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



Home Answers Viewqa Java-Beginners i written the program in the files but in adding whole file is writing once again

Have Programming Question? Ask it here!
 
 
 


niharika
i written the program in the files but in adding whole file is writing once again
4 Answer(s)      5 years and 5 months ago
Posted in : Java Beginners



Advertisement
View Answers

November 17, 2008 at 3:37 AM


Hi friend,

<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>



</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 17, 2008 at 3:38 AM


<%@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");



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

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 17, 2008 at 3:40 AM


Display record


<%@ 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>Delete<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><a href = "deleteAction.jsp?id=<%=rs.getInt("id")%>">Delete</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 17, 2008 at 3:41 AM


Delete record 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();

}

%>

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

Read for more information.

http://www.roseindia.net/jsp/

Thanks.

Amardeep


Related Tutorials/Questions & Answers:
i written the program in the files but in adding whole file is writing once again - Java Beginners
i written the program in the files but in adding whole file is writing once again  Very Urgent: Write a small record management application file and it should not be re-written for every add/delete operation.  Hi
reading multiple files from a directory and writing them into a single file
reading multiple files from a directory and writing them into a single file... file i get an empty text file can you guide me how to do this: /*this program reads multiple files * from a single directory. */ package elite.tech.com
Advertisements
java program for writing xml file - Java Beginners
java program for writing xml file  Good morning i want to write values from my database(one table)into one xml file. Like i have 3 coloumns in my table along with their values,so when click some button i need to generate one
Adding .txt files in a given directory
Adding .txt files in a given directory  I want to read number of XML... tag value as one .txt file in a given directory? I have extracted tag values but plz help me how can I save each body tag as one .txt file and add in a directory
without writing web.xml file we can write servlet program
without writing web.xml file we can write servlet program  Sir Morning... Sir I have one Question "without writing web.xml file we can write servlet program". if yes which way? if no why? but without use Annotation........ Plz
Writing a Program to calculate Circumference of planets reading from a file and writing to new file.
Writing a Program to calculate Circumference of planets reading from a file and writing to new file.  Hello, I would like to know how to write a program to read data from a file. Then use the numerical data within
I am writing a program which converts a string to a timestamp and add days to it
I am writing a program which converts a string to a timestamp and add days to it  java.sql.Timestamp ts2 = java.sql.Timestamp.valueOf("2012-01-11 12:34:39"); long l=ts2.getTime() +(100060602424);//add 24 days Date d=new Date(l
Writing a Program to calculate Circumference of planets reading from a file and writing to new file.
Writing a Program to calculate Circumference of planets reading from a file and writing to new file.  Hello, I would like to know how to write a program to read data from a file. Then use the numerical data within
written in jsp file
written in jsp file  how to create and write in a jsp file through simple core java code
Reading and Writing files - Java Beginners
to investigate writing to files a little (can be also done using Properties...Reading and Writing files  Hello, please help me to Develop a simple... from a file. After welcoming the users, ask them for their name and save
i need a program that will generate daily base log file dynamically - Log4J
i need a program that will generate daily base log file dynamically  i need a program that will generate daily base log file dynamically For example: if suppose today date is 2 sep 2009, when i execute the program it ll
Adding a text file - Java Beginners
Adding a text file  Hello, I need a program that will search a text file of strings representing numbers of type int and will write the largest and the smallest numbers to the screen. The file contains nothing but strings
File I/O - Text Files
Java NotesFile I/O - Text Files Java can read several types of information from files: binary, Java objects, text, zipped files, etc. One of the most... file reading and writing. // Author: Fred Swartz // Date : February 2006
How can I write a GUI stack program by Java to push Image files instead of other data type items?
How can I write a GUI stack program by Java to push Image files instead of other data type items?   How can I write a GUI stack program by Java to push Image files instead of other data type items? for the push instruction I
How to create d db for upload files using bolb i m followin dat upload file in db tutorial
How to create d db for upload files using bolb i m followin dat upload file... wht u have posted, still der is some problem,My program creates class file, But whn i run d application it only uploades the file in C:/uploadedfiles, and i get
File saving and Writing
File saving and Writing   Hello Rose india..... I have a doubt... a "file create option" it will be ".csv" file and i want to write the data from arraylist into .csv file and i want to save that file so it will ask for "save
How to create d db for upload files using bolb i m followin dat upload file in db tutorial
How to create d db for upload files using bolb i m followin dat upload file in db tutorial  How to create d db for upload files using bolb i m followin dat upload file in db tutorial   Create a table named 'file
File I/O
(); File[] files = file.listFiles(filter); for (int i = 0; i <... all the files to on file what am looking for is writing files to different files...File I/O  greetings i was running into a problem. is their a way
Writing and Reading A File
(FirstName, LastName, Age). I also made an empty file I named "contactsFile.txt" where...Writing and Reading A File  Hello, I've been trying to learn writing and reading data from file for our assignment, but just stuck on how to proceed
writing and appending to a file
writing and appending to a file  My input file includes data from... and values and writes into an existing file for 'male'. How can I do the same for females and write into a different 'female string' in the same program? Sorry If I
This code send email two times but i want only once
This code send email two times but i want only once   public void dbbackup_notify(String email,String data,String subject){ String toEmails = email; Session session=Session.getInstance(props, new
This code send email two times but i want only once
This code send email two times but i want only once   public void dbbackup_notify(String email,String data,String subject){ String toEmails = email; Session session=Session.getInstance(props, new
File Writing - Java Beginners
File Writing  Hi... I need a syntax or logic or program by which we can write into the desired shell of the Excel file from console window...  Hi friend, I am sending you a link. This is will help you. Please
writing program - Java Beginners
writing program  WAP to input Name of Cricketer, Number of matches...; for(int i=0;i<5;i++){ System.out.println("Enter cricketer name...: "); int runs=input.nextInt(); average=runs/matches; data[i
Converting Text Files into Bzip File
Converting Text Files into Bzip File  Hi, I am facing the problem during run the program, when converting text files into Bzip file. Please guide me how do i convert the text file into bzip file in PHP. I will welcome, if anyone
Writing a GUI program - Java Beginners
Writing a GUI program  Hello everyone! I'm trying to write a program... if that number is prime or not. When the second button is pressed the program has to calculate the prime factors of the given number. I figure out the whole
File I/O
File I/O  i am trying to write a program that reads a text file... the text file then read it and write it into as a comma delimitade file. i have to problem: everything is perfect but when it comes to writing my program also
Writing xml file - Java Beginners
Writing xml file  Thank you for the quick response The values which... values from the database. If it is still confusing i'l post you my question again... XmlServlet().createXmlTree(doc); System.out.println("Xml File Created
common database jsp file for all the jsp files in the application
common database jsp file for all the jsp files in the application  hi, i have written jspcode to connect to mysqldatabase . i need the code to make use of this single jsp file while connecting to database rather than writing
writing program in bluej - Java Beginners
writing program in bluej  How to write the program on follwing WAP to inpout a string and print Input : I stidied Hard   Hi Friend, Try the following: import java.util.*; public class UserInput{ public
Writing a file using servlets - JSP-Servlet
, but its not writing in the xyz.txt file. I think writing in a servlet should...Writing a file using servlets  I'm using a servlet to read an input... reading the data and creating a file in my space. but it is not writing
Writing Log Records to a Log File
Writing Log Records to a Log File   ... and severe that have log records. Log records are written into a log file... then log records will be written into a log file and it displays a message "
Need help writing a console program
Need help writing a console program  I need help cant seems to figure it out! Write a program that consists of three classes. The first class... will replace all sequences of 2 spaces with 1 space. The program will read a file
i am getting an error in adding a menu item to a menu.
i am getting an error in adding a menu item to a menu.   i am not able to execute the menu program. i am getting an error at menu.add(menuitem); it says add method is undefined for type menu. but as far as i know that is only way
want a program for cd writing in java - Java Beginners
want a program for cd writing in java  Hi Can u tell some body, doing a program on cd writing in java. I m facing some problem on it. Thanks in advance. Regards sanjaya
writing a text into text file at particular line number
writing a text into text file at particular line number   Hi, thanks for quick response, I want to insert text at some particular line number.. after line number four my text will display in text file using java program
Writing to and reading from a binary file in java.
Writing to and reading from a binary file in java.  I have written... the binary file from another program as follows: m_dis = new DataInputStream... having the format: 00501 40.815400 -73.045600. The entries I get in the binary file
File Upload and Retrive files
File Upload and Retrive files  Can any body help me am getting an error in uploading file. into mysql database.... thank's in advance
counting the values in input file and and writing the output to a file
counting the values in input file and and writing the output to a file ...("Sending the output to file:"); for(i=0;i < 20; i++) { for(j=0;j<4; j...-code/16483-counting-values-input-file-writing-output-file.html this code
How do I decompile Java class files?
How do I decompile Java class files?  How do I decompile Java class files
files
and ObjectOutputStream classes to read and write from the file ??obj.txt??. Create variables and initialize them with the values to be written to the file. Once it is written, use ObjectInputStream to read those values from the file
File I/O
File I/O  i have a problem i am trying to print on a new line every... File file = new File(inpath);//files from the inpath File[] files = file.listFiles();//listFiles all file in inpath dir for (int i = 0; i <
writing a text into text file at particular line number
writing a text into text file at particular line number   Hi, thanks for quick response, I want to insert text at some particular line number.. after line number four my text will display in text file using java program  
writing a text into text file at particular line number
writing a text into text file at particular line number   Hi, thanks for quick response, I want to insert text at some particular line number.. after line number four my text will display in text file using java program  
avoid using the whole URL
avoid using the whole URL  How can I avoid using the whole URL
i need program or code for this program
i need program or code for this program  out should be in this form 1 2 3 4 5 6 3 5 7 9 11 8 12 16 20 20 28 36 48 64 112
need help on writing a program. - Java Beginners
Writing first Java Program  Hi, I need help to write my first Java Program other then Hello World! Thanks!!  Hi Thanks for choosing roseIndia to get your query solved. check given link to see the solution of your Java
File I/O
File I/O  i am trying to read and write a file. my program works perfectly i am using PrintWriter and BufferedReader. but my problem is that when... like this input file blahblah i am a computer i am running windows i am
In JSF2 application, source code written in xhtml file is downloading
In JSF2 application, source code written in xhtml file is downloading   HI All, We have a jsf2 application deployed on WAS 8.0. When we hit on xhtml pages, source code written on xhtml pages is downloaded. Same application
file I/O
file I/O  Write a java class which it should do below Read the attached file. Sorted out and writer it into another file(sorted values). Also find the SECOND biggest number in the attached file
Advertisements
 

 

 

DMCA.com