mmolimar / ksql-jdbc-driver

JDBC driver for Apache Kafka
Apache License 2.0
87 stars 19 forks source link

Simple Java connection fails with "No Suitable Driver" #24

Closed avatarsol closed 4 years ago

avatarsol commented 4 years ago

To reproduce:

Have working KSQLDB: http://10.5.100.192:8088/info with page response: KsqlServerInfo |   version | "0.9.0" kafkaClusterId | "0q27dVhgTmKdsdKyO3u28Q" ksqlServiceId | "default_"

Java Code (myapp.java, simplest code, trying just to connect): ... Class.forName("com.github.mmolimar.ksql.jdbc.KsqlDriver"); conn = DriverManager.getConnection(DB_URL); ...

Java app run: java -cp ".:./seed-project-assembly-1.2.0.jar" myapp

Fails with Exception: java.sql.SQLException: No suitable driver found for jdbc:ksql://10.5.100.192:8088 at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:702) at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:251) at KSQLSample.main(KSQLSample.java:18)

avatarsol commented 4 years ago

I was able to build driver with suggested Oracle JDK8 version (while build fails with Oracle JDK14). However when running simple Java code above (in either Oracle JDK8, 14 or OpenJDK11 and 13), trying to connect to SQLDB with new built driver, I still see the same error java.sql.SQLException: No suitable driver found at DriverManager.java:689), as with old driver (built with OpenJDK 13).

I do not quite understand suggestion to match KSQL versions. What I see in driver built.sbt is val ksqlVersion = "5.4.0", but no ksqldb version. There is no matching settings in the reference confluent docker compose file, only: image: confluentinc/ksqldb-server:0.9.0

Some more help would be appreciated.

mmolimar commented 4 years ago

This works with JDK8. Try register the driver in this another way java.sql.DriverManager.registerDriver(new com.github.mmolimar.ksql.jdbc.KsqlDriver).

For this version, you should use ksqldb 0.7.0.

avatarsol commented 4 years ago

Thanks, a lot. Yes, I have now simple Java app running with successful ksqldb query, under Oracle Java 8, with driver compiled also using Oracle Java 8, and having ksldb version = 0.7 in docker (changing ksqldb version in docker-compose.yaml was the key). Driver dependency on Oracle JDK 8 is fine, but could you maybe suggest any workaround (or is there any planned updates) to support apps that require higher JDK version?

mmolimar commented 4 years ago

Yes, there will a new version in a month or so.