aspose file tools*
The moose likes JDBC and the fly likes What's the problem(about update)? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "What Watch "What New topic
Author

What's the problem(about update)?

Crazyworm LovelyWorm
Greenhorn

Joined: Apr 26, 2002
Posts: 9
//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.
Crazyworm LovelyWorm
Greenhorn

Joined: Apr 26, 2002
Posts: 9
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?
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

"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
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

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.
Crazyworm LovelyWorm
Greenhorn

Joined: Apr 26, 2002
Posts: 9
Thanks!
Jessica Sant
Sheriff

Joined: Oct 17, 2001
Posts: 4313

"CrazyWorm Lovely Worm"
This is your 3rd and final warning -- if you do not change your displayed name to conform to the JavaRanch Naming Policy, your account will be disabled.
(1st warning, 2nd warning)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What's the problem(about update)?
 
Similar Threads
5 INSERT but only 4 in my access table
DataBase drivers in Linux
Help with my homework please
how to run code in netbeans
Auto Increment ID Field Table in the Oracle Database