java - Need help- Query to insert an image into a table in sql developer3.0 -
Hello I am using SQL Developer 3.0.
I need to store images in the form of a blob in the table.
I have created a table as:
Create account tables (IMG_ID number, MP_ID number, icon blob); I need to store images
'C: \ project \ images \' any Also please help me insert images in database wuth SQL queries ??
Thanks in advance.
-
Store your image to a file.
file image = new file ("'c: \ project \ images \ image.jpg");
-
The SQL query to insert.
Enter the string Sql = "account_image (IMG_ID, IMG_ID, Icon) value (1,1,?)";
-
Paper Statement >
-
Write a file in the file
FileInputStream fis = Fis = new FileInputStream (image)> ;
-
Attach the fissure to the prepared
pStatement.setBinaryStream (1, fis, fis.length ());
-
Execute
Result as a result = pStatement.executeUpdate ();
A complete
file image = new file ("'c: \ project \ images \ image.jpg"); String Sql = "Enter into account_mage (img_id, img_id, icon) value (1,1,?)"; Created condition pStatement = connection.prepareStatement (SQL); FileInputStream fis = fis = New FileInputStream (Image); PStatement.setBinaryStream (1, fis, fis.length ()); Results Result = pStatement.executeUpdate ();
Comments
Post a Comment