Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JDBC store the image in the oracle using blob and get it back

Have Programming Question? Ask it here!
 
 
 


mukeshbhoge
store the image in the oracle using blob and get it back
3 Answer(s)      6 years and 3 months ago
Posted in : JDBC



Advertisement
View Answers

June 24, 2008 at 7:52 PM


Hi friend,


i am sending code using jdbc connection,

package javacode;

import java.sql.*;
import java.io.*;

public class InsertImage{
public static void main(String[] args) throws IOException {
System.out.println("Insert Image Example!");
String driverName = "com.mysql.jdbc.Driver";
String url = "jdbc:mysql://192.168.10.211:3306/";;
String dbName = "amar";
String userName = "amar";
String password = "amar123";
Connection con = null;
try{
Class.forName(driverName);
con = DriverManager.getConnection(url+dbName,userName,password);
Statement st = con.createStatement();
File imgfile = new File("javacode/rose.jpg");
FileInputStream fin = new FileInputStream(imgfile);
PreparedStatement pre = con.prepareStatement("insert into Image values(?,?,?)");
pre.setInt(1,1);
pre.setString(2,"rose");
pre.setBinaryStream(3,fin,(int)imgfile.length());
pre.executeUpdate();
System.out.println("Inserting Successfully!");
pre.close();
con.close();
}
catch (Exception e){
System.out.println(e.getMessage());
}
}
}



-------------------------------------------------------------

Read for more information,

http://www.roseindia.net/jdbc/

Thanks

(Roseindia Team)


June 25, 2008 at 2:10 PM


hi friend,

i am sending insert and retrive image code

package javacode;

import java.sql.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.PreparedStatement;
import java.sql.Statement;
import java.sql.Blob;
import java.io.*;

class RetriveImage {
FileOutputStream image;
Connection con = null;
PreparedStatement pstmt = null;
Statement stmt= null;
ResultSet res = null;
StringBuffer query=null;
String filename = "javacode/rose.jpg";
String driverName = "com.mysql.jdbc.Driver";
String url = "jdbc:mysql://192.168.10.211:3306/";;
String dbName = "amar";
String userName = "amar";
String password = "amar123";

public RetriveImage(){
try{
query=new StringBuffer("insert into Image(id,imgName,image) values (?,?,?)");
File file= new File(filename);
Class.forName(driverName);
con = DriverManager.getConnection(url+dbName,userName,password);
stmt=con.createStatement();
pstmt=con.prepareStatement(query.toString());
pstmt.setInt(1, 6);
pstmt.setString(2,"rose");
pstmt.setBinaryStream(3, new FileInputStream(filename),(int)file.length());
pstmt.executeUpdate();
System.out.println("Successfully inserted into image .....");
ResultSet rs=stmt.executeQuery("select * from Image where image='image'");
if (rs.next()) {
Blob test=rs.getBlob("image");
InputStream x=test.getBinaryStream();
int size=x.available();
OutputStream out=new FileOutputStream("javacode/rose.jpg");
byte b[]= new byte[size];
x.read(b);
out.write(b);
}
}
catch(ClassNotFoundException cnfe){
System.out.println("ClassNotFoundException occured :"+cnfe);
}
catch(SQLException se){
System.out.println("SQLException occured :"+se);
}
catch(FileNotFoundException fe){
System.out.println("File Not Found Exception occured :"+fe);
}
catch(Exception e){
System.out.println("Exception occured :"+e);
}
finally{
try{
stmt.close();
con.close();
}
catch(Exception e){
System.out.println(e);
}
}
}
public static void main(String args[]) throws IOException{
RetriveImage ri = new RetriveImage();
}
}

---------------------------------------
In this program using jdbc driver , if you want to use oracle driver then change driver name,

Read for more information,

http://www.roseindia.net/jdbc/

Thanks.


June 18, 2011 at 9:26 PM


hello is their any substitute for set binary stream when i tried to executed it by changing the driver , connection in column based databases it was not supporting it . pls provide a alternatuve



Related Tutorials/Questions & Answers:
store the image in the oracle using blob and get it back - JDBC
store the image in the oracle using blob and get it back  hi i am facing problem in the following code . this code can store the image in table but at time of reading it back it never shows me the image ..so plz try this code
store the image in the oracle using blob and get it back - JDBC
store the image in the oracle using blob and get it back  hi i am facing problem in the following code . this code can store the image in table but at time of reading it back it never shows me the image ..so plz try this code
Advertisements
image store and get it back
image store and get it back  store the image in the oracle using blob and get it back hi i am facing problem in the following code . this code can store the image in table but at time of reading it back it never shows me
image store in oracle using jswing
image store in oracle using jswing  hello ,ihave searched the image store in oracle using jswing but i did not find the code please help me
how to store image in oracle express edition using servlet
how to store image in oracle express edition using servlet  strong text how to store image in oracle express edition using servlet?   Please visit the following link: Servlet Insert image into MySQL database
Oracle BLOB
Oracle BLOB  Can anyone send me the code for inserting an image or audio into the oracle database using BLOB datatype. Plz...it's useful for my project
store & retrive the image from oracle database
store & retrive the image from oracle database  how can i store the image path in tha database & fetch that image from oracle database
get Blob
get Blob   how i can display a Blob in XHTML (i developpe with hbernate
How to Store Image using JSF
How to Store Image using JSF  Hi How to upload images in db. using jsf. For jsf photo uploading .. I used this one code for upload image.. But this code haven't option to upload any images . i want to store image in db
Upload and display image and text records using JSP and Oracle
Upload and display image and text records using JSP and Oracle  Hi all, I'm using JSP and Oracle 10g. I could retrieve and display records from database. But i couldnot retrieve and display image. I want to store
Exception while inserting image in oracle using java
Exception while inserting image in oracle using java  import...()); Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost...()); System.out.println("Image length: "+f.length()); System.out.println("No.of rows
Insert Blob(Image) in Mysql table using JSP
Insert Blob(Image) in Mysql table using JSP In this Section, we will insert blob data(image) in Mysql database table using JSP code. A Blob stores a binary... Blob(Image) in Mysql table using JSP Download Source Code
Insert or retrieve image into oracle 10g by using java
Insert or retrieve image into oracle 10g by using java   How can i insert or retrieve image into oracle10g using java plz i need it urgently,need guidance to do this plz
Display Blob(Image) from Mysql table using JSP
Display Blob(Image) from Mysql table using JSP In this section, we will display blob data(image) from Mysql database table using JSP code. A Blob stores... : Insert Blob(Image) in Mysql table using JSP Download Source Code
Store image from html img tag into mysql db using java
Store image from html img tag into mysql db using java  Hi. How to get the image displayed in the < img > tag of HTML and store it in the mysql database using java? Thanks in advance
How to store image into database
into database using Java. Can anyone help me that how can i store image into database using Java. Thanks in advance.   hi friend, To store image... through the following link How To Store Image Into MySQL Using Java
How To Store Image Into MySQL Using Java
How To Store Image Into MySQL Using Java In this section we will discuss about how to store an image into the database using Java and MySQL. This example.... To store an image into database there are four data types tinyblob, blob
using Blob in jdbc - JDBC
using Blob in jdbc  Hi, I got an Exception when i was trying to insert one image into oracle 10g database the exception is Exception in thread..."); Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost
access image from ajax store in mysql using jsp
access image from ajax store in mysql using jsp  access image from ajax store in mysql using jsp (code to access image captured by camera and store in mysql
how to store and retrieve image using struts2 and hibernate integration
how to store and retrieve image using struts2 and hibernate integration  how to store and retrieve image using struts2 and hibernate integration? plz help !! thanks in advance
Blob column
Blob column  Hi all... How to store an excel file in Blob column? I m using oracle 11 g database
how to store image in folder and stored image path in mysql database using JSP
how to store image in folder and stored image path in mysql database using JSP  how to store image in folder and stored image path in mysql database using JSP
How to store user name,city,state,image path into database and image into folder using jsp
How to store user name,city,state,image path into database and image into folder using jsp  How to store user name,city,state,image path into database and image into folder using jsp
servlet program for data store in oracle?
servlet program for data store in oracle?  how to store data in oracle through servlet program
Get Blob
Get Blob      ... where you want to retrieve image saved as blob.    2. Create... as a Blob object by using getBlob() method.     4. Write data
How to store an image in database
How to store an image in database  Hi........... How to store an image in postgresql using a query. I mean tell me the way to store an image using datatype. I am using the datatype bytea but tell me how to insert the image
get and display blob from mysql on jsf
get and display blob from mysql on jsf  i want to get blob from mysql, and display on jsf page. your examples with jsp. i dont find an example with jsf. plese help me about this. thanks..   Have a look at the following
How to get data from Oracle database using JSP
How to get data from Oracle database using JSP  hello i have a simple problem in jsp in the sense to get data from the database like oracle . I have... in the sense to get data from the database like oracle . I have created one jsp
Unable to store the image into database
Unable to store the image into database  Hello, I have created below... ###################################### CREATE TABLE IMAGEMAIN(ID INTEGER,IMAGE BLOB) ; ################## HTML Form... of image. I have debug the JSP program and found that HTML form pass only image
how to store image file and videofile in ms access database using java? - JDBC
how to store image file and videofile in ms access database using java?  how to store image file and video file in ms access database using java
image store in database - JDBC
image store in database  Dear Deepak Sir, If I want to store image... to store image into database. Check at http://www.roseindia.net/servlets/insert...; Inserting Image in Database Table http://www.roseindia.net/jdbc/jdbc-mysql/insert
Retrieving images from the oracle database using jsp and create that rretrieved image as hyperlink
Retrieving images from the oracle database using jsp and create that rretrieved image as hyperlink  I want to insert images into oracle database.I want to retrieve images using jsp and I want to display on the browser.The
store and retrive image from the database
store and retrive image from the database  please provide me... to store and retreive images from sql database using sql commands -how to store and retreive images from sql database using asp.net/c# thanks in advance
How can we get the properties (size, type, width, height) of an image using php image functions?
How can we get the properties (size, type, width, height) of an image using php image functions?  How can we get the properties (size, type, width, height) of an image using php image functions
How to get the text from textarea in HTML and store it in database using javascript and jsp
How to get the text from textarea in HTML and store it in database using javascript and jsp  How to get the text from textarea in HTML and store it in database using javascript and jsp <script> function str() { <
add text box and select list dynamically and get its value to store it into database using jsp request parameter
add text box and select list dynamically and get its value to store it into database using jsp request parameter  its very helpful when you have only dynamically added text field but want code to retrive value of dynamically
How to get the data from the database (Oracle) in console or in ie using servlet or jsp as Front end
How to get the data from the database (Oracle) in console or in ie using servlet or jsp as Front end  hello i have a simple problem in jsp in the sense to get data from the database like oracle . I have created one jsp
oracle
oracle   sir now am doing one project , my frond end is vb and backend is oracle. so 1> how can i store the image in my field 2> how can i back up the table into .txt file
how to store and retrieve image from database
how to store and retrieve image from database  how to store and retrieve images into database(oracle) and how to retrive images from database using jsp   Here is a jsp code that insert and retrieve image from mysql
Get image color
Get image color  How to get image color in iPhone SDK application
Jmagick get image size
Jmagick get image size  Hi, How I can get the image size while using... to get the image size when using Jmagick ImageInfo ii = new ImageInfo(path...; hi, the code given below may help you to get the image size when using
Get Image
Get Image       This Example shows you get the image. Description of the code.... Toolkit.getImage() : getImage method return a Image class object and this object get
Programming using applets and oracle - Applet
Programming using applets and oracle  Develop an Online Examination software in java using applets as front end and oracle as back end. Software.... Following are the classes used in the software: 1. EXAM to store
Write a program to get student details and store in a database
Write a program to get student details and store in a database  Write a program to get student details and store in a database
store and retrive image from database - JDBC
store and retrive image from database  how to store and retrive an image in database using java?  Hi friend, Code for store image in database using Java. import java.sql.*; import java.io.*; public class
How to save excel sheet into mysql database using blob or clob
How to save excel sheet into mysql database using blob or clob  Hi All, I am new to java and i need to upload excel sheet to mysql, please suggest... know to go further, which one should i use BLOB or CLOB ? I have tried using
how to store and then immediately retrieve when store the image into database?
how to store and then immediately retrieve when store the image into database?  how to store and then immediately retrieve when store the image into database?   Here is a jsp code that insert and retrieve image from
change color of back ground using switch
change color of back ground using switch   how to change back ground color according to day using switch case
Image name,image path into database and image into folder using jsp
Image name,image path into database and image into folder using jsp  How to insert image path and image name into oracle database and image into folder using jsp
servelet connectivity with oracle using procedure
servelet connectivity with oracle using procedure   kindly elaborate how servlet code connect to oracle br using procedure
Advertisements
 

 

 

DMCA.com