sir i want to create a web application when we use the jsp inserting the value in the jsp after that i want these value inserted the database mySQl with the help of servlet. Inserting form data
February 27, 2008 at 7:27 PM
Inserting form data into database using JSP and Servlet
Given code will illustrate you, how one can get data into database using JSP and Servlet
Example Code...
insertData.jsp
<html>
<head>
<title>Insert value in database</title>
</head>
<body>
<table border="1" width="50%" cellspacing="0" cellpadding="0">
<tr>
<td width="100%">
<h1><center>Insert value in Database</center></h1>
<form method="POST" action="InsertAction.jsp">
<table border="1" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="50%" valign="right"><b>Name:</b></td>
<td width="50%"><input type="text" name="username" size="30"></td>
</tr>
<tr>
<td width="50%" valign="right"><b>Job-Position:</b></td>
<td width="50%"><input type="text" name="jobposition" size="30"></td>
</tr>
<tr>
<td width="50%" valign="right"> </td>
<td width="50%" valign="right"> </td>
</tr>
</table>
<p><input type="submit" value="Submit" name="B1">
<input type="reset" value="Reset" name="B2"></p>
</form>
</td>
</tr>
</table>
</body>
</html>
- - - - - - -
InsertAction.jsp
<%@ page language="java" import="java.sql.*" %>
<%
Connection con = null;
String url = "jdbc:
mysql://localhost:3306/";;
String db = "register";
String driver = "com.mysql.jdbc.Driver";
try{
Class.forName(driver);
con = DriverManager.getConnection(url+db,"root","root");
try{
Statement st = con.createStatement();
String username=request.getParameter("username");
String jobposition=request.getParameter("jobposition");
int val = st.executeUpdate("insert user_details values('"+username+"','"+jobposition+"')");
con.close();
out.println("success");
}
catch (SQLException s){
System.out.println("SQL statement is not executed!");
}
}
catch (Exception e){
e.printStackTrace();
}
%>
This will help you to create a small application that will insert the HTML form data into database using JSP and Servlet.
Related Tutorials/Questions & Answers:
inserting value - JSP-Servletinserting value sir i want to create a web application when we use the jsp
inserting the
value in the jsp after that i want these
value inserted the database mySQl with the help of servlet.
Inserting form data
Inserting a value to an Enum field in TableInserting a
value to an Enum field in Table I'm writing a code that creates a user account and sends the result to the user table in a mysql database.
For example, in the user table I have:
username varchar(15) PRIMARY KEY
Advertisements
php inserting date into mysqlphp
inserting date into mysql php
inserting date into mysql
Here is a php code that inserts date into mysql database. In the given code... = "INSERT INTO data(dp_name, dp_date)
VALUE ('DATE: Auto CURDATE()', CURDATE
inserting data into datafieldsinserting data into datafields I was raised with a query....
there is a button, on click on it....... few fields regenerates and
the details entered there should be inserted into Database
Number of times we click that button
Inserting Data into mysql - SQLInserting Data into mysql My sincere apologize for this post. I noticed there is no category for php. However am hoping my question will fit... (using php)and
inserting the details in a mysql database. Lets take for instance
inserting picture in ms accessinserting picture in ms access hi i am sanatan, how to insert picture in ms access by jsp.
<%@page import="java.sql.*,java.io.*"%>...());
pre.executeUpdate();
out.println("
Inserting Successfully
duplicate records insertingduplicate records inserting in the application i have provided the text filed on entering and submit the record is getting inserted.
my question is i want to avoid duplicate values getting inserted.
ex. i am
inserting name
Problem in inserting clob data in jspProblem in
inserting clob data in jsp how to insert any rich text editor data (which have more than 32766 characters) in a clob type column of oracle database with jsp
Data is not inserting correctly in mysql database.Data is not
inserting correctly in mysql database. Hello Sir,
below is my code to insert data into database by list iteration through for loop but it is not getting inserted ..it is taking only one
value Inserting Image(s) - JSP-ServletInserting Image(s) Hello Guys, Thank you so much for your support so far. I appreciate everything you guys have done for me. Please what I wanted was java servlet or jsp codes that I can use to insert and retrieve image from MS
Inserting id in place of name to databaseInserting id in place of name to database Hello,
I have a database department where I have "id" and "name". I am fetching this data to a jsp form in dropdown list displaying "name" there and Now I wanted to insert data from
hibernate firstExample not inserting data - Hibernatehibernate firstExample not
inserting data hello all ,
i followed... problem is data is not
inserting into DB even though the program is executed...("
inserting records in Contact table");
Contact contactBO = new Contact
Inserting content(DOM Insertion)
Inserting content(DOM Insertion)
Inserting content(DOM Insertion)
Inserting Dom contents to html ,can be categories in the following 4
categories
Inserting Comma in a decimal number - Java BeginnersInserting Comma in a decimal number Hi, I want to insert comma... { static public void customFormat(String pattern, double
value ){ DecimalFormat myFormatter = new DecimalFormat(pattern); String str = myFormatter.format(
value inserting an path of an image in database - JDBCinserting an path of an image in database hello
kindly help related to the following issue...
I m working in a project where we have to capture an image using web cam....
and when the image is saved in a project at the same
Inserting Image(s) - JSP-ServletInserting Image(s) Hello, I need sample code using java servlet and html form and explanation on how to insert and retrieve image from mysql. Hi friend,This is insert image code.import java.sql.*;import java.io.
urgent help for inserting database in a project urgent help for
inserting database in a project I need some urgent help
i have made java application for conducting a quiz which displays 25 mcq's and then the result at the end.I need to add simple database connectivity
urgent help for inserting database in a project urgent help for
inserting database in a project I need some urgent help
i have made java application for conducting a quiz which displays 25 mcq's and then the result at the end.I need to add simple database connectivity
Inserting Image into table
Inserting Image into table
In this section , we will insert a image into a table. For
inserting image,
table's field (in which image...))
For
inserting whole image, we have to create an 'InputStream'
Inserting data in Excel File - Java BeginnersInserting data in Excel File Dear Sir,
How can we fill the excel with fetched data from the database like Oracle, DB2? Is it possible to create an excel with filled data? Kindly give me the solutions to questions
help me in inserting data into db using hibernatehelp me in
inserting data into db using hibernate How to insert data into dependent tables through hybernate
Hi Friend,
Please visit the following link:
http://www.roseindia.net/hibernate/insert-data-database.shtml
inserting same data to different tables in oracleinserting same data to different tables in oracle Hi there ...! i have to insert un,pwd, to three oracle tables, like admin, user, stud, but i want pickup these table names from a drop down list in html...is there any chance can
inserting same data to different tables in oracleinserting same data to different tables in oracle Hi there ...! i have to insert un,pwd, to three oracle tables, like admin, user, stud, but i want pickup these table names from a drop down list in html...is there any chance can
inserting same data to different tables in oracleinserting same data to different tables in oracle Hi there ...! i have to insert un,pwd, to three oracle tables, like admin, user, stud, but i want pickup these table names from a drop down list in html...is there any chance can
inserting same data to different tables in oracleinserting same data to different tables in oracle Hi there ...! i have to insert un,pwd, to three oracle tables, like admin, user, stud, but i want pickup these table names from a drop down list in html...is there any chance can
inserting same data to different tables in oracleinserting same data to different tables in oracle Hi there ...! i have to insert un,pwd, to three oracle tables, like admin, user, stud, but i want pickup these table names from a drop down list in html...is there any chance can
inserting same data to different tables in oracleinserting same data to different tables in oracle Hi there ...! i have to insert un,pwd, to three oracle tables, like admin, user, stud, but i want pickup these table names from a drop down list in html...is there any chance can
inserting all the values in a html table columninserting all the values in a html table column strong text
hai everyone,
i'm a fresher to servlet i need to know that, how can i insert all the values in a html table column into a database.
Thanks in advance
problem on jsp, inserting data into table(mysql).problem on jsp,
inserting data into table(mysql). hello friends, I have a problem in jsp.I want to insert data, which is given by user through a html page into a table.And the table name also is given by the user.My database
Inserting data on a database in servlet - JSP-ServletInserting data on a database in servlet Hi
I am following the tutorial in this site on servlet and JDBC.
I did all the proccedure for connecting to a databse by a servlet.I used the example in "
Inserting Data In Database table
Exception while inserting image in oracle using javaException while
inserting image in oracle using java import java.sql.*;
import java.io.*;
class Oracle2
{
public static void main(String args[])throws Exception
{
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver
Lock while inserting/updating database in multithreaded.Lock while
inserting/updating database in multithreaded. Hi,
I am having a multithreaded process which replicates the data from many table to one...
inserting/updating to database. I dont know what is the issue but it was never
error while inserting millions of records - EJBerror while
inserting millions of records Hello, I am using ejb cmp and
inserting 1 millions of records but it won't work because trancation time out occurs same problem is occur when i am using hibernate but when i am using
Inserting Text Trapezoid Using Java
Inserting Text Trapezoid Using Java
In this example we are going to create a trapezoid... are creating an object of RichTextRun constructor. In this we
are passing text
value the value of $$b the
value of $$b If the variable $a is equal to 5 and variable $b is equal to character a, what?s the
value of $$b
PASS valuePASS value javascript to pass
value to other html file
Min Value Min
Value How to access min
value of column from database table?
Hi Samar,
You can access minimum
value of column from database...(selectQuery);
System.out.println("Min
Value : " +query.list().get(0
sentinel valuesentinel value how to count the number of red cars that assume 10 cars using sentinel
value sentinel valuesentinel value how to count the number of red cars. Assume there are 10 cars.
how to count the number of red cars that assume 10 cars using sentinel
value Hibernate hello worldIn this section, you will learn about basic tutorial of
inserting value in the database table and printing "hello world" on the console after successful insertion