Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to update record in oracle databse

 
Sudhir Pawar
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Posts: 1777
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65105
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not a JSP question, moved to JDBC. You should not be doing this in a JSP to begin with.
 
Sudhir Pawar
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please friends give me solution on this
 
Wendy Gibbons
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic