import java.sql.*;    import java.io.FileInputStream;   import java.util.Properties;
class JdbcTransactions {
public static void main (String args []) throws Exception {
  DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
  Properties props = new Properties();
  props.load(new FileInputStream("conn.props"));
  Connection conn1 = DriverManager.getConnection(props.getProperty("url"), props);
  conn1.setAutoCommit(false);
  Statement stmt1 = conn1.createStatement();
  stmt1.execute("DROP TABLE TTEST");
  stmt1.execute("CREATE TABLE TTEST(A VARCHAR2(4))");
  stmt1.execute("INSERT INTO TTEST VALUES('1BLA')");
  stmt1.execute("COMMIT");  conn1.commit();      // choose one to show which works
  System.out.println ("select from conn1:");
  ResultSet rset1 = stmt1.executeQuery("SELECT A FROM TTEST");
  while (rset1.next()) { String s = rset1.getString(1);  System.out.println (s); }

  Connection conn2 = DriverManager.getConnection(props.getProperty("url"), props);
  Statement stmt2 = conn2.createStatement();
  stmt2.execute("INSERT INTO TTEST VALUES('2FOO')");
  System.out.println ("select from conn2:");
  ResultSet rset2 = stmt2.executeQuery("SELECT A FROM TTEST");
  while (rset2.next()) { String s = rset2.getString(1); System.out.println (s); }
  conn1.close(); conn2.close();  } }
