0

I keep getting this error randomly when I test an application with mssql and don't have an idea of what I can do to correct the issue.

Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b):
org.eclipse.persistence.exceptions.DatabaseException 
Internal Exception: com.microsoft.sqlserver.jdbc.SQLServerException:
Connection reset ClientConnectionId:a2fb508d-0e8e-48b0-92ed-2d1f262b4db1 Error Code: 0

My setup consists of

  1. Eclipselink as the ORM
  2. sqljdbc v4.1
  3. sql server 2014
  4. Java 8

I believe the problem is probably a setting within sql-server though I haven't seen anything that I could correct. The application works perfect on postgres and mysql but the customer only wants to use mssql.

Bwire
  • 1,181
  • 1
  • 14
  • 25
  • What is the background? Do you run any sql updates/selects? any procedures? Can you run them manually in ssms without any errors? How long do they run? Maybe you have set a to low timeout? – Ionic Jun 15 '15 at 13:33
  • @Ionic yes there are some daemon applications that keep accessing the database to check for different conditions. Mainly they do selects with minor updates in a ratio of about 20:1 no deletes and inserts are there. These daemons are expected to always be running. The default timout from the docs[http://www.eclipse.org/eclipselink/documentation/2.4/jpa/extensions/q_jdbc_timeout.htm] is 0 hence they are not expected to timeout. – Bwire Jun 15 '15 at 13:39
  • I've had sometimes the same experience. The server itself has a timeout with 0, which means it won't timeout. But my c# application has it's own timeout which terminates. You might want to take a look at sys.dm_tran_locks to check if there is a lock while your application is running. Maybe this helps. Here an example: SELECT * FROM sys.dm_tran_locks WHERE resource_database_id = DB_ID() and request_session_id = [YOURSESSION] – Ionic Jun 15 '15 at 13:46
  • @Ionic where exactly would this lock be expected to be initiated. the query does not yield any results. – Bwire Jun 15 '15 at 13:52
  • Well I can't know if it yields anything. Because I don't know which query you run. :-) – Ionic Jun 15 '15 at 13:57
  • @Ionic I ran the query you proposed : SELECT * FROM sys.dm_tran_locks WHERE resource_database_id = DB_ID() and request_session_id = "805925a8-01d8-40f4-adea-04bc08a392fc"; – Bwire Jun 15 '15 at 14:42
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/80579/discussion-between-bwire-and-ionic). – Bwire Jun 15 '15 at 14:54
  • Your request_session_id looks a bist weird. The request_session_id is your spid. I'm currently on the way to bed. If you want we could talk tomorrow. – Ionic Jun 15 '15 at 20:31

1 Answers1

1

MSFT JDBC drivers do not call the sp_reset_connection procedure used to cleanup from the previous session.

I am thinking that this error is coming from something left hanging that is being cleaned up with the other databases.

You will need to run a SQL Profile trace on all the connections until the error occurs to see the actual cause.

More can be found at : What does "exec sp_reset_connection" mean in Sql Server Profiler?

Community
  • 1
  • 1
Rawheiser
  • 1,200
  • 8
  • 17
  • So that means it is a jdbc issue? Which jdbc driver would you recommend I go with then? – Bwire Jun 18 '15 at 19:38
  • The only other driver I have used is jTDS, which also does not call that MS specific procedure. You would have to see if your Connection Pool Manager has a validate method that is called before handing out a connection from the pool,and call the reset proc from there. I don't know enough about EclipseLink to help you there. – Rawheiser Jun 19 '15 at 18:42