*
The moose likes JDBC and the fly likes Jdbc - inserting records-exception(connection reset). Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Jdbc - inserting records-exception(connection reset)." Watch "Jdbc - inserting records-exception(connection reset)." New topic
Author

Jdbc - inserting records-exception(connection reset).

Sonara Rahul
Ranch Hand

Joined: Jul 07, 2001
Posts: 60
Dear Friends,
Culd U please help me out in this regard.
I Update database(pointbase) by inserting few records through Jdbc statements.
When execute select statements I don't get this exception,but when I try to insert records I get this exception.
[java] java.net.SocketException: Connection reset by peer: socket write err
[java] at java.net.SocketOutputStream.socketWrite0(Native Method)
[java] at java.net.SocketOutputStream.socketWrite(SocketOutputStream.ja
92)
[java] at java.net.SocketOutputStream.write(SocketOutputStream.java:126
[java] at com.sun.net.ssl.internal.ssl.OutputRecord.a(DashoA6275)
[java] at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA6275)
[java] at com.sun.net.ssl.internal.ssl.AppOutputStream.flush(DashoA6275
[java] at com.sun.net.ssl.internal.ssl.AppOutputStream.close(DashoA6275
[java] at org.mortbay.http.NullableOutputStream.destroy(NullableOutputS
am.java:81)
[java] at org.mortbay.http.HttpOutputStream.destroy(HttpOutputStream.ja
390)
[java] at org.mortbay.http.HttpConnection.destroy(HttpConnection.java:1
)
[java] at org.mortbay.http.HttpConnection.handle(HttpConnection.java:81
[java] at org.mortbay.http.SocketListener.handleConnection(SocketListen
java:196)
[java] at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:28
[java] at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:48

People who have come across such an exception ,please do reply me with solutions or cause for it.
Expecting ur reply,
Thanks & Regards,
Sonara.
Sanjeev Kaushik
Ranch Hand

Joined: Aug 01, 2002
Posts: 105
Can you send your piece of code?


Sanjeev Kaushik
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

From the Oracle Docs: --> the ideas can be applied to pointbase as well
Error Message: "Connection reset by peer"
Typically, this is the error you will see if the server crashes out while you are connected to it. You may be in the process of establishing a connection, or you could be midway through an established connection. Either way, you should check the server side log files to see what errors and stack dumps were thrown on the server.
Note that this error is different to what happens if you try to connect to a wrong/invalid port or even machine, you would get a different error, not this one. Its also different to the error you would get if the server is down and not accepting connection requests.
Sonara Rahul
Ranch Hand

Joined: Jul 07, 2001
Posts: 60
Hello Mr.Sanjeev Kaushik,
Here is the part of my code where I like to insert records in the loop.
/~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~/
Vector getvector=new Vector();
int transMaxId=0;
String query="insert into Sample(id,name,no) values(?,?,?)";
PreparedStatement pstatement=igeteniv.getPreparedStatement(query);
int vecsize=getvector.size();
Vector internal=new Vector();
internal=getvector;
for(int i=0;i<vecsize;i++)
{
transMaxId=transMaxId+1;
try {
pstatement.setInt(1,transMaxId);
pstatement.setString(2,internal.get(i).toString());
pstatement.setString(3,"1");
pstatement.addBatch();
int[] ss=pstatement.executeBatch();
} catch (SQLException e) {
e.printStackTrace();
}
}
/~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~/
Still the code works fine without connection reset error,if the query is SELECT.Hope U wuld reply.
Thanks & Regards,
Sonara.
Sonara Rahul
Ranch Hand

Joined: Jul 07, 2001
Posts: 60
Hello Mr.jamie Robertson,
Thanks for ur reply.
But still I have my server running properly & is able to handle other request.I dont establish connection at that time its already established & also queries are already made,which worked fine.
This exception occurs only if I do some insert statements,& if the query is of select like that sort it works fine in the same regard.
So what culd be the problem.
Expecting ur reply,
Sonara.
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

try eliminating the possibility of error from the batch statements.
change:
pstatement.addBatch();
int[] ss=pstatement.executeBatch();
to:
pstatement.executeUpdate();
and give it a try. Even though your code should work, you are not using the batch statements properly. ( the executeBatch() should occur outside the loop to experience any performance gains from the batch statements )
Jamie
Sonara Rahul
Ranch Hand

Joined: Jul 07, 2001
Posts: 60
Hello Mr.jamie Robertson,
Thx once again for ur other reply.The specified statement also I have tried,pstatement.executeUpdate();But still I get the error. ((

Hope u wuld tell me some other solution.
Thanks & Regards,
Sonara.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Jdbc - inserting records-exception(connection reset).