-5

i have to insert an image into the matisse database. how can i insert it through sql insert statement in java?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Rukshan
  • 1
  • 1

1 Answers1

0

You can use a java.sql.PreparedStatement to insert a blob into your database.

Example code:

 try{
      Connection con = getYourDatabaseConnection();
      PreparedStatement statement = con.prepareStatement("INSERT INTO YOUR_TABLE(YOUR_BLOB_COLUMN) VALUES (?)";
      statement.setObject(1, yourImage);
      statement.execute();
 } catch(SQLException e){
      e.printStackTrace();
 }
fireandfuel
  • 732
  • 1
  • 9
  • 22