This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes jdbc update help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "jdbc update help" Watch "jdbc update help" New topic

jdbc update help


Joined: Jan 06, 2001
Posts: 6
hi guys
i am trying to update some value in the database which i haved inserted before. it's not givifng any error but it's not updating in the database. pls help
here the codeimport java.sql.*;
public class JdbcTest {

public void doTest(){
Connection con = DriverManager.getConnection("jdbc dbc:rajesh","sa","") ;
Statement stmt = con.createStatement();
//System.out.println("Table Created?"+stmt.executeUpdate("create table mytable (sno integer, name
//varchar(20) )"));
//System.out.println("Inserted?"+stmt.executeUpdate("insert into mytable values (3, 'shane')"));
//System.out.println("Inserted?"+stmt.executeUpdate ("insert into mytable values (4, 'warne')"));
PreparedStatement pre=con.prepareStatement("update mytable set name=? WHERE name LIKE ?");
int n=pre.executeUpdate();
ResultSet rs = stmt.executeQuery("select * from mytable");
while ( ){
System.out.println("SNO ==>"+rs.getInt("sno")+"\n");
System.out.println("NAME ==>"+rs.getString("name")+"\n");
}catch (Exception e){
System.out.println("Error Creating Record");
public static void main( String[] args ) {
JdbcTest test = new JdbcTest();

I agree. Here's the link:
subject: jdbc update help
It's not a secret anymore!