[CONJ-71] Database isn't auto-selected when connecting over SSL Created: 2013-10-29  Updated: 2014-09-17  Resolved: 2013-11-14

Status: Closed
Project: MariaDB Connector/J
Component/s: None
Affects Version/s: 1.1.5
Fix Version/s: 1.1.6

Type: Bug Priority: Major
Reporter: Colin Finck (Inactive) Assignee: Georg Richter
Resolution: Fixed Votes: 1
Labels: None

Issue Links:
Relates
relates to CONJ-93 Connection fails when there is a '-' ... Closed

 Description   

Based on CONJ-64, I've tried to set up my MySQL Server with a self-signed certificate and use the MariaDB Java Client 1.1.5 to connect to it.
I'm using the following code:

public static void main(String[] args)
{
  try
  {
    Class.forName("org.mariadb.jdbc.Driver").newInstance();
    String url = "jdbc:mysql://localhost:3306/test";
 
    Properties info = new Properties();
    info.setProperty("user",  "root");
    info.setProperty("password", "");
    info.setProperty("serverSslCert", "C:\\cert.pem");
    info.setProperty("useSSL", "true");
 
    Connection conn = DriverManager.getConnection(url, info);
    Statement st = conn.createStatement();
    st.executeQuery("SELECT * FROM tbl");
    
    conn.close();
  }
  catch (ClassNotFoundException ex) {System.err.println(ex.getMessage());}
  catch (IllegalAccessException ex) {System.err.println(ex.getMessage());}
  catch (InstantiationException ex) {System.err.println(ex.getMessage());}
  catch (SQLException ex) {System.err.println(ex.getMessage());}
}

The database "test" exists and contains a table called "tbl".
When I run this code, it throws an exception at executeQuery stating "No database selected". All works well when commenting out setProperty("useSSL", "true"). I can also "fix" the problem by changing the SQL query to "SELECT * FROM test.tbl", but this is really not what I want.

This issue is independent of the MySQL Server as I've tried it with 5.0.67-community-nt and 5.5.34-0ubuntu0.12.04.1. Both have been set up with the same SSL certificate.



 Comments   
Comment by Colin Finck (Inactive) [ 2013-11-06 ]

Bump!
I can't believe that I'm the only one suffering from this bug. Especially, because this makes SSL self-signing support pretty much unusable, which is a key benefit of the MariaDB Java Client in contrast to the MySQL one.

Comment by Georg Richter [ 2013-11-14 ]

Fixed in rev. 494

Comment by Vladislav Vaintroub [ 2014-05-22 ]

Team facebook also reported extraneous "use" call overhead in https://www.facebook.com/notes/mysql-at-facebook/jdbc-connection-overheads/10152027251270933 . I fixed it in the attachment for CONJ-93

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