Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/purvgwtw/public_html/tutorials/common.php on line 7
Insert data into Database using JSP
Sponsered Links
Sponsered Links

Insert data into Database using JSP

This section demonstrates you how to insert the data into the Mysql database. For this purpose, you need to create a table in the database. So try the following query to create a table.

CREATE TABLE `data` (                                    
          `id` bigint(30) NOT NULL auto_increment,               
          `name` varchar(255) default NULL,                      
          `address` varchar(255) default NULL,                                                    
          PRIMARY KEY  (`id`)                                    

<%@page import="java.sql.*"%>
try {
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
Statement st = conn.createStatement();
for(int i=0;i<text1.length;i++){
String name="Astha";
String address="Delhi";
st.executeUpdate("insert into data(name,address) values('"+name+"','"+address+"')");
out.println("Record is inserted successfully");
catch(Exception e){

Sponsered Links
Latest Updates
All Content of this site is for learning only. We do not warrant the correctness of its content. The risk from using it lies entirely with the user. While using this site, you agree to have read and accepted our terms of use and privacy policy.
Copyright © 2014 PURVACOMPUTERS.COM All Right Reserved