i have to insert an image into the matisse database. how can i insert it through sql insert statement in java?
Asked
Active
Viewed 96 times
1 Answers
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
-
@Makyen It's more a generic solution that should work on the most databases. – fireandfuel Apr 07 '18 at 17:41
-
Documentation says that blob should be supported, can't test it as Matisse is a commercial software and don't provide a free version. – fireandfuel Apr 07 '18 at 18:05
-
hi @fireandfuel how can i browse image and set it to a blob variable first?? in matisse – Rukshan Apr 09 '18 at 04:56
-
@Rukshan: What do you mean with "browse image"? – fireandfuel Apr 09 '18 at 06:14
-
in your try statement "statement.setObject (1, yourImage)"....how can i get that yourImage from system and set it to blob variable? – Rukshan Apr 10 '18 at 04:08
-
@Rukshan It's off topic. Please search in on your own. – fireandfuel Apr 10 '18 at 04:34