This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

strange!! if not close, database not show ??

 
Dairmon Lee
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,
I am using "sun.jdbc.odbc.JdbcOdbcDriver" doing a testing project using Access 2000 as the database.
I run into a strange scenario:
try{
con=DBUtil.getConnection();
Item it = new Item(con2);
// some insert statement here
con.commit(); //this line not work either!!
}catch (Exception e){
e.printStackTrace();
}finally{
try{
if (con2!=null){
con2.close();// if I comment out this line, database not show the change at all!!
}
}catch(Exception e){
e.printStackTrace();
}
}
Even if I add a con.commit() doesn't help, (if without the con.close() )
Is it normal? Any comments?
Thanks!
[ May 07, 2002: Message edited by: Dairmon Lee ]
[ May 07, 2002: Message edited by: Dairmon Lee ]
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, its a common problem. If you do a search of this forum, you'll find several probems refering to it like this one.
Options are to close the connection, or perform a dummy select afterwards, both seem to 'flush' the operations.
Dave
 
Jamie Robertson
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also ( a side note ), I believe that Access does not support transactions, so con.commit() would be useless anyways. But this does sound like the problem David pointed out.
Jamie
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic