File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error Message

 
Anshul Agrawal
Greenhorn
Posts: 19
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All

I have made a service which connects to jdbc:microsoft:sqlserver and Process some tasks.

The service connects to database after every 10 min and process my code.All goes well.

But If the service is kept running for say 24 hrs it gives me error

[ [Microsoft][SQLServer 2000 Driver for JDBC]Connection reset by peer: socket write error]

The error is random means it not coming everytime.

I have checked the logs also, the server wasn't down.

I am trying with the validationQuery setting

private Connection getDBConn() throws SQLException, ClassNotFoundException {
Connection conn;

Class.forName(driver);

if ((dbName != null) && (!dbName.equals(""))) {
connectionURL = connectionURL + ";DatabaseName=" + dbName;
} else {
connectionURL = connectionURL + ";DatabaseName=master";
}

connectionURL.concat("?validationQuery=String 1");

logger.debug("Establishing Connection: " + connectionURL);

conn = DriverManager.getConnection(connectionURL, username, password);

return conn;
}


is this correct ?

Please suggest.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33697
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anshul,
Where do you close the connection? It sounds like the same connection is used for 24 hours which will result in a timeout. The alternative is to use a connection pool so the connection can reset itself as needed.
 
Anshul Agrawal
Greenhorn
Posts: 19
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No Jeanne
The connection is closed as the thread is completed in my finally block.

The error is random.
 
Misha Ver
Ranch Hand
Posts: 470
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It sounds like something odd with the network.
 
Puja Mantri
Greenhorn
Posts: 15
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you pleae paste the output of following command:
netstat -a -b -v
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic