0

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

mpsimham
  • 3
  • 5
  • seems service is not running on 443 port. Can you recheck. – Ashish Patil Nov 07 '22 at 17:36
  • trino-cluster NodePort XXXXXXX 443:31212/TCP 10d Its running on 443 port .. tried with external port also same exception – mpsimham Nov 07 '22 at 17:49
  • Inital default port is 8080 with http .. Then I was facing SSLHandshakeException .. so chnaged to https & 443 then getting connection refused – mpsimham Nov 08 '22 at 17:13
  • Documentation doesn't seem to have any mention of SSL error if you run with 8080. Can you check if you are running this code inside proxy – Ashish Patil Nov 08 '22 at 17:17
  • Updated now Ashish , Currently no proxy / gateway is configured inside the cluster – mpsimham Nov 09 '22 at 07:19
  • Properties properties = new Properties(); properties.setProperty("user", "user"); properties.setProperty("SSL", "false"); Connection connection = DriverManager.getConnection(url,properties); Statement stmt=connection.createStatement(); This worked to bypass SSL Exception and currently connection is established through http .. – mpsimham Nov 09 '22 at 17:15

0 Answers0