Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java application can not use noria-mysql adapter #15

Open
lipinskipawel opened this issue May 19, 2020 · 1 comment · May be fixed by jonhoo/msql-srv#14
Open

Java application can not use noria-mysql adapter #15

lipinskipawel opened this issue May 19, 2020 · 1 comment · May be fixed by jonhoo/msql-srv#14

Comments

@lipinskipawel
Copy link

Hey! I was trying to run Java application with Noria but I got an exception

Exception in thread "main" java.sql.SQLNonTransientConnectionException: CLIENT_SECURE_CONNECTION is required
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:110)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:73)
	at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:79)
	at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:836)
	at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:456)
	at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:246)
	at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:197)
	at java.sql.DriverManager.getConnection(DriverManager.java:664)
	at java.sql.DriverManager.getConnection(DriverManager.java:270)
	at com.example.demo.DemoApplication.main(DemoApplication.java:12)
Caused by: com.mysql.cj.exceptions.UnableToConnectException: CLIENT_SECURE_CONNECTION is required
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
	at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:61)
	at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:85)
	at com.mysql.cj.protocol.a.NativeAuthenticationProvider.connect(NativeAuthenticationProvider.java:111)
	at com.mysql.cj.protocol.a.NativeProtocol.connect(NativeProtocol.java:1342)
	at com.mysql.cj.NativeSession.connect(NativeSession.java:157)
	at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:956)
	at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:826)
	... 6 more

Steps to reproduce:

  • run zookeeper (docker image all ports are exposed)
  • run noria from README (cargo r --release --bin noria-server -- --deployment myapp --no-reuse --shards 0)
  • run noria-mysql from README (cargo run --release -- --deployment myapp -z 127.0.0.1:2181)
  • execute mysql -h 127.0.0.1
  • create table and insert data in it (CREATE TABLE Cats (id int, name VARCHAR(255), PRIMARY KEY(id));, INSERT INTO Cats (id, name) VALUES (1, "bob");)
  • run Java application
Some java app example main method
Class.forName("com.mysql.cj.jdbc.Driver");
final String name = DriverManager
          .getConnection("jdbc:mysql://127.0.0.1/")
          .prepareStatement("select * from Cats")
          .executeQuery()
          .getString("name");
System.out.println(name);

pom.xml

<dependency>
     <groupId>mysql</groupId>
     <artifactId>mysql-connector-java</artifactId>
     <version>8.0.20</version>
</dependency>

My questions:

  1. Is they any solution to resolve this error above?
  2. How to interact with noria-mysql adapter through the Java code?
  3. What is the general idea of interacting with noria-mysql? (besides mysql -h 127.0.0.1 nothing is working for me)
@jonhoo
Copy link
Collaborator

jonhoo commented May 19, 2020

Ah, yes, msql-srv (which provides the MySQL interface) does not currently support the SSL handshake, and thus only supports non-encrypted connections. If the Java library requires a secure connection ("CLIENT_SECURE_CONNECTION is required"), and that can't be disabled, then the way forward would be to add SSL support to msql-srv. Adding it shouldn't be too difficult, though I don't personally have the bandwidth to do so at the moment. If you want to take a stab at writing a PR, I'd be happy to take a look! See also jonhoo/msql-srv#10 which also has some Java-related problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants