This week's book giveaway is in the Server-Side JavaScript and NodeJS forum.
We're giving away four copies of Modern JavaScript for the Impatient and have Cay Horstmann on-line!
See this thread for details.
Win a copy of Modern JavaScript for the Impatient this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

jdbc update help

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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(){
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
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 ?");
pre.setString(1,"warney");
pre.setString(2,"Charasala");
int n=pre.executeUpdate();
ResultSet rs = stmt.executeQuery("select * from mytable");
while ( rs.next() ){
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");
e.printStackTrace();
}
}
public static void main( String[] args ) {
JdbcTest test = new JdbcTest();
test.doTest();
}
}

 
Poop goes in a willow feeder. Wipe with this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic