Unable to store the image into database

Unable to store the image into database

Hello, I have created below program and program is throwing FileNotFound exception when I pressed the submit button. The problem is coming due to JSP page is not able to find complete path of image. I have debug the JSP program and found that HTML form pass only image name without path that's why problem is coming. Can anyone resolve this problem.

##################  SQL Query ######################################

    CREATE TABLE IMAGEMAIN(ID INTEGER,IMAGE BLOB) ;

##################  HTML  Form ######################

     <form name="frm" method="post" action="index.jsp">
     <input type="text" name="hint">
     <input type="file" name="user_file">
     <input type="submit">

################### JSP PAGE ########################

try
{ 
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    System.out.println("Connection loaded");
    Connection con = DriverManager.getConnection("jdbc:odbc:project","image","image");
    System.out.println("Connection created");
    String ll=request.getParameter("user_file");
    String lo=request.getParameter("hint");
    File imgfile = new File(ll);

    FileInputStream fin = new FileInputStream(imgfile);

    PreparedStatement pre = con.prepareStatement("insert into IMAGEMAIN (id,image) values(?,?)");
    pre.setString(1,lo);
    pre.setBinaryStream(2,fin,(int)imgfile.length());
    pre.executeUpdate();
    pre.close();
}

catch(Exception E)
{
    out.println("the eror is  "+ E);
}
View Answers

August 20, 2013 at 2:44 PM

Hi,

Please check the thread How to Insert image into database?

Thanks









Related Tutorials/Questions & Answers:
Unable to store the image into database
Unable to store the image into database  Hello, I have created below...); }   Hi, Please check the thread How to Insert image into database... of image. I have debug the JSP program and found that HTML form pass only image
How to store image into database
How to store image into database  Hi, all I want to store image 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
Advertisements
image store in database - JDBC
to store image into database. Check at http://www.roseindia.net/servlets/insert...image store in database  Dear Deepak Sir, If I want to store image...; Inserting Image in Database Table http://www.roseindia.net/jdbc/jdbc-mysql/insert
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
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
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
How to store and retrieve image from database in JSP?
How to store and retrieve image from database in JSP?  Hi, In one of my application I have to store and then display the image in JSP. How to store and retrieve image from database in JSP? Thanks   HI, You can use
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...()); } } } For retrieve image from database visit to : http
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
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
how to store image upload path to mssql database
how to store image upload path to mssql database  hi there!!, i need help in storing the image upload path into the database. basically i just use file select to upload the image from jsp to database. however when i click submit
how to store image upload path to mssql database
how to store image upload path to mssql database  hi there!!, i need help in storing the image upload path into the database. basically i just use file select to upload the image from jsp to database. however when i click submit
how to store image upload path to mssql database
how to store image upload path to mssql database  hi there!!, i need help in storing the image upload path into the database. basically i just use file select to upload the image from jsp to database. however when i click submit
how to store image upload path to mssql database
how to store image upload path to mssql database  hi there!!, i need help in storing the image upload path into the database. basically i just use file select to upload the image from jsp to database. however when i click submit
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
How To Store Multilple Images In MySQL database dynamically with image uploader and then retrieve them in image gallery using java
How To Store Multilple Images In MySQL database dynamically with image uploader and then retrieve them in image gallery using java  How To Store Multilple Images In MySQL database dynamically with image uploader
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
unable to connect database in java
unable to connect database in java  Hello Everyone! i was trying to connect database with my application by using java but i am unable to connect... i was using this code.... try { Driver d=(Driver)Class.forName
unable to connect database in java
unable to connect database in java  Hello Everyone! i was trying to connect database with my application by using java but i am unable to connect... i was using this code. try { Driver d=(Driver)Class.forName
unable to insert data into database
unable to insert data into database    hello.i have a problem in inserting data into database.i have used two prepared statement.one for retrieving the eid based on ename and the other is inserting data into database based
unable to insert data into database
unable to insert data into database    hello.i have a problem in inserting data into database.i have used two prepared statement.one for retrieving the eid based on ename and the other is inserting data into database based
unable to insert data into database
unable to insert data into database    hello.i have a problem in inserting data into database.i have used two prepared statement.one for retrieving the eid based on ename and the other is inserting data into database based
unable to insert data into database
unable to insert data into database    hello.i have a problem in inserting data into database.i have used two prepared statement.one for retrieving the eid based on ename and the other is inserting data into database based
image in database
image in database  how to set image in database and retrieve it using servlet(java)in msaccess
image store and get it back
image store and get it back  store the image in the oracle using blob... store the image in table but at time of reading it back it never shows me the image and how to convert the image file into binary format.... so that i can store
How To Store Image Into MySQL Using Java
how to store an image into the database using Java and MySQL. This example explains you about all the steps that how to store image into MySQL database. To store an image into database there are four data types tinyblob, blob
image upload and stored in database - JSP-Servlet
image upload and stored in database  How can i upload a image and store that image in a database
image upload and stored in database - JSP-Servlet
image upload and stored in database  How can i upload a image and store that image in a database
Unable to connect servet, jsp to oracle 10g database.. Unable to retrieve data..
Unable to connect servet, jsp to oracle 10g database.. Unable to retrieve data.... If I use it also, unable to connect to backend oracle database. Let me... for the connection to the database is specified in the Web-inf >> config
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
inserting image into database
inserting image into database  how to insert image into database using struts frame work and spring JDBC
Fetching image from database
Fetching image from database  I have uploaded image path and image name in database so, now how can i display that image using JSP or HTML page... in database is:E:\1003\54175\20110407121554 image name i have stored
image retrive into DataBase - JDBC
the image into DataBase. Thanks & Regards, VijayaBabu.M  Hi, Retrieving image from database is easy task. JDBC provides all the necessary API and function to retrieve the image from database. You retrieve image from database
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
unable to get datas from oracle database
unable to get datas from oracle database  Dear Sir, I am again struck in my project.. i want to display data from oracle database but i get... org.apache.jasper.JasperException: Unable to compile class for JSP: An error occurred
Unable to upload a file to mysql database using struts1
Unable to upload a file to mysql database using struts1  Hi, Below are my classes 1.upload.jsp <%@ taglib uri="/tags/struts-html" prefix="html" %> <html:html> <body> <html:form action="upload" enctype
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
upload image to database
upload image to database  i am try to upload image to MySql database using netbeans. when jsp execute it return no error. but also data does inserted in database. i am using blob datatype and preopared statement
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
Insert image in database
Insert image in database  Want a jsp-struts program in which the imageFile is in the form of getter and setter and inserted in the database as a Blob using . and then download the image and show on next jsp pg. No use
Resize image stored in database
Resize image stored in database  hi, Can any one please send code for how to resize image stored in database in blob datatype in jsp, i want to resize it to 140(w)*160(h) 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
Store XML file into Sqlserver Database
Store XML file into Sqlserver Database  Code for storing a typical XML file into SQl server database in 1 or more tables using asp.net using C
store dropdown box values in database server
store dropdown box values in database server  how to store dropdown box values in database server in jsp
to store form vaues in database - JDBC
to store form vaues in database  sir i have created one form with two... the code   Hi friend, Code to insert the data into database :   Navigating in a Database Table Welcome
How to retrieve and display image from database in Java?
. Please check the it at How to store and retrieve image from database in JSP...How to retrieve and display image from database in Java?  Hi, I am writing a web application for reading the data from database and displaying
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
Inserting Image in Database Table
Inserting Image in Database Table   ... This program helps the user to insert an image in the MySQL database table. To insert an image, you need to establish a connection with MySQL database
Jsp Code to store date in database - JSP-Servlet
Jsp Code to store date in database   Hi, Can u give me jsp code to store current date in to database. Thanks Prakash

Ads