textfields and update

textfields and update

View Answers

September 22, 2008 at 11:20 AM



Hello Friend

As per ur 1st Q: Read the data from database and store into a list or arraylist (as per ur requiement);
pass the list into jsp page, iterate there and display.

In Second Q, u not clarify under which basis u want to update database?
can u clarify?

Thanks
Rajaniakant

September 22, 2008 at 11:29 AM

Hi friend,


Code to update record retieve at the Same time:

Some points to be remmeber:

1.Create a "process.jsp" file to update and retrieve record from database.
2.Using set the arraylist in the request parameter and forward to next page.

"process.jsp"

<%@ page import="java.sql.*,java.util.*,java.text.*,java.text.SimpleDateFormat" %>
<%

String userName = request.getParameter("userName");
String password = request.getParameter("password");
String first_name = request.getParameter("first_name");
String last_name = request.getParameter("last_name");

System.out.println("MySQL Connect Example.");
Connection conn = null;
String url = "jdbc:mysql://localhost:3306/";;
String dbName = "user_register";
String driver = "com.mysql.jdbc.Driver";
String username = "root";
String userPassword = "root";

java.util.Date now = new java.util.Date();
String DATE_FORMAT = "yyyy-MM-dd hh:mm:ss";
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);

String strDateNew = sdf.format(now) ;


try {
Class.forName(driver).newInstance();
conn = DriverManager.getConnection(url+dbName,username,userPassword);
Statement st = conn.createStatement();
Statement stmt = conn.createStatement();

String strQueryUpdate = "update user_register set first_name='"+first_name+"',last_name='"+last_name+"' where username='"+userName+"' and password='"+password+"'";

int i = st.executeQuery(strQuery);

String strQuery = "select * from user_register";
//out.println(strQuery);
ResultSet rs = st.executeQuery(strQuery);

ArrayList al = new ArrayList();

ArrayList arList;
while(rs.next())
{
arList = new ArrayList
String first_name= rs.getString("first_name");
String last_name= rs.getString("last_name");
al.add(first_name);
al.add(last_name);

arList.add(al);
}

request.setAttribute("arList",arList);
String nextJSP = "/home.jsp";
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(nextJSP);
dispatcher.forward(request,response);
conn.close();

} catch (Exception e) {
e.printStackTrace();
}
%>

Display record from database:

"home.jsp"

<%

List arlist = (ArrayList)request.getAttribute("arList");
Iterator itr = arlist.iterator();
Iterator itrrecord;
while(itr.hasNext())
{
Arraylist alrecord = (ArrayList)itr.next();

itrrecord = arlist.iterator();
while(itr.hasNext())
{
out.println(itr.next());
}
}
%>

Thanks


For read more details to visit....

http://www.roseindia.net/servlets/web-application.shtml

Thanks










Related Tutorials/Questions & Answers:
textfields and update - SQL
textfields and update  how can i retrieve a table from a database and put in on the textfields using jdbc?and at the same time update the items on the database
textfields and update - SQL
textfields and update  how can i put retrieved table from a database to the textfields using jdbc?and at the same time update the items on the database..   Hello Friend As per ur 1st Q: Read the data from
Advertisements
TextFields
labels,textfields,buttons
labels,textfields,buttons  how to set the labels,textfields,buttons at certain positions such that we can add them without layout managers? my program is to design a login page with image and these labels at exact positions
update
update  how can i update multiple records in database using jsp ,servlet and jdbc based on selection of checkbox in jsp
update
update  Predict and justify the output of the following code snippet written by the developer to update the Status table: String str = "UPDATE m...://localhost:3306/roseindia", "root", "root"); String str = "UPDATE Status SET
making of dynamic textfields using swings
making of dynamic textfields using swings  How to make dynamic textfields using java swings
making of dynamic textfields using swings
making of dynamic textfields using swings  how to crate dynamic texfields by clicking on button
update profile
update profile  coding for update profile
how to update
how to update   conditional update
update image
update image  sir, I want to do update image into database
dynamic textfields
Background color blocks all labels and textfields
Background color blocks all labels and textfields  I added background color but I dont see textfields and labels anymore, please help. What am I missing? (" JFrame f = new JFrame(); SchoolOption f1 = new SchoolOption(); Color c
update query
update query  using oops concept in php.. How to update the data from databse ? with program example
Use Map to display file data into textfields
Use Map to display file data into textfields Collection framework allows... textfields which are generated at run time. In text file, we have written... { JButton b = new JButton("Put file data into TextFields"); JPanel p = new
to update the information
to update the information   sir, i am working on library mgt project. front end is core java and backend is ms access.i want to open,update the information through form.please send me code earliar
How to insert data from textfields into database using hibernate?
How to insert data from textfields into database using hibernate?  ...(); } This method doesn't work. I tried with quotes for textfields, without them. The setters require other parameters, not textfields. I tried to cast them
update database
update database  hi.. i want to know how the valuesof database can be updated in the jsf-jpa framework when the drop down button is clicked the data... that can be done there then by pressing the update buutton the value can be updated
Update value
Update value  How to update value of database using hibernate ?   Hi Samar, With the help of this code, you will see how can update database using hibernate. package net.roseindia.DAO; import
to update the information
update the information   sir, i am working on library mgt project. front end is core java and backend is ms access.i want to open,update the information through form.please send me code earliar.   Please visit
Update - JDBC
is what I used to update normally. It works. Please assist me. Thanks...("jdbc:odbc:Biu"); stat = con.prepareStatement("Update Biu SET itemcode...; Step1: Retrive the column value which one you want to update and store
coding for update profile
coding for update profile  coding for update profile
update mysql database
update mysql database  update mysql database
update php cpanel
update php cpanel  update php cpanel
Update statement
Update statement  I create a access database my program When I click add button bata are adds to the my data base but when i click update button my database is not update I write this program using 3 differfnt notepad pages MY
update jsp
update jsp  <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC...;/Controller"> <center> <input type="hidden" name="page" value="update"/>
create a table in access2007 from gui application using textfields and combox
create a table in access2007 from gui application using textfields and combox  I want to create a table in ms access 2007 from gui application in which when i click create button the table should get created based on textfield
data update
edit/update data and saved them into that table again
Update a resultset programmatically
Update a resultset programmatically  How to update a resultset programmatically
auto update codings
auto update codings  auto update coding in xml
how to update image in php
how to update image in php  how to update image in php
Update not working in hibernate.
Update not working in hibernate.  Update not working in hibernate
Hibernate Update
In this section we will discuss various method of update
Update Profile
Update Profile       Update Profile This facility is used for updating user... user wishes to change their information, he may proceed by clicking on Update
update statement in mysql
update statement in mysql  i am looking for mysql update statement example. Thanks
update two frames at once
update two frames at once  How do I update two frames at once
ModuleNotFoundError: No module named 'update'
ModuleNotFoundError: No module named 'update'  Hi, My Python... 'update' How to remove the ModuleNotFoundError: No module named 'update'... to install padas library. You can install update python with following command
Update SQL Query Example
Update SQL Query Example  Hi, I am beginner in SQL (MySQL) and trying to learn Update SQL Query with Example code. Can anyone explain me the SQL Update query with an example code? Thanks   Hi, A simple example
The Update Statement in SQL.
The Update Statement in SQL.  The Update Statement in SQL.   Hi, here is the answer,ADS_TO_REPLACE_1 The update statement in the sql is written as follows- UPDATE table_name SET column_name = new_value WHERE column
Where to update the Hibernate tools?
Where to update the Hibernate tools?  Hi, What is the url to to update the hibernate tool in eclipse? Thanks   Hi, Hi if you are using the hibernate tool you can update it. Check Check the tutorial Hibernate tools
frame update another frame.
frame update another frame.   How do I make a link or form in one frame update another frame
session update in php
session update in php  How to session update in php?   $this->session->set_userdata('name', $fullname
Foreign key update table
Foreign key update table  How to update table that has the foreign key in SQL..?   ALTER TABLE YourTable ADD CONSTRAINT FK_YourForeignKey... (YourPrimaryKeyColumn) ON UPDATE CASCADE
How to update table in Hibernate
How to update table in Hibernate  Hi, I have a table in database that has two fields in it. Student Name and ID, can anyone explain me how to update these tables in Hibernate. Thanks.   Update table query in Hibernate
CASE IN UPDATE IN MYSQL
CASE IN UPDATE IN MYSQL  I WANT THE SYNTAX FOR USING CASE IN UPDATE STMT IN MYSQL.ANY ONE PLEASE HELP.   Hi Friend, Visit hereADS_TO_REPLACE_1 Thanks
how to update the value of jslider
how to update the value of jslider  hello, I want to make a audio player but the jslider is not updating help me
how to update the value of jslider
how to update the value of jslider  hello, I want to make a audio player but the jslider is not updating help me
how to update the value of jslider
how to update the value of jslider  hello, I want to make a audio player but the jslider is not updating help me
how to update the value of jslider
how to update the value of jslider  hello, I want to make a audio player but the jslider is not updating help me
how to update the value of jslider
how to update the value of jslider  hello, I want to make a audio player but the jslider is not updating help me

Ads