Shankar Guru
Shankar Guru

Reputation: 1161

Azure SQL : error code for Connection is closed exception's

I am getting below exceptions at times in my java code which connects to Azure SQL server. For this, I need to implement retry logic i.e. when I face below exception I will retry 1) Create new connection 2) Re-execute the SQL query 3) Commit the transaction.

But, I am unable to get the Azure SQL server error code for below error. Please let me know the error code ? I do not see the error code when I run below query:

SELECT * FROM sys.messages WHERE language_id = 1033 

Exception:

com.microsoft.sqlserver.jdbc.SQLServerException: The connection is closed.
    at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:227)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.checkClosed(SQLServerConnection.java:796)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.commit(SQLServerConnection.java:2681)

Also, is it a good practice to use e.getMessage() and check if return string is "The connection is closed." and retry my logic ?

I do not see the error code in Error codes from SQL

Upvotes: 0

Views: 969

Answers (1)

Alberto Morillo
Alberto Morillo

Reputation: 15648

This exception seems to be related to an attempt to convert from a supported data type to an unsupported data type. This is a good example.

Try another version of the JDBC driver.

Upvotes: 0

Related Questions