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



Home Answers Viewqa Java-Beginners can u plz try this program
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


niharika
can u plz try this program
6 Answer(s)      6 years and 2 months ago
Posted in : Java Beginners



Advertisement
View Answers

November 18, 2008 at 12:28 AM


Hi friend,

form code
------------------
<html>



<head>



<title>User information</title>

</head>



<body>

<br><br><br>

<div align="center">

<center>

<table border="1" cellpadding="0" cellspacing="0" width="400px" height="69">

<tr>

<td width="859" height="69">

<form method="POST" action="userInfomAction.jsp">



<h1 align="center">&nbsp;User Information Form</h1>

<div align="left">

<table border="1" cellpadding="0" cellspacing="0" width="400px">



<tr>

<td width="50%"><b>Name:</b></td>

<td width="50%"><input type="text" name="name" size="20"></td>

</tr>

<tr>

<td width="50%"><b>Last Name:</b></td>

<td width="50%"><input type="text" name="lsname" size="20">

</td>

</tr>

<tr>

<td width="50%"><b>Age :</b></td>

<td width="50%"><input type="text" name="age" size="10">

</td>

</tr>



</table>

</div>

<p align="center"><input type="submit" value="Submit" name="submit">

<input type="reset" value="Reset" name="B2"></p>

</form>

<a href="showDataAction.jsp"><b>Click for Show Data</a></b>

</td>

</tr>

</table>

</center>

</div>



</body>



</html>


-------------------------


November 18, 2008 at 12:29 AM


data insert action code:
----------------------------

<%@page language="java" import="java.sql.*" %>



<%

Connection con = null;
String url = "jdbc:mysql://192.168.10.211:3306/";;
String db = "amar";
String driver = "com.mysql.jdbc.Driver";
String userName ="amar";
String pass="amar123";



try{

Class.forName(driver);

con = DriverManager.getConnection(url+db,userName,pass);



try{

Statement st = con.createStatement();

String name = request.getParameter("name");

String lsname = request.getParameter("lsname");
String age = request.getParameter("age");



int val = st.executeUpdate("insert into userinform(name,lsname,age) values('"+name+"','"+lsname+"','"+age+"')");

con.close();

out.println("Successfully insert data into Database");

}



catch(SQLException ex){

System.out.println("SQL satatment not found");

}

}

catch(Exception e){

e.printStackTrace();

}

%>

<br>

<a href="userInform.jsp">Home Page</a>

---------------------------------------



November 18, 2008 at 12:30 AM


Data display code:

----------------------------

<%@ page language="java" import="java.io.*, java.sql.*" %>

<html>

<head>

<title>display data</title>

</head>

<body>

<center>

<H1>Display Record From Database<H1>

<br>

<table border="1" cellpadding="0" cellspacing="0" width="500px" height="69">

<tr>

<td></td>

</tr>

<tr>

<td><b>Id<b></td>

<td><b>Name<b></td>

<td><b>Last Name<b></td>
<td><b>Age <b></td>

<td><b>Delete<b></td>
<td><b>Edit<b></td>

</tr>



<%

Connection con = null;

String url = "jdbc:mysql://192.168.10.211:3306/";;

String db = "amar";



String driver = "com.mysql.jdbc.Driver";

String username = "amar";

String password = "amar123";



try{

Class.forName(driver);

con = DriverManager.getConnection(url+db,username,password);



try{

Statement st = con.createStatement();

String sqlQuery = "Select * from userinform";

ResultSet rs = st.executeQuery(sqlQuery);

int sno = 0;

while(rs.next()){

sno++;

%>



<tr style="background-color:#CCFFFF;">

<td><%=sno%></td>

<td><%=rs.getString("name")%></td>

<td><%=rs.getString("lsname")%></td>
<td><%=rs.getString("age")%></td>

<td><a href = "deleteAction.jsp?id=<%=rs.getInt("id")%>">Delete</a></td>
<td><a href = "Updaterecord.jsp?id=<%=rs.getInt("id")%>">Edit</a></td>

</tr>



<%



}



rs.close();

con.close();

st.close();

}

catch(SQLException ex){

System.out.println("SQL satatment not found");

}

}

catch(Exception e){

e.printStackTrace();

}

%>



</table>

<a href="userInform.jsp">Home Page</a>

</center>

</body>

</html>


November 18, 2008 at 12:31 AM


Data delete action code:

-----------------------

<%@page language="java" import="java.sql.*" %>



<%

Connection con = null;
String url = "jdbc:mysql://192.168.10.211:3306/";;
String db = "amar";
String driver = "com.mysql.jdbc.Driver";
String userName ="amar";
String pass="amar123";



String id=request.getParameter("id");

System.out.println("id:"+id);

try{

Class.forName(driver);

con = DriverManager.getConnection(url+db,userName,pass);



try{

Statement st = con.createStatement();



String sqlQuery = "delete from userinform where id="+id;

int delete = st.executeUpdate(sqlQuery);

con.close();

out.println("Successfully Delete data into Database");

}



catch(SQLException ex){

System.out.println("SQL satatment not found");

}

}

catch(Exception e){

e.printStackTrace();

}

%>

--------------------------------


November 18, 2008 at 12:32 AM


Data edit code.
---------------------

<%@ page language="java" import="java.io.*, java.sql.*" %>
<%
int id=0;
Connection con = null;
String url = "jdbc:mysql://192.168.10.211:3306/";;
String db = "amar";
String driver = "com.mysql.jdbc.Driver";
String userName ="amar";
String password="amar123";



String name="";
String lastName="";
String age = "";
if(request.getParameter("id")!=null && request.getParameter("id")!="")
{

id = Integer.parseInt(request.getParameter("id").toString());


try{

Class.forName(driver);
con = DriverManager.getConnection(url+db,userName,password);

Statement st = con.createStatement();

String sqlQuery = "Select * from userinform where id="+id;
System.out.println("sqlQuery>>>>>>>" + sqlQuery);

ResultSet rs = st.executeQuery(sqlQuery);
if(rs.next())
{
name = rs.getString(2);
lastName = rs.getString(3);
age = rs.getString(4);
}
}
catch(Exception e) {
System.out.println(e.getMessage());
}

}
%>
<html>
<head>
<title>update record</title>
</head>
<body>
<center>
<table border="0" width="400px" cellspacing="0" cellpadding="0">
<tr>
<td width="100%">
<center>
<h2><font color="#FF0033">Update data into database</font></h2></center>
<form name="updateForm" action="updateRecordAction.jsp" method="GET" >
<input type="hidden" name="id" value="<%=id%>">
<table border="1" width="400px" cellspacing="0" cellpadding="0" bgcolor="#CCFFCC">
<tr>
<td width="50%"><b>Id:</b></td>
<td width="50%" valign="right">
<input type="text" name="id" value="<%=id%>"> </td></tr>
<td width="50%"><b>Name</b></td>
<td width="50%">
<input type="text" name="name" value="<%=name%>"></td></tr>
<td width="50%"><b>Last Name</b></td>
<td>
<input type="text" name="lsname" value="<%=lastName%>"><br/></td></tr>

<td width="50%"><b>Age </b></td>
<td>
<input type="text" name="age" value="<%=age%>"><br/></td>

</tr>
<tr><td><center>
<input type="submit" name="update" value="Update"></center></td></tr>

</tr>
</table>
</form>
</td>
</tr>
</table>
</center>
</body>
</html>

------------------------------


November 18, 2008 at 12:35 AM


Edit action code:

-----------------------------

<%@ page language="java" import="java.sql.*" %>

<%
Connection con = null;
String url = "jdbc:mysql://192.168.10.211:3306/";;
String db = "amar";
String driver = "com.mysql.jdbc.Driver";
String userName ="amar";
String password="amar123";

System.out.println( "uri : "+ request.getRequestURI());
int id = Integer.parseInt(request.getParameter("id"));
System.out.println("id:"+id);
String name = request.getParameter("name");
String lsname = request.getParameter("lsname");
String age = request.getParameter("age");

try{
Class.forName(driver);
con = DriverManager.getConnection(url+db,userName,password);
try{
Statement st = con.createStatement();
String sqlQuery ="update userinform set name='"+name+"',lsname='"+lsname+"',age='"+age+"' where id="+id;
int update = st.executeUpdate(sqlQuery);
con.close();
out.println("successfully update data from database!");

}
catch (SQLException ex){
System.out.println("SQL statement is not executed!");
}
}
catch (Exception e){
e.printStackTrace();
}

%>
<br>
<a href="showDataAction.jsp">Edit Page</a>

-----------------------------------

Visit for more information.

http://www.roseindia.net/jsp/user-search.shtml

Thanks.

Amardeep


Related Tutorials/Questions & Answers:
can u plz try this program - Java Beginners
can u plz try this program  Write a small record management application for a school. Tasks will be Add Record, Edit Record, Delete Record, List Records. Each Record contains: Name(max 100 char), Age, Notes(No Maximum Limit
Can u Look to the error plz - Java Beginners
Can u Look to the error plz  this is my code can u modify it plz and give me the result of it when u check it on eclipse or jcreator plz and i will be more thankfull if u do that :) , oh yeh one thing can you draw a flag
Advertisements
plz help me any one as fast as u can
plz help me any one as fast as u can  A thief Muthhooswamy planned... is given in an array. Write a program to find out the total number of jumps he will make to escape from the jail. Input Specifications Your program must read 4
can u plz explain the http request methods - JSP-Servlet
can u plz explain the http request methods  can u plz explain http... duplicate entries in the MySQL database we can follow one of these following approach... we can execute following query: Query CREATE TABLE backup_table AS SELECT
can u plz help out how to attach file directly & send to a particular mail id
can u plz help out how to attach file directly & send to a particular mail id  i am building a project online LEAVE MANAGEMENT SYSTEM to our coll mini project so if a faculty write all details abt leave & shd send to HOD
how can u reduce the size of textfield?
how can u reduce the size of textfield?  how can u reduce the size of textfield? thanks in advance   import javax.swing.*; public class ReduceTextField extends JFrame { public static void main(String
can u help me to get a calendar with color codes on days ???
can u help me to get a calendar with color codes on days ???  hi roseindia, Can you help me to get the code, I need a calendar with color codes.i,e....... NOTE:Its a calendar not a date-picker PLZ can you help me, its very urgent
CAN U HELP ME TO CODE IN JSP FOR ONLINE VOTING SYSTEM
CAN U HELP ME TO CODE IN JSP FOR ONLINE VOTING SYSTEM  can u help me to code in jsp for online voting system
plz try to clear my doubt for shuffling multi-dimensional array
plz try to clear my doubt for shuffling multi-dimensional array  hi, if v r using Arrays.asList() means, it may shuffle the row wise list only... v...??? plz help me... thanks in advance   Hi Friend, Try the following code
Write a program that replaces a, e, i, o, u in Java2
Write a program that replaces a, e, i, o, u in Java2  Write a program that replaces a, e, i, o, u, with the letter z. (i.e. John Smith -> Jzhn Smzth. Also the program reverses the users name (i.e. John Smith -> htimS nhoJ
plz anyone can solve my
plz anyone can solve my  creat an applet prog which accepts the details of 10 customers like name , address , city , ect. and display it   import java.awt.*; import javax.swing.*; import java.awt.event.*; import
plz help me find a program
plz help me find a program  plz help..i want a source code in jsp for order processing
plz explain me the output of program - Java Beginners
plz explain me the output of program  Hi friends, can u please explain me the output of below program with proper explanation of each and every line...;Hi Friend, Output of this program is: a=2 b=0 c=0 mul=27 volume=18
how the answer is 13 can anyone explain plz
how the answer is 13 can anyone explain plz  public class that { public static void main(String arr[]) { int i=3; int j=1; while(i<4) { //j=i; i=i+j/2; } System.out.println(i
plz solve this program - Java Interview Questions
plz solve this program  write a program to out put this resault using two dimensional array this is an image of the reasult: http://www.4shared.com/file/154846107/dc2f1ac1/_2__Untitled-1.html so help me
this code gives addition of 2 numbers in j2me..but the code is not executing ..can u pls find out the error...??
this code gives addition of 2 numbers in j2me..but the code is not executing ..can u pls find out the error...??  import javax.microedition.midlet.*; import javax.microedition.lcdui.*; public class add1 extends MIDlet implements
swing program plz urgent sir - Java Beginners
swing program plz urgent sir   hi sir,i waan a jtable swings program table having column names "itemid","price".Initially table having single empty row.whenever we click the "enter" button automatically new row will be insert
Nested Try-Catch Blocks
Nested Try-Catch Blocks       In Java we can have nested try and catch blocks. It means that, a try statement can be inside the block of another try. If an inner try
Plz Provide correct program code for all questions.
Plz Provide correct program code for all questions.   Write a program... of n numbers? Develop a program that accepts the area of a square and will calculate its perimeter. Develop the program calculateCylinderVolume., which accepts
displaying List of records from database in a jsp using ajax, onclick it should display the results ?? its urgent can u help me
displaying List of records from database in a jsp using ajax, onclick it should display the results ?? its urgent can u help me   displaying List... ?? its urgent can u help me
How Jdbc program can be run??
How Jdbc program can be run??  import java.sql.*; import java.util.*; class MyDbCode3 { public static void main(String [] args) { try...; System.out.println("Enter bookid:"); id=kb.nextInt(); try
very urgent : Iam unable to code this program plz help me - RMI
very urgent : Iam unable to code this program plz help me  Write a Multi-user chat server and client.  Hi friend, Chat server... must be connected with the server after that your message can broadcast to each
Java try, catch, and finally
Java try, catch, and finally         The try, catch, and finally keywords are Java keywords that are used to handle the exception in a program.  The mechanism to handle
plz help me out with this problem...please write the program for me.thanxxxxx
plz help me out with this problem...please write the program for me.thanxxxxx  Write a program that will print out a hydro bill. The bill will be formatted as the example on the next page. The following information
plz help me out with this problem...please write the program for me.thanxxxxx
plz help me out with this problem...please write the program for me.thanxxxxx  Write a program that will print out a hydro bill. The bill will be formatted as the example on the next page. The following information
Can u print in turbo c 9 8 7 6 5 4 3 2 1 0 using pre increment operator Only use print ++a in the same printf() command ten times)
Can u print in turbo C  Can u print in turbo c 9 8 7 6 5 4 3 2 1 0 using pre increment operator Only use print ++a in the same printf() command ten times
Nested try catch
then it will be catch by the catch block. We can have more than one try/catch block. We can declare multiple try blocks inside the try block. The most...Nested try catch      
Try it Editor
Try it Editor  Hello sir...actually i want to add an html,css & js editor like in w3 school try it editor 1.5....can you tell me how i can add it..pllz plzzz rppy soon
Multiple try catch
block then it will be catch by the catch block. We can have more than one try...Multiple try catch          The code which can throw exception should
Can u print in turbo c 9 8 7 6 5 4 3 2 1 0 using pre increment operator Only use print ++a in the same printf() command ten times)
Can u print in turbo c 9 8 7 6 5 4 3 2 1 0 using pre increment operator Only use print ++a in the same printf() command ten times)  Can u print in turbo c 9 8 7 6 5 4 3 2 1 0 using pre increment operator Only use print
how can i add wirecard option(or button ) at my web page plz tell all steps? View Answers
how can i add wirecard option(or button ) at my web page plz tell all steps? View Answers  how can i add wirecard option(or button ) at my web page plz tell all steps? View Answers
Advertisements
 

 

 

DMCA.com