Example to retrieve image from Oracle databaseBy the help of PreparedStatement we can retrieve and store the image in the database. The getBlob() method of PreparedStatement is used to get Binary information, it returns the instance of Blob. After calling the getBytes() method on the blob object, we can get the array of binary information that can be written into the image file. Signature of getBlob() method of PreparedStatementSignature of getBytes() method of Blob interfaceWe are assuming that image is stored in the imgtable. Now let's write the code to retrieve the image from the database and write it into the directory so that it can be displayed. In AWT, it can be displayed by the Toolkit class. In servlet, jsp, or html it can be displayed by the img tag. Now if you see the d drive, sonoo.jpg image is created. Next TopicStoring file in the database using java |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India