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

 
 


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

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 Pages:
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
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
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
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
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
files
a given number of files. file names should be given at command line.   ...(); } for (int i = 0; i < f.length; i++) { File file = new File(f[i]); try { BufferedReader freader = new
again java - Java Beginners
again java  i will ask iam using servlets ,in one program my...: please observe the code: )page.jsp: Display file upload form to the user UPLOAD THE FILE   Choose the file To Upload:  
again java - Java Beginners
again java  Hi, i will ask iam using servlets ,in one program...: please observe the code: )page.jsp: Display file upload form to the user UPLOAD THE FILE   Choose the file To Upload
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
(); 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
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
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
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 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
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 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
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
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
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 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
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
files
files  Question:How to create a new text file in another directory..(in which .class file is not there)... Discription:If we use the class FileWriter to write data to a new file then a new file
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
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
Java Write To File Append
the older text when you are writing again to an existing file. To achieve... the text when you are writing in a text file. Appending a text means that the text that are written earlier or can say the old contents of an existing file should
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 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 "
Console vs Dialog I/O
age")); Example program written two ways Here's a simple program to average three ints, written once with JOptionPane and again... Java NotesConsole vs Dialog I/O Dialog box I/O is useful. Normal
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
Adding a Reports tap in table pool
Adding a Reports tap in table pool  strong textHow to write a code to create a report in java using eclipse and link that report in jsp file that is written in jsf. I have to edit a jsp file that is written jsf there is a table
JFREE error again
JFREE error again  hi......... As i had asked u the jfree error i want to tel u that i have taken the both the jar files jfree and jcommon. but then also its giving me error i am able to compile the code but now when i am
again with xml - XML
again with xml  hi all i am a beginner in xml so pls give me...)); System.out.print("Enter a XML file name: "); String xmlFile = buff.readLine(); File file = new File(xmlFile); System.out.print("Enter an element
java and files - Java Beginners
. i have one doubt that is i have written a program for accessing the xml file from java code,its get executed for that i have used XML Prser. but now... in file.when ever i execute that program the text file that is notepad
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
adding a dialogue
adding a dialogue  Blockquote Hi can you help with the program below,the program is a loop that prints out a code and a quantity when prompt for the user input.what I need is to modify the code to incorporate a dialogue asking
adding loop
adding loop  Hi I have a program that is not compiling when I add a loop can you help me?The program below is compiling without the loop. >...:"); String p=in.nextLine(); } } And the program containing
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  
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
saving files
saving files  i want to create a program that would allows me to save my file and attach data
Java show files in tree format
the whole file system in tree format. Description of code: The java.swing... example, we have used JTree class to show the whole files in a systematic way...(); root.setUserObject(file.getName()); if (file.isDirectory()) { File files
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 Log Records Only After a Condition Occurs
those have been written in a log file if  the "if" conditions... of program: Program takes a file name that has '.log' extension and checks it. If the given file exists then log records are written in a log file, when
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
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
problem of writing to a local file ( JApplet ) - Applet
problem of writing to a local file ( JApplet )  Dear All, I want to program a guestbook using java applets but now I have problem of writing to a file from JApplet. it is working without any problem if i run the program using
avoid using the whole URL
avoid using the whole URL  How can I avoid using the whole URL
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
differences between require and include, include_once.
of the code of next line. include_once();-->if same file was included first...differences between require and include, include_once.  What are the differences between require and include, include_once?   Hi friends

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.