This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes JDBC and the fly likes How to update record in oracle databse Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "How to update record in oracle databse" Watch "How to update record in oracle databse" New topic
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
    
  13

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
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: How to update record in oracle databse
 
Similar Threads
Login JSP if condition and redirecting issue
Value in the else condition is getting printed as the page loads
How to position fieldset?
error comes while connecting to database please see the source code and error for detail
JSP two pages