I am getting below exception when executing sql query through trino Java API
[] threw exception [Request processing failed; nested exception is java.sql.SQLException: Error executing query: java.net.ConnectException: **Failed to connect to /clusterIP:port]** with root cause
java.net.ConnectException: Connection refused (Connection refused)
at java.net.PlainSocketImpl.socketConnect(Native Method) ~[na:1.8.0_212]
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) ~[na:1.8.0_212]
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) ~[na:1.8.0_212]
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~[na:1.8.0_212]
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[na:1.8.0_212]
at java.net.Socket.connect(Socket.java:589) ~[na:1.8.0_212]
at io.trino.jdbc.$internal.okhttp3.internal.platform.Platform.connectSocket(Platform.java:130) ~[trino-jdbc-402.jar!/:402]
at io.trino.jdbc.$internal.okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.java:263) ~[trino-jdbc-402.jar!/:402]
with http & 8080 port below is the message :
"message": "Error executing query: javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake",
Maven dependency:
<dependency>
<groupId>io.trino</groupId>
<artifactId>trino-jdbc</artifactId>
<version>402</version>
Code snippet:
String url = "jdbc:trino://trino-cluster:443";
String sql = "select * from keyspace.tableName";
Properties properties = new Properties();
properties.setProperty("user", "user");
properties.setProperty("SSL", "true");
Connection connection = DriverManager.getConnection(url,properties);
Statement stmt=connection.createStatement();
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()){
System.out.println(rs.getString(1));
}
System.out.println(connection.getCatalog());
Followed this ref to deploy trino-cluster with 8080 port and updated it to 443 for SSL Handshake issue resolution.
https://trino.io/docs/current/installation/kubernetes.html
I am able to exec the pod and run cassandra queries, but from java while executeQuery() its giving exception.
I have deployed trino using helm as one service and created another micro service with above code snippet to connect to trino service and run the queries in kubernetes cluster
Kindly suggest if any changes needed. Couldn't get much docs w.r.t trino Java Integration.
My requirement to connect to trino to fetch records from cassandra connector through Java API