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

 
 


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

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 Pages:
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
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 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
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
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
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
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
Gui plz help
Gui plz help   Create a Java application that would allow a person... if u got it right or wrong and also i gave them some coding but i can't make it do only 10 questions for button1 and not able to add them so i can get answers
plz. answer my ques - Java Beginners
such type of program is possible in c.  can you mention technology in which u want to do i mean for view or it simple console based.  create...plz. answer my ques  I want to ask a prog. prob which would create
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
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
help plz - Java Interview Questions
help plz  1 )write a program that does the following : a. prompts... 2)write a program that prompts the user to input a four-digit positive integer. the program than outputs the digits of the number, one digit per line
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      
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
help plz - Java Interview Questions
help plz   1 )write a program that does the following : a. prompts... 2)write a program that prompts the user to input a four-digit positive integer. the program than outputs the digits of the number, one digit per line
code and specification u asked - Java Beginners
code and specification u asked  you asked me to send the requirements... can build in java are extensive and have plenty of capability built in. We found including a browser can be very useful, example. The user browse
Try catch in JSP
Try catch in JSP          In try block we write those code which can... it is caught inside the catch block. The try catch block in jsp just work as 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
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
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
plz send code for this
plz send code for this  Program to calculate the sum of two big numbers (the numbers can contain more than 1000 digits). Don't use any library classes or methods (BigInteger etc
plz answer - Java Beginners
plz answer   Write a Binary Search program that searches an array of ordered data. Compose an ordered array of 500 integers that contains..., 89, ...  Hi Friend, Try the following code: import java.util.
plz help - Java Beginners
plz help  i have to programs and it takes too long to run them so i... some operations ... how can i makes them as thread first code: import...(); } public void run(){ try { System.out.println(s
plz Help me - Java Beginners
plz Help me  Hi, I want learn struts,I dont have any idea about this plz help how can i make a framework.If u have any information then plz send my personal id plz tell me that whose software installed.and give me brief
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
plz - Java Interview Questions
greater than or equal to 1 and less than or equal to 6 , you can use...; Hi Friend, Try the following code: import java.util.*; class die
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
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
try and finally block
try and finally block  hello, If I write System.exit (0); at the end of the try block, will the finally block still execute?   hii, if we use System.exit (0); statement any where in our java program
Try and catch in Exception Handling.
Try and catch in Exception Handling.  How can we use try and catch...; try{ x=a/b; }catch (Exception er.... Then to perform exception handling, we have used try and catch block where we have
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 - Java Interview Questions
plz help  1)write a java program that prompts the user to input... on three exams and two large projects.the program should then add five decimal... don't use "for"  Hi Friend, Try the following code 1) import
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 help me find a program
plz help me find a program  plz help..i want a source code in jsp for order processing
Plz Help
Plz Help  Hello Guys!! Plz. Help I need to write a program to display the astrological sign based on your birthday for example If we enter the date of birth in the following format from console--13/08/1990 it should give you
sir plz do respond to my problem immediately - Java Beginners
code(sent by you).plz inject that code into my browser code so that it can show...sir plz do respond to my problem immediately  Hello sir, Iam very happy that you have responded to my problem.The code u sent
pattern program
pattern program  can any 1 print the following pattern in java .plz give the code.and yes thank u so much for answering my 2 other questions.had i known that this would be so helpful i would have registered here long
Maximum number of catches for a try block
Maximum number of catches for a try block  How many catch statements are allowed for a try statement?   Hello Friend, You can use any number of catch statement for a try statement. Thanks
ans plz
class MyThread2 extends Thread  Hi Friend, Try the following code..., PipedWriter pw) { this.pr = pr; this.pw = pw; } public void run() { try... pr, PipedWriter pw) { this.pr = pr; this.pw = pw; } public void run() { try
required treenodes checkboxes are not clicking if u change the url - Java Server Faces Questions
required treenodes checkboxes are not clicking if u change the url  ...(1001,1007,1002,1005,1008,1002,1009,1010,1008)are getting clicked. But when u again add or remove the album... changes in the screen . can anybody help asap. Library.java
help today plz:( - Java Interview Questions
help today plz:(  write a program that promptes the user to enter the weight of a package in pounds, and then outputs the weight of the backage... "for" and import java.text.*;  Hi Friend, Try the following code
OCI Connectivity For Oracle Plz Solve This Error
) { e.printStackTrace(); } } } ---> I found Error below how i can solve this error plz...OCI Connectivity For Oracle Plz Solve This Error  import java.io.... class OraThin { public static void main(String[] args) { try
OCI Connectivity For Oracle Plz Solve This Error
) { e.printStackTrace(); } } } ---> I found Error below how i can solve this error plz...OCI Connectivity For Oracle Plz Solve This Error  import java.io.... class OraThin { public static void main(String[] args) { try
java program
this as soon u finished this thanks   Hi Friend, Try the following code: <...java program  Problem 1 Write a javaScript program that would input... hours worked:__ Overtime pay:_ Gross pay:__ Guys plz help me 4 this problem thanks
help me plz - Java Interview Questions
? plz answer my question   Hi Friend, Try the following code: 1...help me plz  1)write a java program that prompts the user to input... scors on three exams and two large projects.the program should then add five
really need help on how to write this program plz some 1 help out. - Java Beginners
really need help on how to write this program plz some 1 help out.  i am confused here on what to write can some 1 help out here i dont quite understand how to code it so can some 1 help out. Part II Write, compile and execute
php brute force code.. hlp plz .....
php brute force code.. hlp plz .....  hello friends, from somewhere i got a code that can generate all posible combination via recursive function... on ... to last combination so please edit my script so that i can get my project
ping program
but i want every ip info into my db.so can u pls help me out. code: import...ping program  my program will ping upto 192.168.100.59. and i want...() { try{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con
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

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.