how to insert data into databasse by using jdbc

how to insert data into databasse by using jdbc

â?¢ Create a Registration Form with 10 input fields using HTML and get those inputs using JSP and insert those inputs into database using JDBC.

View Answers

September 4, 2012 at 5:58 PM

Here is a jsp code that accepts several fields from the user and add these values to database.

1)register.jsp:

<html>
<form method="post" action="insert.jsp">
<table>
<tr><td>First Name:</td><td><input type="text" name="fname"></td></tr>
<tr><td>Last Name:</td><td><input type="text" name="lname"></td></tr>
<tr><td>Email:</td><td><input type="text" name="email"></td></tr>
<tr><td>Password:</td><td><input type="password" name="pass"></td></tr>
<tr><td>Confirm Password:</td><td><input type="password" name="cpass"></td></tr>
<tr><td>Date Of Birth</td><td><input type="text" name="dob"></td></tr>
<tr><td>Age:</td><td><input type="text" name="age"></td></tr>
<tr><td>Gender</td><td><input type="text" name="gender"></td></tr>
<tr><td>Address:</td><td><input type="text" name="address"></td></tr>
<tr><td>Country</td><td><input type="text" name="country"></td></tr>
<tr><td>State:</td><td><input type="text" name="state"></td></tr>
<tr><td>City</td><td><input type="text" name="city"></td></tr>
<tr><td>Telephone No:</td><td><input type="text" name="tno"></td></tr>
<tr><td>Mobile:</td><td><input type="text" name="mobile"></td></tr>
<tr><td></td><td><input type="submit" value="Submit"></td></tr>
</table>
</form>
</html>

2)insert.jsp:

<%@page import="java.sql.*,java.util.*"%>
<%
String fname=request.getParameter("fname");
String lname=request.getParameter("lname");
String email=request.getParameter("email");
String pass=request.getParameter("pass");
String cpass=request.getParameter("cpass");
String dob=request.getParameter("dob");
int age=Integer.parseInt(request.getParameter("age"));
String gender=request.getParameter("gender");
String address=request.getParameter("address");
String country=request.getParameter("country");
String state=request.getParameter("state");
String city=request.getParameter("city");
int telephone=Integer.parseInt(request.getParameter("tno"));
int mobile=Integer.parseInt(request.getParameter("mobile"));
        try{
         Class.forName("com.mysql.jdbc.Driver");
           Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/roseindia", "root", "root");
           Statement st=con.createStatement();
           int i=st.executeUpdate("insert into student(firstname,lastname,email,pass,confirm_pass,dob,age,gender,address,country,state,city,telephone,mobile) values('"+fname+"','"+lname+"','"+email+"','"+pass+"','"+cpass+"','"+dob+"',"+age+",'"+gender+"','"+address+"','"+country+"','"+state+"','"+city+"',"+telephone+","+mobile+")");
        out.println("Data is successfully inserted!");
        }
        catch(Exception e){
        System.out.print(e);
        e.printStackTrace();
        }
        %>

For more information, visit the following links:

http://www.roseindia.net/jsp/javascriptpagerefresh.shtml

http://www.roseindia.net/jsp/user-registration-form-using-jsp.shtml









Related Tutorials/Questions & Answers:
how to insert data into databasse by using jdbc
how to insert data into databasse by using jdbc  â?¢ Create a Registration Form with 10 input fields using HTML and get those inputs using JSP and insert those inputs into database using JDBC.   Here is a jsp code
how to insert data into databasse by using jdbc
how to insert data into databasse by using jdbc  â?¢ Create a Registration Form with 10 input fields using HTML and get those inputs using JSP and insert those inputs into database using JDBC.   Here is a jsp code
Advertisements
how to insert data into databasse by using jdbc
how to insert data into databasse by using jdbc  â?¢ Create a Registration Form with 10 input fields using HTML and get those inputs using JSP and insert those inputs into database using JDBC.   Here is a jsp code
how to insert data into databasse by using jdbc
how to insert data into databasse by using jdbc  â?¢ Create a Registration Form with 10 input fields using HTML and get those inputs using JSP and insert those inputs into database using JDBC.   Here is a jsp code
how to insert data into database using jsp & retrive
how to insert data into database using jsp & retrive  Hello, I have created 1 html page which contain username, password & submit button. in my oracle10G database already contain table name admin which has name, password
how to insert data in database using html+jsp
how to insert data in database using html+jsp  anyone know what... is student. */ String URL = "jdbc:oracle:thin:@10.2.160.244:1521:prodasdb"; // declare a connection by using Connection interface
how to insert data from database using oops concepts - Development process
how to insert data from database using oops concepts  Hi, How to insert data from database using oops based concepts.please write the code... the following code: import java.sql.*; class Insert{ public static String url
How to insert data from a combobox and textbox values into DB using JSP?
How to insert data from a combobox and textbox values into DB using JSP?  hi, How to insert a comb-box and a text box values in to DB using JSP? @DB:student; @table:stu_info; Combobox values:(class1,class2,class3); textbox1
How to insert data from textfields into database using hibernate?
How to insert data from textfields into database using hibernate?   try{ Session session = HibernateUtil.getSessionFactory().openSession...); System.out.println("Successfully data insert in database"); tx.commit
how to insert array data into sql server using jsp
how to insert array data into sql server using jsp  hello, i have problem to insert array data into my sql server from jsp form. beloW is my code... from form, but not insert into my sql database. try { //String
insert data in the database using checkbox
insert data in the database using checkbox  i am fetching data from... each row but the problem is that i am not fetching data in any textboxes so how should i insert only checked data into database on submission.   We
please let me get code how to insert a data to mysql using setter and getter method by using java
please let me get code how to insert a data to mysql using setter and getter method by using java  please let me get code how to insert a data... to insert data
please let me get code how to insert a data to mysql using setter and getter method by using java
please let me get code how to insert a data to mysql using setter and getter method by using java  please let me get code how to insert a data... to insert data
How to insert clob data??
How to insert clob data??  Can any one tell me in details how to populate clob column in a table using sql??I tried simple sql statements but found... of data and need pl/sql to avail that feature.Can any one tell me how to create
JDBC Video Tutorial- How to insert data into MySQL database table?
Tutorial: How to insert data into MySQL Table? Here is the code of the full Java... to insert into database: Connect to MySQL Database using JDBC Create... the data into MySQL database using the JDBC driver.ADS_TO_REPLACE_5 Download
How to insert multiple drop down list data in single column in sql database using servlet
How to insert multiple drop down list data in single column in sql database using servlet  i want to insert date of birth of user by using separate drop down list box for year,month and day into dateofbirth column in sql server
How to read every cell of an excel sheet using Apache POI and insert those data into a DB?
How to read every cell of an excel sheet using Apache POI and insert those data into a DB?   i have an excel sheet, whose data in each cell has to be read and those data has to be inserted in the DB. This has to happen for all
how to read data from excel file through browse and insert into oracle database using jsp or oracle???
how to read data from excel file through browse and insert into oracle database using jsp or oracle???  sir.. i have number of excel sheets which... a browse button which can upload a excelfile and after uploading the data should
JDBC batch insert using Java bean class
In this tutorial, you will learn about JDBC batch insert using java bean / model class
How to insert data into MySQL Table?
How to insert data into MySQL Table?  Hi, How to insert the data...   Hi, The insert into query is used to insert the data into MySQL... ) Then we can use the following query to insert the data: insert into email(first_name
Insert excel file data into database Using Java Programming
Insert excel file data into database in Java Program In this PHP tutorial section, you will learn how to insert excel file data into the database. We have... excel file data into Database Using java programming: import java.io.
JDBC: Insert Records Example
JDBC: Insert Records Example In this section, you will learn how to insert records to the table using JDBC API. Insert Records : After creating table you can insert records. Inserting records means adding values to your table which
insert data into mysql databse using swing
insert data into mysql databse using swing   Blockquote hi, here is my code, i want code for store data into mysql database when click on submit button from access data from this form, please provide code, import java.awt.
JDBC: Insert Record using Prepared Statements
JDBC: Insert Record using Prepared Statements In this section, you will learn how to insert row using Prepared Statements. Insert Record  ... are inserting student record using PreparedStatement. package jdbc
i need program to insert data in database using javascript
i need program to insert data in database using javascript  please help me
Insert data in mysql database through jsp using prepared statement
; This is detailed jsp code that how to insert data into database by using prepared statement... Insert data in mysql database through jsp using prepared statement...*" %>  <HTML> <HEAD> <TITLE>insert data using
jdbc insert
jdbc insert  Hi , i want to insert a declared integer variable into a mysql table through jdbc. how to insert that. help me with query... thanks... a table there. After creating a table in database, it insert a rows in the database
how to insert data from netbeans into databse
how to insert data from netbeans into databse  how to insert data from netbeans into databse   Please visit the following link: http://www.roseindia.net/webservices/web-services-database.shtml
using ajax i want to insert data into oracle database
using ajax i want to insert data into oracle database  i would like to insert/update/select/delete from jsp to oracle database using ajax? please send a code for this iam using oracl database thank you
how to insert, retrieve data from,to db(code)....
how to insert, retrieve data from,to db(code)....  Hi..... i ve... that data will b stored in db(m using sybase). 2.also hw to retrieve the data from db. cn u plz tel me the code in detail.n i thk it shud b written in jdbc
Hibernate Insert
This tutorial will help you to learn how to insert data into table by using hibernate
how to insert date&time coloumn value in mssql - JDBC
how to insert date&time coloumn value in mssql  how to insert...; Hi friend, Code insert date and time in Database : <% int val=0; Connection con=null; PreparedStatement pstatement = null; String url = "jdbc
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
how to make a radiobutton selected when retrieving data from database using struts framework and spring jdbc
how to make a radiobutton selected when retrieving data from database using struts framework and spring jdbc  how to make a radio button selected when retrieving data from database using struts framework and spring jdbc
how to insert, retrieve data from,to db(code)....
how to insert, retrieve data from,to db(code)....  Hi, i have created... register his details,(for ex,username,password,dob,gender) 1.how that data will b stored in db(m using sybase). 2.also hw to retrieve the data from db. cn u
how to insert the physical path of an image in database - JDBC
how to insert the physical path of an image in database  hello I m working in a project where we have to capture an image using web cam. when... , the image column is of varchar datatype.. plz can you tell me how to insert image's
Retrive the data from the table in data base using jdbc
Retrive the data from the table in data base using jdbc  Retrive the data from the table in data base using jdbc   JDBC Tutorials
Problem insert data into database using servlet n javabean - Java Beginners
Problem insert data into database using servlet n javabean  I created...("jdbc:odbc:Futsal1", " ", " "); return true; } public ResultSet executeSQL... = conn.createStatement(); rs = stmt.executeUpdate("INSERT INTO login(name,userid
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
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="font&colors.css" rel="stylesheet" type="text/css"> <p></p>
insert data using drop down box in java into database postgresql
insert data using drop down box in java into database postgresql  can... data into database using an drop down box .....as i m using eclipse as jdbc and postgresql as data base syntax which i m using is like:- java class
insert data using drop down box in java into database postgresql
insert data using drop down box in java into database postgresql  can... data into database using an drop down box .....as i m using eclipse as jdbc and postgresql as data base syntax which i m using is like:- java class
insert data using drop down box in java into database postgresql
insert data using drop down box in java into database postgresql  can... data into database using an drop down box .....as i m using eclipse as jdbc and postgresql as data base syntax which i m using is like:- java class
insert data using drop down box in java into database postgresql
insert data using drop down box in java into database postgresql  can... data into database using an drop down box .....as i m using eclipse as jdbc and postgresql as data base syntax which i m using is like:- java class
JDBC Insert Statement Example
.style1 { text-align: center; } JDBC Insert Statement Example JDBC Insert statement allow you to insert record into the table of the database. This tutorial shows you that how to load database driver, get connection t
how to insert and retrieve an image from mysql using java - Java Beginners
how to insert and retrieve an image from mysql using java  how to insert and retrieve an image from mysql using java?  Hi friend, Code to insert image using java : import java.sql.*; import java.io.*; class
How to Retrieve Excel data into mysql using type 2 JDBC-ODBC driver
How to Retrieve Excel data into mysql using type 2 JDBC-ODBC driver  Can any please help it is very urgent. I tried to read excel sheet using ODBC... using ODBC.plz help me guys..........   Follow these steps: Open Data
Insert XML file data to database
Insert XML file data to database In this tutorial, you will learn how to insert the xml file data to database using dom parser. You all are aware of XML file, it is a tag based language. You can easily transfer and store its data
insert and delete data in database
insert and delete data in database  insert and delete data in database from servlets through JDBC   Hi Friend, Please visit the following links:ADS_TO_REPLACE_1 Insert Data Delete Data ThanksADS_TO_REPLACE_2
insert data
insert data  i've got a problem to insert my data to database.i can... =DriverManager.getConnection("jdbc:mysql://localhost:3306/test","...("insert into images values(?,?,?,?,?)"); st.setString(2

Ads