Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Interview-Questions how to insert data into databasse by using jdbc

Have Programming Question? Ask it here!
 
 
 


saranya.m
how to insert data into databasse by using jdbc
1 Answer(s)      2 years ago
Posted in : Java Interview Questions


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


Advertisement
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:
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.
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
Advertisements
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: Insert Data Delete Data Thanks
Insert text file data into Database
Insert 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
Insert a row in 'Mysql' table using JSP Code
Insert a row in 'Mysql' table using JSP Code In this section, we will discuss about how to insert data in Mysql database using JSP code. Query...; Mysql database Table. Code to insert row in Mysql table : databaseinsertion.jsp
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: http://www.roseindia.net/jdbc/insert-clob-example.shtml Thanks
Insert Mysql Blob data
Insert Mysql Blob data   In this section, we will discuss about how to insert a blob data into a database table. A Blob stores a binary large... which points to the Blob data, data is not directly stored in the row
Inserting Mysql CLOB data using Servlet
Inserting Mysql CLOB data using Servlet In this Section, we will insert "clob" data using "servlet". A CLOB is a Character Large Object... portion of the CLOB data. 2.Equallity of 2 CLOBs can  be check by using equals
insert and retrive data and time - SQL
insert and retrive data and time  hello everybody . Is there any method in java so that we can insert current system time and then it can... default NULL, PRIMARY KEY (`id`) ) To insert current date and time
how to create a databaseconnectvity using SQLSERVER2005 in J2ME - JDBC
how to create a databaseconnectvity using SQLSERVER2005 in J2ME  hi , iam new to J2ME,i want to know, How to create a data base connectivity using sqlserver through J2ME. Currently we are working on a Mobile Applicayion
How to insert a single page PDF file into another multipage PDF file using iText? - Java Beginners
How to insert a single page PDF file into another multipage PDF file using iText?  Hi ALL: I have two PDF files. PDF-A.pdf is a multipage PDF file. PDF-B.pdf is a single page PDF file. I want to insert PDF-B into PDF-A only
How to display data in form using aryylist in struts - Java Beginners
How to display data in form using aryylist in struts  Hi, I want to display data using arraylist in struts pls help me Its urgent
insert excel value in to oracle data base
insert excel value in to oracle data base  Hi All I am using... the data from the excel file using JDBC. For this you need to create dsn... this Excel file then how excel data will mapp to oracle database table. My project
Insert record into a table using DBCP
;);     bds.setUrl("jdbc:mysql://localhost:3306/mydb"
insert
insert  insert data in database from servlet through JDBC   Ho Friend, Please visit the following: Insert data into database Thanks
How to retrieve data by using combo box value in jsp? - JSP-Servlet
How to retrieve data by using combo box value in jsp?  For example, In Employee.jsp form, When i click employee id value in combo box ,the related employee name will be displayed in text field
How to retrieve data by using combo box value in jsp? - JSP-Servlet
How to retrieve data by using combo box value in jsp?  I am using a single jsp form.. i did not get from another form.. i do not use 2 jsp form.. all.... Note: I am using only this jsp form.. i do not use
Insert Blob(Image) in Mysql table using JSP
Insert Blob(Image) in Mysql table using JSP In this Section, we will insert blob data(image) in Mysql database table using JSP code. A Blob stores a binary... pointer which points to the Blob data, data is not directly stored in the row
How to retreive data by using combo box value - JSP-Servlet
How to retreive data by using combo box value  Hello friend , i am using only one form. U are using html form and jsp form. So get the values from html. So u r using if(request.getParameter("cid")!=null
How to retrieve data using combo box value in jsp? - JSP-Servlet
How to retrieve data using combo box value in jsp?  Hi freind, I already post this question. I need urgent help from u. pl response me.... All actions in the same page.......  Hi Friend, Please visit
PDO Insert
PDO-Insert-Code To get data from the database, we need to put some data into it. In PDO we use same conventional coding of inserting data, but to execute...;insert into student(id,name,roll)values ($id,$name,$roll)'; $count=$db->
How to retreive data by using combo box value - JSP-Servlet
How to retreive data by using combo box value  I am using a single jsp form.. i did not get from another form.. i do not use 2 jsp form.. all.... Note: I am using only this jsp form.. i do not use to get values from
how to retrieve data from database using combobox value without using request.getParameter in jsp - JSP-Servlet
how to retrieve data from database using combobox value without using request.getParameter in jsp  Answer pl
how to store data in table using swings - Java Beginners
how to store data in table using swings  Hi, I am doing a project in which i need to store some data in the table using swings.......Iam using... will be same to store data into tables) of my application....can any body give an example
Deleting Blob Data from Database table using servlet
Deleting Blob Data from Database table using servlet In this section, we will discuss about how to insert a blob data into a database table. A Blob... contains a logical pointer which points to the Blob data, data is not directly
Multi value data - JDBC
Multi value data  Hello, please help,how do i use Multi-value data with mysql database. thank you  Hi friend, Plz explain your problem in details what you want and visit to : http://www.roseindia.net/jdbc/jdbc
Data base - JDBC
Data base  I want to do this Inserting a record with Object type column using PreparedStatement but wht should b the column datatype this is te...( "jdbc:oracle:thin:@mysys:1521:sandb",p); PreparedStatement ps
Data Source - JDBC
Data Source  Hi, plz let me know why we r using Data Source . and how we will use in our java Code??? Thanks
how to insert the selected item of combobox in mysql - XML
how to insert the selected item of combobox in mysql  hi, i have to insert the selected item from combobox into MYSQL database.pls provide... of combobox in mxml.how to insert selecteditem in database. pls suggest me i have
Insert into table using Java Swing
INSERTION IN TABLE USING SWING In this section, We will insert rows into "Mysql" database using "Swing". What is Swing? Swing...("com.mysql.jdbc.Driver"); con=DriverManager.getConnection ("jdbc
How to export data from database to excel sheet by using java swing in standalone project - Java Beginners
How to export data from database to excel sheet by using java swing... from u to solve my problem. my problem is i don know how to export data from database to excel sheet by using java swing in standalone project.I get solution from
Insert option does not work in my jstl... - JDBC
Insert option does not work in my jstl...  I have problem with this jstl code... This will extract and displays details from xml... But i cant able to store that values in a database... Pls solve my problem...... Joe
Navigate Data using Java Swing
Navigate Data using Java Swing In this java tutorial section, you will learn how to navigate the Database data using Java Swing. For this, we have created...("jdbc:odbc:access");       Statement 
PHP Insert Value
Insertion of data into table: We will study in this tutorial how to insert data into a table using MySQL console and phpMyAdmin. After creating table we need...'); Now to insert values into table:   ii)    Using WAMP
How retreive data from database without using post method in jsp - JSP-Servlet
How retreive data from database without using post method in jsp  Tell me how?  Hi Friend, If you don't want to use post method then use Ajax.We have provided you a link.In that example, with the use of Ajax, we take
parameter meta data - JDBC
in jdbc as well as the diffrent methods used in parameter meta data  ... on the designated column to succeed. For more information on JDBC visit to : http://www.roseindia.net/jdbc/ Thanks
Multi-value data - JDBC
Multi-value data  hey! actually am supposed to create this database that allows multi-value data.its supposedly going to become a very large database.only i dont know just how to begin creating it.what i need is mysql syntax
how i conditional access the data from database using combo box. - JSP-Servlet
how i conditional access the data from database using combo box.   i... appears named Subject values Arts, Commerce, Science. how i conditional access the data from database when i select class 11 0r 12. Here is JSP file
How to retrieve data from database by using combo box value in jsp? - JSP-Servlet
How to retrieve data from database by using combo box value in jsp?  Hello friend i want use only one jsp page.. but u give 2 pages... I want to work in one page... Pl response.. I do not need getParameter... Pl respose me
Read data from Excel and insert in to DB and export data from DB to Excel
Read data from Excel and insert in to DB and export data from DB to Excel  Read data from Excel and insert in to DB and export data from DB to Excel Hi, I need to read the data from excel and I need to insert the same in to DB
Inserting a row using PreparedStatement
INSERING A ROW USING PREPAREDSTATEMENT If you want to execute a statement many.... The advantage of using "PreparedStatement " is that you can use the same...;    String url = "jdbc:mysql://192.168.10.13
how to prepopulate data in struts2 - Struts
how to prepopulate data in struts2  I wanted to show the data from database using Struts 2
read text file and store the data in mysql - JDBC
read text file and store the data in mysql  when we store the data in mysql table from text file its store the data from new line to new column. how to store the data in different column from a single line of text file. 
exporting data to excel sheet - JDBC
exporting data to excel sheet  Sir i have already send request about...; Form(){ String data[][] = {{"",""}}; String col[] = {"Name","Address"}; final DefaultTableModel model = new DefaultTableModel(data,col
how to store image file and videofile in ms access database using java? - JDBC
how to store image file and videofile in ms access database using java?  how to store image file and video file in ms access database using java
can i insert values into two tables by a query - JDBC
can i insert values into two tables by a query  hi all, can i insert values into two tables by a query Thanks Bala k
how to connect mysql with JDBC - JDBC
in the database MYsql, i have to connect them now using JDBC, can u please suggest me...(); } } Thanks Rajanikant  Hi friend, To mysql connect using JDBC... database using Jdbc: import java.sql.*; public class GetAllRows{ public
Extract File data into JTable
Extract File data into JTable In this section, you will learn how to read the data from the text file and insert it into JTable. For this, we have created... implementations for most of the methods in the TableModel interface. Using
Deleting Mysql Clob data using servlet
Deleting  Mysql Clob data using servlet In this Section, we will discuss about how to delete a Clob data from a database table using servlet. A CLOB is a Character Large Object in a Database table. CLOB data is used to store
Queue implementation using array.
Description: In this tutorial you will see how to implement queue using array and queue insert & delete operations. Code: #include <stdio.h> #define MAX 5 #include <stdlib.h> void insert(int queue[], int *rear
 

 

 

DMCA.com