• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Access Database

 
pree sree
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have connected to my database in access.I am able to retrieve(select * from table) is working.

ResultSet rs = null;
Statement stmt= null;
Connection connection = getConnection();
stmt = connection.createStatement();
rs = stmt.executeQuery("select * from table");



when i do update or insert, I am not getting any error messages but
execute(query) returns false and executeUpdate returns 1 ??


ResultSet rs = null;
Statement stmt= null;
Connection connection = getConnection();
stmt = connection.createStatement();
rs = stmt.execute("insert" or "update" or "delete");

Please help me.
 
Aravind Prasad
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Pree Sree!!
there are some drawbacks for the MS Access Database!!
u can select using the execute(query)
but when u try to insert use the Prepared Statement!! ok

we can insert.. delete using PreparedStatement!!
select work in execute()

i'm not sure abt the update table statement.. in msaccess..
i tried it long back!!

but when i tried it in oracle..
every query is running perfectly!!

try the prepared statement!!
if u have any doubts ..
send reply.. will help u!!
thanks
regards!!

Aravind
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aravind, please use real words and try not to use abreviations. These make your posts hard to understand.

Pree, there is a bug in the JDBC-ODBC bridge where it does not always commit operations to the databases. Three common solutions are:
1) setAutoCommit(true) on the connection or
2) do a dummy select after insert/update/delete operations eg "select * from user where userid=1". This will cause the previous operation to go through.
3) Don't use Access
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic