• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

insert command is not working.

 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Friends,
after executing the following code, the table is not inserted with the new value. any body help me with this?
 
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Look for the return value from executeUpdate call. Is it really returning 0? If not so, then probably the autocommit on your connection is false. So you may have to call

before closing statement object.

If, executeUpdate call returns 0, then I am not sure why you did not get any exception.
 
K Vidhyakar
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
int i=stat.executeUpdate();
System.out.println(i);

prints 1.

So wat may be the problem? is my code is perfect?
or else wat are the things i have to consider regarding the data base. ie ms access.
 
Susanta Chatterjee
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is very good that executeUpdate returns 1. Now, try putting con.commit() before closing statement object, as I have suggested before. Looks like, connections are not set to autocommit on your database and you do have to do it as part of your program.

You may talk to your DBA (or look for documentation to see how if you are DBA yourself) if database connections are set to have autocommit false by default.
 
K Vidhyakar
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks a lot. its working after calling con.commit() method

stat.executeUpdate();
con.commit() ;
stat.close();
con.close();

Thanks a lot
reply
    Bookmark Topic Watch Topic
  • New Topic