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



Home Answers Viewqa SQL textfields and update

Have Programming Question? Ask it here!
 
 
 


raven
textfields and update
2 Answer(s)      5 years and 10 months ago
Posted in : SQL



Advertisement
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
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
making of dynamic textfields using swings
making of dynamic textfields using swings  How to make dynamic textfields using java swings
update
update  how can i update multiple records in database using jsp ,servlet and jdbc based on selection of checkbox in jsp
making of dynamic textfields using swings
making of dynamic textfields using swings  how to crate dynamic texfields by clicking on button
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
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
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... = new JButton("Put file data into TextFields"); JPanel p = new JPanel
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
how to update
how to update   conditional update
update profile
update profile  coding for update profile
update image
update image  sir, I want to do update image into database
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
update query
update query  using oops concept in php.. How to update the data from databse ? with program example
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
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
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"/>
data update
edit/update data and saved them into that table again
update php cpanel
update php cpanel  update php cpanel
update mysql database
update mysql database  update mysql database
coding for update profile
coding for update profile  coding for update profile
code to enter values in multiple textfields throught 10 buttons (0-9) (as if a calculator programe)
code to enter values in multiple textfields throught 10 buttons (0-9) (as if a calculator programe)  how can i enter values in two different textfield's through 10 different buttons.?? as we saw a online calculator type
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 not working in hibernate.
Update not working in hibernate.  Update not working in hibernate
how to update image in php
how to update image in php  how to update image in php
auto update codings
auto update codings  auto update coding in xml
Update a resultset programmatically
Update a resultset programmatically  How to update a resultset programmatically
Hibernate Update
In this section we will discuss various method of update
How to open textfields in the the same panel of the jframe by selcting from dropdown menu option ...
How to open textfields in the the same panel of the jframe by selcting from... and i have to show textfields and submit button on the basis of the selection... the textfields and submit button in the same panel of the jframe window . Below is my
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
The Update Statement in SQL.
The Update Statement in SQL.  The Update Statement in SQL.   Hi, here is the answer, The update statement in the sql is written as follows- UPDATE table_name SET column_name = new_value WHERE column_name = some_value
session update in php
session update in php  How to session update in php?   $this->session->set_userdata('name', $fullname
frame update another frame.
frame update another frame.   How do I make a link or form in one frame update another frame
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 here 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
Dynamic-update not working in Hibernate.
Dynamic-update not working in Hibernate.  Why is dynamic update not working in hibernate?   Dynamic-update is not working. It means when you are running your update, new data is added in your table in place
Advertisements
 

 

 

DMCA.com