cant store an image into a sqlserver 7 with netdirect JDBC driver
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   javier_Hack
Posted On:   Friday, August 23, 2002 12:15 PM

i do this: File file = new File("myimg.jpg"); FileInputStream fin = new FileInputStream(file); String sql = "INSERT INTO img_table (id, img_data) VALUES(?,?)"; PreparedStatement stmt = this.getSession().getConnection().prepareStatement(sql); stmt.setString(1, "1"); stmt.setBinaryStream(2, fin, (int) file.length()); int results = stmt.executeUpdate(); stmt.close(); if ( results == 0 ) { throw new DatabaseException("No se puede grabar la imagen", new Exception()); } It all works fine, with out any exception but when i go to the sql server query analyzer and execute this script "select * from img_table&q   More>>

i do this:

File file = new File("myimg.jpg");
FileInputStream fin = new FileInputStream(file);
String sql = "INSERT INTO img_table (id, img_data) VALUES(?,?)";
PreparedStatement stmt = this.getSession().getConnection().prepareStatement(sql);
stmt.setString(1, "1");
stmt.setBinaryStream(2, fin, (int) file.length());
int results = stmt.executeUpdate();
stmt.close();
if ( results == 0 ) {
throw new DatabaseException("No se puede grabar la imagen", new Exception());
}


It all works fine, with out any exception but when i go to
the sql server query analyzer and execute this script "select * from img_table" no results are shown.
PLEASE, help me , i cant store them in the file system.
TIA
Javier

   <<Less

Re: cant store an image into a sqlserver 7 with netdirect JDBC driver

Posted By:   Laurent_Mihalkovic  
Posted On:   Saturday, August 24, 2002 12:10 AM

hi there,

would you mind taking the time to format your code sample as suggested on the posting page... you know, it really makes a difference.

cheers

About | Sitemap | Contact