Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
1.1.7
-
None
-
None
Description
If I set session variables via the MySQLDataSource.setProperties method (or indirectly with setURL), the value of the 'sessionVariables' parameter is not picked up correctly.
I use:
dataSource.setProperties("sessionVariables=sql_mode='PIPES_AS_CONCAT'")
|
The current implementation of this method is:
public void setProperties(String properties) {
|
String[] parameters = properties.split("&");
|
for (String param : parameters) {
|
String[] keyVal = param.split("=");
|
this.info.setProperty(keyVal[0], keyVal[1]);
|
}
|
}
|
which leads to the property 'sessionVariables' with value 'sql_mode'.
The entire text after sql_mode is lost and creating a connection to the database throws an exception.
The implementation of parsing properties in the class Driver is correct:
private void setURLParameters(String urlParameters, Properties info)
|
{
|
String[] parameters = urlParameters.split("&");
|
for (String param : parameters) {
|
int pos = param.indexOf('=');
|
if (pos == -1) {
|
throw new IllegalArgumentException("Invalid connection URL, expected key=value pairs, found " + param);
|
}
|
info.setProperty(param.substring(0, pos), param.substring(pos + 1));
|
}
|
}
|