Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

java.sql.SQLException: Io exception: Connection reset by peer: socket write

843859Sep 1 2008 — edited Sep 2 2008
I am using NetBeans 6.1 ( from a Client m/C ) and Oracle 9i ( Running on a separate Server m/c in a LAN ).
I am getting this Error Message ( java.sql.SQLException: Io exception: Connection reset by peer: socket write Error )when the size of the Image File exceeds 4 KB....
Any one faced the problem and or any solution ????????
Plz. suggest ................


For Writing ---- [[
try {
File file = new File(str);
fin = new FileInputStream(file);
BufferedInputStream bis = new BufferedInputStream(fin);
PreparedStatement ps = null;
ps = conn.prepareStatement("insert into photo values(?,?)");
if (ps != null) {

ps.setString(1, id);
ps.setBinaryStream(2, bis, (int) file.length());
//System.out.println("success");
ps.execute();

conn.commit();

}
]]

For Reading [[
try {
FileOutputStream fout = null;
OutputStream out1 = response.getOutputStream();
OutputStream os = null;
InputStream bis = null;
InputStream is = null;
BLOB blob = null;
String query = "select * from photo where id=10 for update";

int len;
rs = stmt.executeQuery(query);

if (rs.next()) {

String ID = rs.getString(1);
//fout = new FileOutputStream(new File("E:\\log.jpg"));
//BufferedInputStream bis=new BufferedInputStream(rs.getBinaryStream("PIC"));
BLOB b = ((OracleResultSet) rs).getBLOB(2);
//oracle.sql.BLOB b=(oracle.sql.BLOB)rs.getBlob(2);

byte[] buffer = new byte[(int) b.length() * 4];
System.out.print(b.length());

bis = b.getBinaryStream();




while ((len = bis.read(buffer, 0, buffer.length)) != -1) {

out1.write(buffer, 0, len);




}
out1.close();os.close();
}
]]
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 30 2008
Added on Sep 1 2008
1 comment
331 views