List of usage examples for java.sql Connection commit
void commit() throws SQLException;
Connection
object. From source file:Main.java
public static void main(String[] args) throws Exception { Connection connection = null; connection.setAutoCommit(false);//from www .j ava 2 s . c om connection.commit(); }
From source file:com.xpfriend.fixture.runner.example.ExampleJob.java
/** * TEST_FB ???/* w w w .j a v a 2 s . c o m*/ * @param args 1:?ID?2:??NAME? */ public static void main(String[] args) throws Exception { if (args.length < 2) { throw new IllegalArgumentException("args.length == " + args.length); } int id = Integer.parseInt(args[0]); String name = args[1]; Connection connection = getConnection(); try { updateDatabase(id, name, connection); connection.commit(); } finally { connection.close(); } }
From source file:Main.java
public static void main(String[] argv) throws Exception { String driverName = "com.jnetdirect.jsql.JSQLDriver"; Class.forName(driverName);//ww w . j av a 2s . com String serverName = "127.0.0.1"; String portNumber = "1433"; String mydatabase = serverName + ":" + portNumber; String url = "jdbc:JSQLConnect://" + mydatabase; String username = "username"; String password = "password"; Connection connection = DriverManager.getConnection(url, username, password); // Disable auto commit connection.setAutoCommit(false); // Do SQL updates... // Commit updates connection.commit(); }
From source file:MainClass.java
public static void main(String[] args) throws Exception { Class.forName("COM.cloudscape.core.JDBCDriver").newInstance(); Connection conn = DriverManager.getConnection("jdbc:cloudscape:GAMETRADER"); conn.setAutoCommit(false);/*from w w w .j a v a 2 s . c om*/ Statement s = conn.createStatement(); s.executeUpdate("CREATE TABLE MANUALS(GAMEID INT, MANUAL LONG VARCHAR)"); conn.commit(); File file = new File("manuals.xml"); InputStream is = new FileInputStream(file); PreparedStatement ps = conn.prepareStatement("INSERT INTO MANUALS VALUES(?,?)"); ps.setInt(1, 1285757); ps.setAsciiStream(2, is, (int) file.length()); ps.execute(); conn.commit(); }
From source file:XMLDBDOM.java
public static void main(String[] args) throws Exception { Class.forName("COM.cloudscape.core.JDBCDriver").newInstance(); Connection conn = DriverManager.getConnection("jdbc:cloudscape:GAMETRADER"); conn.setAutoCommit(false);// w ww . j av a 2s .c o m Statement s = conn.createStatement(); s.executeUpdate("CREATE TABLE XMLData(GAMEID INT, MANUAL SERIALIZE(org.w3c.dom.Document))"); conn.commit(); File file = new File("XMLData.xml"); InputStream is = new FileInputStream(file); PreparedStatement ps = conn.prepareStatement("INSERT INTO XMLData VALUES(?,?)"); ps.setInt(1, 1285757); DOMParser parser = new DOMParser(); parser.parse("XMLData.xml"); Document manual = parser.getDocument(); ps.setObject(2, manual); ps.execute(); conn.commit(); }
From source file:Main.java
public static void main(String[] args) throws Exception { Connection conn = getConnection(); conn.setAutoCommit(false);//from w w w . j a v a 2 s . c om Statement st = conn.createStatement(); st.executeUpdate("create table survey (id int,myURL CHAR);"); String str = conn.nativeSQL("insert into survey(id) values(02)"); System.out.println(str); conn.commit(); st.close(); conn.close(); }
From source file:Main.java
public static void main(String[] args) throws Exception { Connection conn = getConnection(); conn.setAutoCommit(false);/*ww w . ja v a 2s . c om*/ Statement stmt = conn.createStatement(); stmt.executeUpdate("create table survey (id int, name CHAR(5) );"); stmt.executeUpdate("INSERT INTO survey(id, name)VALUES(111, '123456789')"); // since there were no errors, commit conn.commit(); ResultSet rs = stmt.executeQuery("SELECT * FROM survey"); outputResultSet(rs); rs.close(); stmt.close(); conn.close(); }
From source file:Main.java
public static void main(String[] args) throws Exception { Connection conn = getConnection(); conn.setAutoCommit(false);// w w w .java 2 s .c om Statement stmt = conn.createStatement(); stmt.executeUpdate("create table survey (id int, name CHAR(5) );"); stmt.executeUpdate("INSERT INTO survey(id, name)VALUES(111, '123456789')"); // since there were no errors, commit conn.commit(); ResultSet rs = stmt.executeQuery("SELECT * FROM survey"); outputResultSet(rs); stmt.executeUpdate("drop table survey"); rs.close(); stmt.close(); conn.close(); }
From source file:Main.java
public static void main(String[] argv) throws Exception { Class.forName("com.mysql.jdbc.Driver"); Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/jdbctutorial", "root", "root"); con.setAutoCommit(false);/*from ww w . j a v a 2s.c om*/ String table1 = "INSERT emp_sal VALUES('v',1200)"; String table2 = "DELETE FROM movies WHERE title = 'r'"; Statement st = con.createStatement(); st.addBatch(table1); st.addBatch(table2); int count[] = st.executeBatch(); con.commit(); con.close(); System.out.println("Successfully!"); }
From source file:jp.co.opentone.bsol.linkbinder.CorresponBodyUpdater.java
/** * @param args// w w w . j a v a2s.com */ public static void main(String[] args) throws Exception { Connection con = getConnection(); PreparedStatement stmt = null; boolean success = true; try { con.setAutoCommit(false); stmt = con.prepareStatement("UPDATE correspon SET body = ? WHERE id = ?"); execute(stmt); success = true; } finally { if (success) { con.commit(); } else { con.rollback(); } if (stmt != null) stmt.close(); con.close(); } }