Subject | Blob and update pb |
---|---|
Author | Gbouille |
Post date | 2002-12-20T00:01:36Z |
Hi !
I use Jaybird in one of my program.
I think I don't really know how to update a BLOB field un a row. Here is the
code I use (quite the same as the one in the insert example) :
public void setPhoto(InputStream laPhoto, int taille, DataSource dataSource)
{
Connection connection = null;
try
{
connection = dataSource.getConnection();
String SQL = "update personne set photo = ? where id = ?";
PreparedStatement ps = connection.prepareStatement(SQL);
ps.setInt(2, personne.getId().intValue());
ps.setBinaryStream(1, laPhoto, taille);
ps.executeUpdate();
ps.close();
}
catch (SQLException e)
{
System.err.println("Couldn't insert binary data: " + e);
}
finally
{
try
{
if (connection != null)
connection.close();
}
catch (SQLException e)
{
System.err.println("Couldn't insert binary data: " + e);
}
}
}
As a result, the blob field ("photo" here) is still null.
So, do I use it right or not ?
Is it a bug ?
Thanx for your responses.
_____________________________________________________________________
Envie de discuter en "live" avec vos amis ? T�l�charger MSN Messenger
http://www.ifrance.com/_reloc/m la 1�re messagerie instantan�e de France
I use Jaybird in one of my program.
I think I don't really know how to update a BLOB field un a row. Here is the
code I use (quite the same as the one in the insert example) :
public void setPhoto(InputStream laPhoto, int taille, DataSource dataSource)
{
Connection connection = null;
try
{
connection = dataSource.getConnection();
String SQL = "update personne set photo = ? where id = ?";
PreparedStatement ps = connection.prepareStatement(SQL);
ps.setInt(2, personne.getId().intValue());
ps.setBinaryStream(1, laPhoto, taille);
ps.executeUpdate();
ps.close();
}
catch (SQLException e)
{
System.err.println("Couldn't insert binary data: " + e);
}
finally
{
try
{
if (connection != null)
connection.close();
}
catch (SQLException e)
{
System.err.println("Couldn't insert binary data: " + e);
}
}
}
As a result, the blob field ("photo" here) is still null.
So, do I use it right or not ?
Is it a bug ?
Thanx for your responses.
_____________________________________________________________________
Envie de discuter en "live" avec vos amis ? T�l�charger MSN Messenger
http://www.ifrance.com/_reloc/m la 1�re messagerie instantan�e de France