use of com.microsoft.sqlserver.jdbc.ISQLServerConnection in project mssql-jdbc by Microsoft.
the class ConnectionDriverTest method testIsWrapperFor.
@Test
public void testIsWrapperFor() throws SQLException, ClassNotFoundException {
try (Connection conn = DriverManager.getConnection(connectionString);
SQLServerConnection ssconn = (SQLServerConnection) conn) {
boolean isWrapper;
isWrapper = ssconn.isWrapperFor(ssconn.getClass());
assertTrue(isWrapper, "SQLServerConnection supports unwrapping");
assertEquals(ssconn.TRANSACTION_SNAPSHOT, ssconn.TRANSACTION_SNAPSHOT, "Cant access the TRANSACTION_SNAPSHOT ");
isWrapper = ssconn.isWrapperFor(Class.forName("com.microsoft.sqlserver.jdbc.ISQLServerConnection"));
assertTrue(isWrapper, "ISQLServerConnection supports unwrapping");
ISQLServerConnection iSql = (ISQLServerConnection) ssconn.unwrap(Class.forName("com.microsoft.sqlserver.jdbc.ISQLServerConnection"));
assertEquals(iSql.TRANSACTION_SNAPSHOT, iSql.TRANSACTION_SNAPSHOT, "Cant access the TRANSACTION_SNAPSHOT ");
ssconn.unwrap(Class.forName("java.sql.Connection"));
}
}
use of com.microsoft.sqlserver.jdbc.ISQLServerConnection in project mssql-jdbc by Microsoft.
the class PoolingTest method testConnectionPoolClientConnectionId.
@Test
public void testConnectionPoolClientConnectionId() throws SQLException {
SQLServerXADataSource ds = new SQLServerXADataSource();
ds.setURL(connectionString);
PooledConnection pc = ds.getPooledConnection();
ISQLServerConnection con = (ISQLServerConnection) pc.getConnection();
UUID Id1 = con.getClientConnectionId();
assertTrue(Id1 != null, "Unexecepted: ClientConnectionId is null from Pool");
con.close();
// now reget the connection
ISQLServerConnection con2 = (ISQLServerConnection) pc.getConnection();
UUID Id2 = con2.getClientConnectionId();
con2.close();
assertEquals(Id1, Id2, "ClientConnection Ids from pool are not the same.");
}
Aggregations