import java.sql.*;

public class d638_repro3{
    public static void main(String[] args){
        
        try {
            
            Connection conn = null;
            if ((args.length > 0) && args[0].equalsIgnoreCase("client")) {
                Class.forName("org.apache.derby.jdbc.ClientDriver").newInstance();
                conn = DriverManager.getConnection("jdbc:derby://localhost:1528/testdb;create=true","testusr","testpwd");
            }
            else {
                Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
                conn = DriverManager.getConnection("jdbc:derby:testdb;create=true;user=testusr;password=testpwd");
            }
            
            Statement stmt1= conn.createStatement();
            
            try{ stmt1.executeUpdate("drop table test_tab"); } catch (SQLException sqle) { }
            
            Statement stmt2 = conn.createStatement();
            stmt2.executeUpdate("CREATE TABLE test_tab(id int)");

            conn.setAutoCommit(false);
            stmt2.executeUpdate("INSERT INTO test_tab values (1)");
            conn.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
            conn.rollback();
            ResultSet rs = stmt2.executeQuery("select count(*) from test_tab");
            rs.next();
            System.out.println("test_tab has " + rs.getInt(1) + " rows");

        }catch(Exception e){
            System.out.println("Unexpected exception");
            e.printStackTrace();
        }
        
    }
}
