Code example for Statement

Methods: execute, executeQuery

0
        con3.setAutoCommit(false);
 
        //connection1.commit(); 
        Statement st = con3.createStatement();
 
        st.execute("DROP TABLE T IF EXISTS");
        st.execute("CREATE TABLE T (I INT)");
        st.execute("INSERT INTO T VALUES (2)");
 
        ResultSet rs = st.executeQuery("SELECT * FROM T");
 
        rs.next();
 
        int value = rs.getInt(1);
 
        con2.commit();
        con3.commit();
        con1.commit();
 
        rs = st.executeQuery("SELECT * FROM T");
 
        rs.next();
 
        if (value != rs.getInt(1)) {
            throw new Exception("value doesn't exist");