insert name city image in database using mysql and jsp

Ads
 

insert name city image in database using mysql and jsp

how to insert name ,city and image in database in mysql and jsp

View Answers

June 25, 2012 at 4:30 PM

Here is an example in jsp that insert name, city and image to database.

<%@ page import="java.sql.*"%>
<%@ page import="java.io.*"%>
<%
FileInputStream fis;
String url="jdbc:mysql://localhost:3306/test";
   try{
     Class.forName("com.mysql.jdbc.Driver").newInstance();
     Connection con=DriverManager.getConnection(url,"root","root");
     File image=new File("c:/image1.jpg");
     PreparedStatement psmt=con.prepareStatement("insert into data(name,city,image)"+"values(?,?,?)");
     psmt.setString(1,"John");
     psmt.setString(2,"Austin");
     fis=new FileInputStream(image);
     psmt.setBinaryStream(3, (InputStream)fis, (int)(image.length()));
     int s = psmt.executeUpdate();
     if(s>0) {
     %>
     <b><font color="Blue">
     <% out.println("Inserted successfully !"); %>
     </font></b>
     <% }
     else {
     out.println("Error!");
     }
     con.close();
     psmt.close();
     }
     catch(Exception ex){
     out.println("Error in connection : "+ex);
     }
%>

Ads









Related Tutorials/Questions & Answers:
insert name city and upload image in database using mysql and jsp
insert name city and upload image in database using mysql and jsp   insert name city and upload image in database using mysql and jsp
insert name city image in database using mysql and jsp
insert name city image in database using mysql and jsp  how to insert name ,city and image in database in mysql and jsp   Here is an example in jsp that insert name, city and image to database. <%@ page import
Advertisements
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
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
Image upload in mysql database using jsp servlet
Image upload in mysql database using jsp servlet  Hello, I need code to insert image in mysql database, I have seen the code which is already in your portal but it is not inserting image into database it save in the folder
retrive the employee details with image from mysql database using jsp servlet
retrive the employee details with image from mysql database using jsp servlet  im doing the web project to retrive the employee profile which i stored in the database using jsp servlet then want to show the result in the next jsp
How to insert and retreive an image in mysql database using spring mvc framework???
How to insert and retreive an image in mysql database using spring mvc framework???  I ve solved this problem based on the Product Search Application. Those who need this concept and code segment kindly copy it. Thanks and All
fetch and insert multiple rows into mysql database using jsp servlet
fetch and insert multiple rows into mysql database using jsp servlet  ... jsp form and want inserting it into my mysql database table. but i am having a problem to insert multiple rows into database using a single insert query
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 upload an image from a jsp page to a mysql database table using jsp
how to upload an image from a jsp page to a mysql database table using jsp  how to upload an image from a jsp page to a mysql database table using jspstrong text
Insert data in mysql database through jsp using Prepared Statement ---- Please Resolve it
Insert data in mysql database through jsp using Prepared Statement ---- Please...,"root","root"); String queryString = "INSERT INTO stu_info(Name,City,Phone..._increment, Name varchar(20), City varchar(20), Phone varchar(15), primary key
Insert data in mysql database through jsp using Prepared Statement ---- Please Resolve it
Insert data in mysql database through jsp using Prepared Statement ---- Please...(connectionURL,"root","root"); String queryString = "INSERT INTO stu_info(Name,City..._increment, Name varchar(20), City varchar(20), Phone varchar(15
How to insert image in sql database from user using servlet
How to insert image in sql database from user using servlet  pls tell me accept image from user and insert image in sql server 2005 database using servlet and jsp
how to insert data in database using html+jsp
how to insert data in database using html+jsp  anyone know what... and database name. Here machine name id localhost and database name...; Here we have used MySQL database: 1)form.html: <html> <form
How to retrieve image from mysql database in JSP?
How to retrieve image from mysql database in JSP?  Hi, I need JSP same codes for learning to get image which is stored in MySQL Database. How to retrieve image from mysql database in JSP? Thanks   Hi, You can write
Insert image from user using and save in database
Insert image from user using and save in database  when i am trying to upload a image from user and trying to save into oracle9i database.... Apache Tomcat/6.0.29  We have used MySQl database. 1)page.jsp: <
how to insert data into database using jsp & retrive
how to insert data into database using jsp & retrive  Hello, I have... oracle10G database already contain table name admin which has name, password. name is amit and password is ddave. so hw could i check whether the username &
How I Upload File and Store that file name in Database using JSP
How I Upload File and Store that file name in Database using JSP  Hi... and some other form data in MySQL database. Ex. There is one employee detail form like Emp name, Emp id, city, address and one employee profile image(upload
how to fetch image from mysql using jsp
how to fetch image from mysql using jsp  how to fetch image from mysql using jsp
insert and retrive image from sql server database in jsp
insert and retrive image from sql server database in jsp  what is the code to insert and retrive an image from sql server database in jsp
how to insert checkbox value into database using jsp
how to insert checkbox value into database using jsp  How to insert check box value to the oracle database using jsp? I want to create hotel's...;   Here is a simple jsp code that insert the selected checkbox values
how to insert checkbox value into database using jsp
how to insert checkbox value into database using jsp  how to insert check box value to the database using jsp my code is <link href...;p/> <FORM action="roles.jsp" method="post" name="entry"> <
Save profile and image to mysql database, and view the image in another jsp page
Save profile and image to mysql database, and view the image in another jsp page  Pls. need help in saving the profile info with the image in mysql database.. some basic code pls in jsp... thanks in advance
how to insert checkbox value into database using jsp
how to insert checkbox value into database using jsp  How to insert check box value to the oracle database using jsp? I want to create hotel's package. where the admin will select the activities to insert in the PACKAGE table. I
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
How to Insert image and data both together in database in JSP/Servlet ?
How to Insert image and data both together in database in JSP/Servlet ? ... = connection.prepareStatement("insert into data(Name,City,Img) values('"+nn+"','"+cc...; City:<input type=text name="city"> <tr> <center> <td
<img src=""> using retrieve image from database using jsp
using retrieve image from database using jsp  how to <img src="" > tag using retrieve image from database and display in jsp
How to insert image in MySQL database using sql query?
Insert image in MySQL database using sql query  ... to insert image in MySQL database using sql query?": So, lets start... in MySQL database and then used the query to insert the data
retrive image from database using jsp without stream
retrive image from database using jsp without stream  How to retrive image from database using jsp without stream like (inputStream
login page using jsp servlrt with mysql database?
login page using jsp servlrt with mysql database?  Description: example:total users are 3.each use have username and password save in mysql database table login. After successfully login user1 see only index page,if user2 login
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

Ads