Search in sources :

Example 1 with DalConnection

use of com.ctrip.platform.dal.dao.client.DalConnection in project dal by ctripcorp.

the class DalConnectionTest method testClose.

@Test
public void testClose() throws SQLException {
    Connection conn = null;
    try {
        DalConnection test = getConnection();
        Statement statement = test.getConn().createStatement();
        ResultSet rs = statement.executeQuery("select * from " + SqlServerTestInitializer.TABLE_NAME);
        rs.next();
        conn = test.getConn();
        test.close();
        assertTrue(conn.isClosed());
    } catch (Throwable e) {
        fail();
        e.printStackTrace();
    } finally {
        if (conn != null)
            conn.close();
    }
}
Also used : DalConnection(com.ctrip.platform.dal.dao.client.DalConnection) Statement(java.sql.Statement) Connection(java.sql.Connection) DalConnection(com.ctrip.platform.dal.dao.client.DalConnection) ResultSet(java.sql.ResultSet) Test(org.junit.Test)

Example 2 with DalConnection

use of com.ctrip.platform.dal.dao.client.DalConnection in project dal by ctripcorp.

the class DalConnectionTest method testDalConnection.

@Test
public void testDalConnection() throws SQLException {
    Connection conn = null;
    try {
        DalConnection test = getConnection();
        assertNotNull(test);
    } catch (Throwable e) {
        fail();
        e.printStackTrace();
    } finally {
        if (conn != null)
            conn.close();
    }
}
Also used : DalConnection(com.ctrip.platform.dal.dao.client.DalConnection) Connection(java.sql.Connection) DalConnection(com.ctrip.platform.dal.dao.client.DalConnection) Test(org.junit.Test)

Example 3 with DalConnection

use of com.ctrip.platform.dal.dao.client.DalConnection in project dal by ctripcorp.

the class DalConnectionTest method testGetConn.

@Test
public void testGetConn() throws SQLException {
    Connection conn = null;
    try {
        DalConnection test = getConnection();
        assertNotNull(test.getConn());
    } catch (Throwable e) {
        fail();
        e.printStackTrace();
    } finally {
        if (conn != null)
            conn.close();
    }
}
Also used : DalConnection(com.ctrip.platform.dal.dao.client.DalConnection) Connection(java.sql.Connection) DalConnection(com.ctrip.platform.dal.dao.client.DalConnection) Test(org.junit.Test)

Example 4 with DalConnection

use of com.ctrip.platform.dal.dao.client.DalConnection in project dal by ctripcorp.

the class DalConnectionTest method testGetCatalog.

@Test
public void testGetCatalog() throws SQLException {
    Connection conn = null;
    try {
        DalConnection test = getConnection();
        assertNotNull(test.getDatabaseName());
    } catch (Throwable e) {
        fail();
        e.printStackTrace();
    } finally {
        if (conn != null)
            conn.close();
    }
}
Also used : DalConnection(com.ctrip.platform.dal.dao.client.DalConnection) Connection(java.sql.Connection) DalConnection(com.ctrip.platform.dal.dao.client.DalConnection) Test(org.junit.Test)

Example 5 with DalConnection

use of com.ctrip.platform.dal.dao.client.DalConnection in project dal by ctripcorp.

the class DalConnectionTest method testGetMeta.

@Test
public void testGetMeta() throws SQLException {
    Connection conn = null;
    try {
        DalConnection test = getConnection();
        assertNotNull(test.getMeta());
        LogEntry entry = new LogEntry();
        assertNotNull(test.getMeta());
        test.getMeta().populate(entry);
        assertNotNull(test.getMeta());
    } catch (Throwable e) {
        fail();
        e.printStackTrace();
    } finally {
        if (conn != null)
            conn.close();
    }
}
Also used : DalConnection(com.ctrip.platform.dal.dao.client.DalConnection) Connection(java.sql.Connection) DalConnection(com.ctrip.platform.dal.dao.client.DalConnection) LogEntry(com.ctrip.platform.dal.dao.client.LogEntry) Test(org.junit.Test)

Aggregations

DalConnection (com.ctrip.platform.dal.dao.client.DalConnection)14 Connection (java.sql.Connection)10 Test (org.junit.Test)10 PooledConnection (org.apache.tomcat.jdbc.pool.PooledConnection)3 DalHints (com.ctrip.platform.dal.dao.DalHints)2 DalException (com.ctrip.platform.dal.exceptions.DalException)2 SQLException (java.sql.SQLException)2 DalConnectionManager (com.ctrip.platform.dal.dao.client.DalConnectionManager)1 DbMeta (com.ctrip.platform.dal.dao.client.DbMeta)1 LogEntry (com.ctrip.platform.dal.dao.client.LogEntry)1 ResultSet (java.sql.ResultSet)1 Statement (java.sql.Statement)1