aspose file tools*
The moose likes JDBC and the fly likes Error Message Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Error Message" Watch "Error Message" New topic
Author

Error Message

Anshul Agrawal
Greenhorn

Joined: Jul 15, 2008
Posts: 19
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.


Regards
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30537
    
150

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Anshul Agrawal
Greenhorn

Joined: Jul 15, 2008
Posts: 19
No Jeanne
The connection is closed as the thread is completed in my finally block.

The error is random.
Misha Ver
Ranch Hand

Joined: Mar 03, 2008
Posts: 470
It sounds like something odd with the network.
Puja Mantri
Greenhorn

Joined: Sep 24, 2009
Posts: 15
Could you pleae paste the output of following command:
netstat -a -b -v
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error Message