in registration page,hw the details wil b stored in db,n retrieved.....

in registration page,hw the details wil b stored in db,n retrieved.....

1)in registration page,when new user register his details,hw the details will b stored in db....(i knw hw to do it bt i ve some doubts in it),so plz give me the code in detail plzzz.....2)n hw do v knw whether that details r inserted in db(do v need to write select query in d same pgm)?

and here is my code tthe above query...i thk thr r some mistakes in ths,plz find out n tel me the mistake i ve done... ' <% try { Class.forName(driver);

con = DriverManager.getConnection(url + db, user, pass); statement stmt=con.createstatement(); string uname=request.getparameter("username"); string pass=request.getparameter("pasword"); int count=stmt.executeUpdate("insert into abc(username,password) values("+uname+","+pass+"); if(count>0) { out.println("successful"); } else { out.println("unsucce..."); } } catch { .... }

also 3)code for retreiving the data frm db(tel me with statement n prepared stmt seperatly plzz...)...

4) actually i ve no data in db,after inserting user details only the data will b inserted in db,so hw to retrive that....

plzzz give the codes for all the abv 4 queries in detail,seperatly plzzz...

View Answers

July 13, 2011 at 11:18 AM

1)form.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.println(e);
        e.printStackTrace();
        }
        %>

If the values will get inserted then you will get the message on the browser 'Data is successfully inserted' as we have specified in the above code.


July 13, 2011 at 11:39 AM

Retrieve data using Statement

<%@page import="java.sql.*"%>
<table border=1>
<%
Class.forName("com.mysql.jdbc.Driver").newInstance();  
 Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/roseindia","root","root");  
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("Select * from student");
if(rs.last()){
    %>
<tr><td><%=rs.getString(1)%></td><td><%=rs.getString(2)%></td><td><%=rs.getString(3)%></td><td><%=rs.getString(4)%></td><td><%=rs.getString(5)%></td><td><%=rs.getString(6)%></td><td><%=rs.getString(7)%></td><td><%=rs.getString(8)%></td><td><%=rs.getString(9)%></td><td><%=rs.getString(10)%></td><td><%=rs.getString(11)%></td><td><%=rs.getString(12)%></td><td><%=rs.getString(13)%></td><td><%=rs.getString(14)%></td></tr>
<%
}
%>
</table>

Retrieve data using PreparedStatement

<%@page import="java.sql.*"%>
<table border=1>
<%
Class.forName("com.mysql.jdbc.Driver").newInstance();  
 Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/roseindia","root","root");  
PreparedStatement pst=con.prepareStatement("Select * from student");
ResultSet rs=pst.executeQuery();
if(rs.last()){
    %>
<tr><td><%=rs.getString(1)%></td><td><%=rs.getString(2)%></td><td><%=rs.getString(3)%></td><td><%=rs.getString(4)%></td><td><%=rs.getString(5)%></td><td><%=rs.getString(6)%></td><td><%=rs.getString(7)%></td><td><%=rs.getString(8)%></td><td><%=rs.getString(9)%></td><td><%=rs.getString(10)%></td><td><%=rs.getString(11)%></td><td><%=rs.getString(12)%></td><td><%=rs.getString(13)%></td><td><%=rs.getString(14)%></td></tr>
<%
}
%>
</table>









Related Tutorials/Questions & Answers:
in registration page,hw the details wil b stored in db,n retrieved.....
in registration page,hw the details wil b stored in db,n retrieved.....  1)in registration page,when new user register his details,hw the details will b stored in db....(i knw hw to do it bt i ve some doubts in it),so plz give me
after entering details in reg page,n enter the submit button,how can v store the data in db, n hw can v retrive the data frm db in jsp
after entering details in reg page,n enter the submit button,how can v store the data in db, n hw can v retrive the data frm db in jsp  i ve creted registration page n login page. after entering details in reg page,n enter
Advertisements
Design a registration.jsp page with input for user registration details
Design a registration.jsp page with input for user registration details  Design a registration.jsp page with input for user registration details like... submitting this details, display the details onto the display.jsp page using
HTML(Registration form) to Jsp to stored into MS ACCESS database
HTML(Registration form) to Jsp to stored into MS ACCESS database  i am sending one html file that contain 18 fields these are stored in ms-access... you for waiting that code. This is My Html page Link
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?   first registration...; please help me for this i tried but when the press the registration button
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?   first registration...; please help me for this i tried but when the press the registration button
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?   first registration...; please help me for this i tried but when the press the registration button
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?   first registration...; please help me for this i tried but when the press the registration button
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?   first registration...; please help me for this i tried but when the press the registration button
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?   first registration...; please help me for this i tried but when the press the registration button
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?   first registration...; please help me for this i tried but when the press the registration button
c programming..what wil be the output of this program
c programming..what wil be the output of this program   #include int main() { int arr[] = {0,1,2,3,4}; int i,*ptr; for (ptr=arr+4; ptr= arr; ptr--) { printf("%d",*ptr
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
stored procedure
stored procedure  what is stored procedure
stored procedures
stored procedures  What are stored procedures
stored procedures
stored procedures  What are stored procedures
advantage of stored programs
advantage of stored programs  Which of the following is an advantage of stored programs? a) Reliability b)Reduction in operation costs c) The computers becoming general purpose D) All of the above E) None of these  
Stored procedures
Stored Procedure in MySQL at Stored Procedures and Functions in MySQL tutorial page...Stored procedures  hello What are stored procedures?   hello, A stored procedure is a set of statements or commands which reside
Develop user registration form
retrieved from the registration form. To stored the data into the database it uses... user registration jsp page.  In this example we will create a simple... User Registration Form in JSP     
user registration
user registration  hi frnds...am working on a project in JSP.i want to create a user registration form with username,password,mail id and check box option for community selection.once the details are registered i want to save
stored procedure
stored procedure  on storing values to database using stored procedure it throws an error lyk ADODB.Command error '800a0bb9' Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another
what is the value of $$b?
what is 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
course registration
course registration  project for course registration system in java programming
registration application
registration application  How to develop a registration application in struts which has seperate file for database connection and data checking and form and action
what?s the value of $$b?
what?s 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
student details
student details  create an application for details of 1st to 5th standard students by using loops and scanner
b+ trees - UML
b+ trees  can i get entire documentation of b+ trees implementation in java
b+trees - UML
b+trees  i need use case diagrams,class diagrams and flowcharts for b+ trees urgently
scjp details
scjp details  SCJP fees details abou scjp? What are the best books for preparing to scjp? How many time scjp exam's are conducted for one year
student details
student details  hi sir/madam i have a doubt in PHP how to insert student details using mysql with php..   Have a look at the following link: PHP Mysql insert
customer details
customer details  write a java code to enter n number of persons details(name,address,phone number) in a array list. Also consider exceptional cases like entering integer in name,character in phone number. use try,catch ,throw
ModuleNotFoundError: No module named 'b'
ModuleNotFoundError: No module named 'b'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'b' How to remove the ModuleNotFoundError: No module named 'b' error
APLIANCE DETAILS
APLIANCE DETAILS  I have created a package named ApplianceDetails that contains the Appliance class. Now I want to create a class named NewAppliance that stores the details of the newly launched appliances.I used the following
B+ trees search
B+ trees search  Can anyone send the code for implementing the B+ trees searching on a oracle database? please your answer will be useful for my project
B+ trees search
B+ trees search  Can anyone send the code for implementing the B+ trees searching on a oracle database? please your answer will be useful for my project
deletion in b plus tree
deletion in b plus tree  please help me out!! i need a code for deletion on b-plus tree in JAVA. its urgent please help
java.lang.IllegalStateException: Writer already retrieved at - Ajax
java.lang.IllegalStateException: Writer already retrieved at   Hi, I am learning the AJAX.i did simple program.getting this error... Exception: java.lang.IllegalStateException: Writer already retrieved
Swing JTable which is retrieved from MySQL
Swing JTable which is retrieved from MySQL  How To Display both image and data into Swing JTable which is retrieved from MySQL database
registration form
registration form  Hii.. I have to design one registration page... = connection .prepareStatement("select user_name from user_details...;%@ page language="java" import="java.util.<em>,saar.etisalat.</em>
Registration Form
Registration Form  Hi Friends I am Working on a small project.I have to create a Registration page using MVC pattern where i have to insert data username,password,date of birth,Mobile number number into database. How to insert
difference b/w == and equals()
difference b/w == and equals()  what is the difference between == operator and equals()   Hi Friend, The == operator checks if the two objects were actually the same object. This operator looks at the actually memory
Registration - Ajax
Registration  i want to create a registration page. in which User... me on this topic. How i can connect this registration page to data base. i am...;hi friend, registration form in jsp function checkEmail(email
REGISTRATION OF MBEAN
REGISTRATION OF MBEAN  my question is... i have installed jboss, and created a managed Bean(MBEAN)and provided interface and everything. but i dont know whether the service registerd in jmx or not. please suggest me
ModuleNotFoundError: No module named 'stored'
ModuleNotFoundError: No module named 'stored'  Hi, My Python... 'stored' How to remove the ModuleNotFoundError: No module named 'stored'... to install padas library. You can install stored python with following command
to creating a registration form
to creating a registration form  how to create a registration form
B+ tree - Java Beginners
B+ tree  Hello everyone, this is my assinment in univ, i spent 2.... In this assignment, you will implement B+-tree data structure on a fixed-length data... field is separated or delimited by a white space. Initially, your B+-tree
b+trees - Swing AWT
b+trees  i urgently need source code of b+trees in java(swings/frames).it is urgent.i also require its example implemented using any string by inserting and deleting it.  Hi Friend, Try the following code: import
Stored Procedure and Trigger
Stored Procedure and Trigger  hello, What is the difference between Stored Procedure and Trigger ?   hii,ADS_TO_REPLACE_1 Triggers once defined are called automatically, there can be no explicit invocation Stored
initializing B+ tree from Jtable - JDBC
initializing B+ tree from Jtable   hi, i have fixed-length data file such student table.i stored this file in Jtable All fields are fixed length: 8... i can Initially, constructed B+ tree based from this Jtable. and make initial
where this file is stored
where this file is stored  thank your sir, but where this file is stored? and how to get the path for further use

Ads