This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes Access Database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Access Database" Watch "Access Database" New topic
Author

Access Database

pree sree
Ranch Hand

Joined: Jul 27, 2002
Posts: 34
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

Joined: Dec 28, 2005
Posts: 263
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

Joined: Mar 06, 2001
Posts: 13459

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Access Database
 
Similar Threads
rs.next() always return true even no result is querried
Getting Table Name
JDBC
PostgreSQL jdbc driver Problem
ResultSet.TYPE_SCROLL_SENSITIVE