what is the jsp coding to insert a data in database tables
Dear Sir,
I Want to know the coding for insert the data from jsp to oracle database.. my html coding,
<html>
<form method="post" action="http://localhost:8080/examples/jsp/1/insert.jsp">
<table>
<tr><td>DEPARTMENT_NAME</td><td><input type="text" name="DEPARTMENT_NAME"></td></tr>
<tr><td>DEPARTMENT_ID</td><td><input type="text" name="DEPARTMENT_ID"></td></tr>
<tr><td></td><td><input type="submit" value="Submit"></td></tr>
</table>
</form>
</html>
// when i give departmentname and departmentid and click submit i want to save this data in my oracle database.. in oracle i created a table "department" and having this departmentname and departmentid colums, and also let me know how to mention my oracle server in coding..
thank you!!
Ragulan.M
View Answers
August 29, 2012 at 3:37 PM
Here is a jsp code that insert the form values to MySQL 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();
}
%>
August 30, 2012 at 10:13 AM
thank you for the reply!!
how to mention the
"Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/roseindia", "root", "root");"
for oracle.. i am confused here..
November 11, 2012 at 5:48 PM
Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe", "username", "password");"
Related Tutorials/Questions & Answers:
how to insert data into database using jsp & retrivehow 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
Advertisements
how to insert data in database using html+jsphow to
insert data in
database using html+jsp anyone know
what... and
database name. Here machine name id localhost and
database name... = null;
// declare a resultset that uses as a table for output
data from
insert data into databaseinsert data into database hi,thanks for reply
just i am doing student information project,frontend is
jsp-servlet and backend is msaccess2007. i... the
data into the
jsp page that
data stored into the database.Here the error
insert and delete data in databaseinsert 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
To insert maximum number of data in database.To
insert maximum number of
data in
database. how to change string
data type into clob
data type in
jsp
Hi Friend,
Please visit the following link:ADS_TO_REPLACE_1
http://www.roseindia.net/jdbc/
insert-clob
database is connected but not insert the datadatabase is connected but not
insert the data hi,
i am getting connected to database.Retrive the
data also but cannot
insert the
data into
database...=con.prepareStatement("
insert into studentmaster(slno) values('"+batch+"')");
i
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
insert data into databaseinsert data into database type Exception report
message...)Go to the start->Control Panel->Administrative Tools->
data sources.
2... selecting the driver, click finish button.
4)Then give
Data Source Name
To insert attachment file in database in JSP.To
insert attachment file in
database in
JSP. I am doing project in
JSP. How to
insert attachment file in mysql
database? Please suggest some solution. Your inputs is valuable to me.
Hi Friend,
Visit HereADS
To insert attachment file in database in JSP.To
insert attachment file in
database in
JSP. I am doing project in
JSP. How to
insert attachment file in mysql
database? Please suggest some... = connection.prepareStatement("
insert into file(file_
data) values(?)");
fis = new
Insert data in Excel File from Database using JSP developed a application to
insert data in excel file from
database in
JSP. We... will retrieve the
data from
database, create an excel file and
data
insert...
Insert data in Excel File from Database using
JSP
insert data in the database using checkboxinsert data in the
database using checkbox i am fetching
data from the
database using servlet on the
jsp page and there is checkbox corresponding... should i
insert only checked
data into
database on submission.
We
Insert file data into databaseInsert file
data into
database
In this section, you will learn how to
insert the file
data into
database.
Description of code:
Here we have used FileReader.... Now to
insert this
data into the
database, we have
established a
database Question about "Insert text file data into Database"Question about "
Insert text file
data into
Database" Hey
I was reading the tutorial "
Insert text file
data into
Database", (awesome btw), and noticed that both a FileInputStream, a DataInputStream and a BufferedReader
Java to insert picture to database - JSP-ServletJava to
insert picture to database Hi Guys, Please assist me on this. Below is the code I wanted to use to
insert picture into Ms Sql server 2000 but after the insertion, I got this in the
database (back-end
how to insert checkbox value into database using jsphow 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 jsphow 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 XML file data to databaseInsert 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... to read the xml file
data and save the values
of an XML file to a
Database how to insert array data into sql server using jsphow 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 text file data into DatabaseInsert text file
data into
Database
In this section, you will learn how to
insert the text file
data into the
database. For this purpose, we have created... the
data to the ArrayList.
This list is then iterated through the Iterator