Java / JDBC
How can we store images in the database using JDBC?
Using PreparedStatement interface, we can store and retrieve images.
The setBinaryStream() method of PreparedStatement sets binary information into the parameterIndex.
PreparedStatement ps=con.prepareStatement("insert into images values(?,?)"); ps.setInt(1,400); //Image index FileInputStream fis=new FileInputStream("d:\\myImage.jpg"); ps.setBinaryStream(2,fis,fis.available()); int i=ps.executeUpdate();
More Related questions...