[CONJ-123] Session variables lost and exception if set via MySQLDataSource.setProperties/setURL Created: 2014-11-25  Updated: 2014-12-02  Resolved: 2014-11-26

Status: Closed
Project: MariaDB Connector/J
Component/s: None
Affects Version/s: 1.1.7
Fix Version/s: 1.1.8

Type: Bug Priority: Major
Reporter: J. Veldhuizen Assignee: Massimo Siani (Inactive)
Resolution: Fixed Votes: 0
Labels: 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));
  }
}



 Comments   
Comment by J. Veldhuizen [ 2014-11-26 ]

That is handled very quickly! Thank you!

Generated at Thu Feb 08 03:13:20 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.