| Author |
How to update record in oracle databse
|
Sudhir Pawar
Greenhorn
Joined: Sep 27, 2012
Posts: 22
|
|
1.
This is my jsp code which allow to select users through drop down list and then set respective user information to textbox after click on show button.
And i did any changes in shown text fields and click on update button to save those changes in to database(login table).
But how to update text field details through update button?
2.
Here i also face another problem, while matching user_name in table with selected drop down list option e.g. I keep user name = sudhir pawar and any respected details in login table.
Then i select sudhir pawar from drop down list and click on show button no text fields with its respected details are shown in jsp page.
It work fine if i keep user name = sudhir only not sudhir pawar, so please give me solution for this situation.
you can create table using this query:-
CREATE TABLE "LOGIN"
( "NAME" VARCHAR2(50) NOT NULL ENABLE,
"USERNAME" VARCHAR2(50) NOT NULL ENABLE,
"PASSWORD" VARCHAR2(50) NOT NULL ENABLE,
"ADDRESS" VARCHAR2(200) NOT NULL ENABLE,
"CONTACT" NUMBER NOT NULL ENABLE,
"GENDER" VARCHAR2(10) NOT NULL ENABLE,
"EMAIL" VARCHAR2(50) NOT NULL ENABLE
)
/
|
 |
Stefan Evans
Bartender
Joined: Jul 06, 2005
Posts: 1005
|
|
Suggestion #1: Move most of this code into a java class.
Java code does not belong on a JSP.
SQL/Database code does not belong on a JSP.
You might consider methods in this java class such as
public List<String> getAllUserNames();
public User getUserBasedOnName(String name)
public void saveUserDetails(User user);
Suggestion#2: Break this JSP up.
This JSP seems to do many things.
- display a list of users to choose
- display the details for one user
- update the details for one user
I would suggest breaking this functionality up into seperate modules so that you can develop and test each independently.
>It work fine if i keep user name = sudhir only not sudhir pawar, so please give me solution for this situation.
Your database table has fields for both "name" and "username"
Currently your code appears to be looking up using the "name" column, rather than "username". That might explain this situation.
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56216
|
|
|
Not a JSP question, moved to JDBC. You should not be doing this in a JSP to begin with.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Sudhir Pawar
Greenhorn
Joined: Sep 27, 2012
Posts: 22
|
|
|
please friends give me solution on this
|
 |
Wendy Gibbons
Bartender
Joined: Oct 21, 2008
Posts: 1098
|
|
Ok so the key on your database table is name, the select worked when you choose "sudhir" but not when you use "sudihar pawar", these names are different.
It work fine if i keep user name = sudhir only not sudhir pawar, so please give me solution for this situation.
|
 |
Wendy Gibbons
Bartender
Joined: Oct 21, 2008
Posts: 1098
|
|
and to contiue the servlet bullying, but if this is only an example program to test the db end learn about unit tests.
jsp or servlets
|
 |
 |
|
|
subject: How to update record in oracle databse
|
|
|