Package java.sql

Examples of java.sql.Savepoint


     * test 6a - create a savepoint release it and then create another with the
     * same name. and release the first one
     */
    public void testReleaseReleasedSavepoint() throws SQLException {
        Connection con = getConnection();
        Savepoint savepoint1 = con.setSavepoint("s1");
        con.releaseSavepoint(savepoint1);
        // The following savepoint was earlier named s1. Changed it to s2 while
        // working on DRDA support
        // for savepoints. The reason for that is as follows
        // The client translates all savepoint jdbc calls to equivalent sql and
View Full Code Here


     * test 6b - create a savepoints release it and then create another with the
     * same name. and rollback the first one
     */
    public void testRollbackReleasedSavepoint() throws SQLException {
        Connection con = getConnection();
        Savepoint savepoint1 = con.setSavepoint("s1");
        con.releaseSavepoint(savepoint1);
        // The following savepoint was earlier named s1. Changed it to s2 while
        // working on DRDA support
        // for savepoints. The reason for that is as follows
        // The client translates all savepoint jdbc calls to equivalent sql and
View Full Code Here

     * System.out.println("Expected Exception is " + se.getMessage()); }
     * con2.commit();
     */
    public void testReleaseSavepointFromOtherTransaction() throws SQLException {
        Connection con = getConnection();
        Savepoint savepoint1 = con.setSavepoint("s1");
        Statement s = createStatement();
        s.executeUpdate("INSERT INTO T1 VALUES(2,1)");
        Connection con2 = openDefaultConnection();
        try {
            con2.releaseSavepoint(savepoint1);
View Full Code Here

    public void testSwapSavepointsAcrossConnectionAndRelease()
            throws SQLException {
        Connection con = getConnection();
        Connection con2 = openDefaultConnection();
        con2.setAutoCommit(false);
        Savepoint savepoint1 = con2.setSavepoint("s1");
        Statement s = createStatement();
        s.executeUpdate("INSERT INTO T1 VALUES(2,1)");
        con.setSavepoint("s1");
        try {
            con.releaseSavepoint(savepoint1);
View Full Code Here

    public void testSwapSavepointsAcrossConnectionsAndRollback()
            throws SQLException {
        Connection con = getConnection();
        Connection con2 = openDefaultConnection();
        con2.setAutoCommit(false);
        Savepoint savepoint1 = con2.setSavepoint("s1");
        Statement s = createStatement();
        s.executeUpdate("INSERT INTO T1 VALUES(2,1)");
        con.setSavepoint("s1");
        try {
            con.rollback(savepoint1);
View Full Code Here

    /**
     * Test 9 test savepoint name and verify case sensitivity
     */
    public void testSavepointName() throws SQLException {
        Connection con = getConnection();
        Savepoint savepoint1 = con.setSavepoint("myname");
        String savepointName = savepoint1.getSavepointName();
        assertEquals(savepointName, "myname");
        con.rollback();
    }
View Full Code Here

    /**
     * Test 10 test savepoint name case sensitivity
     */
    public void testNameCaseSensitivity() throws SQLException {
        Connection con = getConnection();
        Savepoint savepoint1 = con.setSavepoint("MyName");
        String savepointName = savepoint1.getSavepointName();
        assertEquals(savepointName, "MyName");
        con.rollback();
    }
View Full Code Here

    /**
     * Test 11 rolling back a savepoint multiple times - should work
     */
    public void testRollbackMultipleTimes() throws SQLException {
        Connection con = getConnection();
        Savepoint savepoint1 = con.setSavepoint("MyName");
        con.rollback(savepoint1);
        con.rollback(savepoint1);
        con.rollback();
    }
View Full Code Here

    /**
     * Test 12 releasing a savepoint multiple times - should not work
     */
    public void testReleaseMultipleTimes() throws SQLException {
        Connection con = getConnection();
        Savepoint savepoint1 = con.setSavepoint("MyName");
        con.releaseSavepoint(savepoint1);
        try {
            con.releaseSavepoint(savepoint1);
            fail("FAIL 12 releasing a savepoint multiple times should fail");
        } catch (SQLException se) {
View Full Code Here

     * after setting autocommit on and off
     */
    public void testSavepointFromEarlierTransactionAfterToggleAutocommit()
            throws SQLException {
        Connection con = getConnection();
        Savepoint savepoint1 = con.setSavepoint("MyName");
        con.setAutoCommit(true);
        con.setAutoCommit(false);
        Savepoint savepoint2 = con.setSavepoint("MyName1");
        try {// shouldn't be able to use savepoint from earlier tranasaction
            // after setting autocommit on and off
            con.releaseSavepoint(savepoint1);
            fail("FAIL 13 shouldn't be able to use a savepoint from earlier "
                    + "transaction after setting autocommit on and off");
View Full Code Here

TOP

Related Classes of java.sql.Savepoint

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.