Code example for Connection

Methods: createStatementgetAutoCommit

0
    } 
 
    protected static void checkDataSourceOk(String name, boolean autocommit) throws Exception {
        DataSource ds = DataSourceHelper.getDataSource(name);
        Connection conn = ds.getConnection();
        assertEquals(autocommit, conn.getAutoCommit());
        Statement st = conn.createStatement();
        ResultSet rs = st.executeQuery("SELECT 123");
        assertNotNull(rs);
        assertTrue(rs.next());
        assertEquals(123, rs.getInt(1));
        st.close();
        conn.close();
    } 
 
    @Test 
    public void testNonXANoTM() throws Exception { 
        deployContrib(TEST_BUNDLE, DATASOURCE_CONTRIB);
        checkDataSourceOk("foo", true); 
        checkDataSourceOk("alias", true); 
Experience pair programming with AI  Get Codota for Java