ksql-jdbc-driver icon indicating copy to clipboard operation
ksql-jdbc-driver copied to clipboard

ClassNotFoundException

Open NitishDhok123 opened this issue 4 years ago • 3 comments

confluent

I am trying to connect to ksqldb public class MainClass {

public static void main(String[] args) {
	try {
		Class.forName("com.github.mmolimar.ksql.jdbc.KsqlDriver");
		KsqlDriver driver=new KsqlDriver();
		String url="jdbc:ksql://localhost:8089";
		
		KsqlConnection con=driver.buildConnection(KsqlDriver.parseUrl(url), null);
		Statement st=con.createStatement();
		ResultSet rs=st.executeQuery("select * from KSQLTEST");
		
		while(rs.next()) {
			System.out.println(rs.getString(0));
		}
	} catch (ClassNotFoundException | SQLException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}

}

but I m facing this issue Exception in thread "main" java.lang.NoClassDefFoundError: io/confluent/ksql/rest/client/KsqlRestClient at com.github.mmolimar.ksql.jdbc.KsqlConnection.init(KsqlConnection.scala:177) at com.github.mmolimar.ksql.jdbc.KsqlConnection.(KsqlConnection.scala:163) at com.github.mmolimar.ksql.jdbc.KsqlDriver.buildConnection(KsqlDriver.scala:71) at com.torana.ksqldemo.MainClass.main(MainClass.java:21) Caused by: java.lang.ClassNotFoundException: io.confluent.ksql.rest.client.KsqlRestClient at java.net.URLClassLoader.findClass(URLClassLoader.java:382) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 4 more

NitishDhok123 avatar Jun 09 '20 13:06 NitishDhok123

Hi. Is the classpath properly set? I mean, all dependencies the driver has are included?

mmolimar avatar Jun 11 '20 00:06 mmolimar

yes can you tell me list of dependency that are need to connect

NitishDhok123 avatar Jun 11 '20 05:06 NitishDhok123

When you build the project with sbt clean assembly all deps are in the fat jar.

mmolimar avatar Jun 11 '20 13:06 mmolimar