JDBC Connection closes between 'stmt.execute( ... ) and stmt.executeQuery( ... )

dataAllMyLife
New Contributor

I'm running a Java application that registers a CSV table with HIVE and then checks the number of rows imported. Its done in several steps.:

Statement stmt = con.createStatement();

....

stmt.execute( "CREATE TABLE ( <definition> < > );

.....

ResultSet rs = stmt.executeQuery( "SELECT count(*) as rowCnt from ...... );

while (rs.next()) {

rows = rs.getLong(1);

}

As soon as the 2nd statement gets executed I receive an exception

WARNING: sun.reflect.Reflection.getCallerClass is not supported. This will impact performance.

Apr 27, 2022 12:59:37 PM com.simba.spark.jdbc42.internal.apache.http.impl.execchain.RetryExec execute

INFO: I/O exception (java.net.SocketException) caught when processing request to {s}->https://<id>.cloud.databricks.com:443: Connection or outbound has closed

Apr 27, 2022 12:59:37 PM com.simba.spark.jdbc42.internal.apache.http.impl.execchain.RetryExec execute

INFO: Retrying request to {s}->https://<id>.cloud.databricks.com:443

Any ideas or inputs are appreciated .....

Noopur_Nigam
Databricks Employee
Databricks Employee

@Reto Matter​  Are you running a jar job or using dbconnect to run java code? Please provide how are you trying to make a connection and full exception stack trace.