Skip to content

Java application can not use noria-mysql adapter #15

@lipinskipawel

Description

@lipinskipawel

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions