//create table coffees query = "create table coffees(cof_name varchar(32)," + "sup_id integer," + "price float," + "sales integer," + "total integer)"; //Insert data into table coffees 1) stmt.executeUpdate("insert into coffees values('French_Rost',49,8.99,0,0)"); 2) stmt.executeUpdate("insert into coffees values('Espresso',150,9.99,0,0)"); 3) stmt.executeUpdate("insert into coffees values('Columbian_Decaf',101,8.99,0,0)"); 4) stmt.executeUpdate("insert into coffees values('Columbian',101,7.99,0,0)"); 5) stmt.executeUpdate("insert into coffees values('French_Rost_Decaf',49,9.99,0,0)"); statement 1),2),3) can execute success, three record been inserted into database. And statement 4),5) return value is 1, but no data be insert into database. What is the problem? What cause this problem? thanks! [ Edited by Dave to remove special characters ] [ June 16, 2002: Message edited by: David O'Meara ]
Rome was not built in a day.
Joined: Apr 26, 2002
One error on above post. the statement 4) will influence the database, only the last statement 5) does not influence the database. I find the answer. The last statement will do nothing if the Connection don't close. After close the Connection, the result of last statement will influence to database. So I have another question: Why Connection must be close? And why can last statement only not influence the database?
"Crazyworm lovely worm", The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp. We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please edit your profile and select a new name which meets the requirements. Thanks. Dave ps We don't just recommend you use your real name, we try to enforce it to the best of our ability, and 'Crazyworm lovely worm' won't cut it
This is a known problem with the JDBC-ODBC bridge and there are basically three solutions. You found one, which is to close the connection. The other is to make a 'dummy select' after an insert or update. It appears that the driver holds onto one query so you need to do one more to get it pushed out. The real solution is to not use the JDBC-ODBC bridge and to use a 'real' database (other than MS Access) and the specific drivers for it. On a side note, I've never had this problem, but I always use setAutocommit( true ) when dealing with Access, but it isn't that often. Dave.