- con = DriverManager.getConnection("jdbc:mysql:///jk","rjk", "sivaji");
-
con.setAutoCommit(false);
-
java.sql.Statement stmt = con.createStatement();
-
stmt.executeUpdate("INSERT INTO jk1(fname, lname) VALUES('a', 'b')");
-
stmt.executeUpdate("INSERT INTO jk1(fname, lname) VALUES('c', 'd')");
-
con.rollback();
-
stmt.executeUpdate("INSERT INTO jk1(fname, lname) VALUES('x', 'y')");
-
con.commit();
By ths code the records containing values a,b and c,d should nt be saved bt the record containing x,y should be saved...bt all the three records r getting saved...Pls help....
--------------------------------------------------------------------------------
4 6027
con = DriverManager.getConnection("jdbc:mysql:///jk","rjk", "sivaji");
con.setAutoCommit(false);
java.sql.Statement stmt = con.createStatement();
stmt.executeUpdate("INSERT INTO jk1(fname, lname) VALUES('a', 'b')");
stmt.executeUpdate("INSERT INTO jk1(fname, lname) VALUES('c', 'd')");
con.rollback();
stmt.executeUpdate("INSERT INTO jk1(fname, lname) VALUES('x', 'y')");
con.commit();
By ths code the records containing values a,b and c,d should nt be saved bt the record containing x,y should be saved...bt all the three records r getting saved...Pls help....
--------------------------------------------------------------------------------
Please do not double post.
Heya, Jith.
Please use CODE tags when posting source code:
[CODE=java]
Java code goes here.
[/CODE]
- con = DriverManager.getConnection("jdbc:mysql:///jk","rjk", "sivaji");
-
con.setAutoCommit(false);
-
java.sql.Statement stmt = con.createStatement();
-
stmt.executeUpdate("INSERT INTO jk1(fname, lname) VALUES('a', 'b')");
-
stmt.executeUpdate("INSERT INTO jk1(fname, lname) VALUES('c', 'd')");
-
con.rollback();
-
stmt.executeUpdate("INSERT INTO jk1(fname, lname) VALUES('x', 'y')");
-
con.commit();
By ths code the records containing values a,b and c,d should nt be saved bt the record containing x,y should be saved...bt all the three records r getting saved...Pls help....
--------------------------------------------------------------------------------
Check your table type. You must use the innodb engine: - CREATE TABLE `database_name`.`table_name` (
-
`itemID` int(10) unsigned NOT NULL auto_increment,
-
PRIMARY KEY (`itemID`)
-
) ENGINE=InnoDB;
Check your table type. You must use the innodb engine: - CREATE TABLE `database_name`.`table_name` (
-
`itemID` int(10) unsigned NOT NULL auto_increment,
-
PRIMARY KEY (`itemID`)
-
) ENGINE=InnoDB;
Even then, he creates the connection with the database after setting autoCommit to false. A newly created connection has autoCommit set to true by default so the setAutoCommit(false) at the top there is just useless. He should set autoCommit(false) after creating the connection.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: mdh |
last post by:
I am trying to learn the basics of MVC applications using a Tomcat
infrastructure. I'm starting by building a simple application with:
* a login.jsp page for a basic login form with a action...
|
by: Monica Ferrero |
last post by:
Hi!
I'm not sure if this is the most adequate mySQL list for this post. If not,
please indicat me which one I should use...
I'm using Tomcat 4.1.24 with Apache 2 and MySQL 4.0.13. I have the...
|
by: Jerry Weinstein |
last post by:
Hi,
I know about stored procedures and that they can speed up data entry via the
SQL 'insert ' statement.
However, one drawback to this method is that using the stored procedure
still requires...
|
by: sridhar nagabhurshana |
last post by:
hello
I am trying to connect to mysql database using connector/J jdbc driver
this is my code
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
|
by: Ugrasena via DBMonster.com |
last post by:
Hi team i am using DB2 7.2 on Windows2000.
We have lot many SQL Procedure Calls, is there any way i can Turn off the
Auto Commit on that Database, the Problem i have is many of our Application...
|
by: cwho.work |
last post by:
Hi!
We are using apache ibatis with our MySQL 5.0 database (using innodb
tables), in our web application running on Tomcat 5. Recently we
started getting a number of errors relating to...
|
by: oll3i |
last post by:
my librarybean
package library.ejb;
import java.sql.*;
import javax.ejb.*;
import library.common.*;
@Stateless @Remote
|
by: jith87 |
last post by:
con = DriverManager.getConnection("jdbc:mysql:///jk","rjk", "sivaji");
con.setAutoCommit(false);
java.sql.Statement stmt = con.createStatement();
stmt.executeUpdate("INSERT INTO jk1(fname, lname)...
|
by: Anonymous |
last post by:
I resolved this issue.
If you are using an Oracle XA DataSource, Oracle's JDBC driver
will automatically issue a COMMIT when it sees a "DROP TABLE foobar"
statement.
Oracle's JDBC driver...
|
by: Zunil |
last post by:
Hi All,
We are testing one of our component with JDBC + DB2 using db2jcc
driver. We afced a strange issue.
Scenario is like this.
1. We insert 1 record to a table having IDENTITY column as the...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |