Search in sources :

Example 6 with SQLServerXADataSource

use of com.microsoft.sqlserver.jdbc.SQLServerXADataSource in project mssql-jdbc by Microsoft.

the class NativeMSSQLDataSourceTest method testInterfaceWrapping.

@Test
public void testInterfaceWrapping() throws ClassNotFoundException, SQLException {
    SQLServerDataSource ds = new SQLServerDataSource();
    assertEquals(true, ds.isWrapperFor(Class.forName("com.microsoft.sqlserver.jdbc.ISQLServerDataSource")));
    assertEquals(true, ds.isWrapperFor(Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDataSource")));
    assertEquals(true, ds.isWrapperFor(Class.forName("javax.sql.CommonDataSource")));
    ISQLServerDataSource ids = (ISQLServerDataSource) (ds.unwrap(Class.forName("com.microsoft.sqlserver.jdbc.ISQLServerDataSource")));
    ids.setApplicationName("AppName");
    SQLServerConnectionPoolDataSource poolDS = new SQLServerConnectionPoolDataSource();
    assertEquals(true, poolDS.isWrapperFor(Class.forName("com.microsoft.sqlserver.jdbc.ISQLServerDataSource")));
    assertEquals(true, poolDS.isWrapperFor(Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDataSource")));
    assertEquals(true, poolDS.isWrapperFor(Class.forName("com.microsoft.sqlserver.jdbc.SQLServerConnectionPoolDataSource")));
    assertEquals(true, poolDS.isWrapperFor(Class.forName("javax.sql.CommonDataSource")));
    ISQLServerDataSource ids2 = (ISQLServerDataSource) (poolDS.unwrap(Class.forName("com.microsoft.sqlserver.jdbc.ISQLServerDataSource")));
    ids2.setApplicationName("AppName");
    SQLServerXADataSource xaDS = new SQLServerXADataSource();
    assertEquals(true, xaDS.isWrapperFor(Class.forName("com.microsoft.sqlserver.jdbc.ISQLServerDataSource")));
    assertEquals(true, xaDS.isWrapperFor(Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDataSource")));
    assertEquals(true, xaDS.isWrapperFor(Class.forName("com.microsoft.sqlserver.jdbc.SQLServerConnectionPoolDataSource")));
    assertEquals(true, xaDS.isWrapperFor(Class.forName("com.microsoft.sqlserver.jdbc.SQLServerXADataSource")));
    assertEquals(true, xaDS.isWrapperFor(Class.forName("javax.sql.CommonDataSource")));
    ISQLServerDataSource ids3 = (ISQLServerDataSource) (xaDS.unwrap(Class.forName("com.microsoft.sqlserver.jdbc.ISQLServerDataSource")));
    ids3.setApplicationName("AppName");
}
Also used : SQLServerConnectionPoolDataSource(com.microsoft.sqlserver.jdbc.SQLServerConnectionPoolDataSource) ISQLServerDataSource(com.microsoft.sqlserver.jdbc.ISQLServerDataSource) SQLServerDataSource(com.microsoft.sqlserver.jdbc.SQLServerDataSource) ISQLServerDataSource(com.microsoft.sqlserver.jdbc.ISQLServerDataSource) SQLServerXADataSource(com.microsoft.sqlserver.jdbc.SQLServerXADataSource) Test(org.junit.jupiter.api.Test) AbstractTest(com.microsoft.sqlserver.testframework.AbstractTest)

Example 7 with SQLServerXADataSource

use of com.microsoft.sqlserver.jdbc.SQLServerXADataSource in project mssql-jdbc by Microsoft.

the class NativeMSSQLDataSourceTest method testNativeMSSQLDataSource.

@Test
public void testNativeMSSQLDataSource() throws SQLException {
    SQLServerXADataSource ds = new SQLServerXADataSource();
    ds.setLastUpdateCount(true);
    assertTrue(ds.getLastUpdateCount());
}
Also used : SQLServerXADataSource(com.microsoft.sqlserver.jdbc.SQLServerXADataSource) Test(org.junit.jupiter.api.Test) AbstractTest(com.microsoft.sqlserver.testframework.AbstractTest)

Aggregations

SQLServerXADataSource (com.microsoft.sqlserver.jdbc.SQLServerXADataSource)7 AbstractTest (com.microsoft.sqlserver.testframework.AbstractTest)7 Test (org.junit.jupiter.api.Test)7 ISQLServerConnection (com.microsoft.sqlserver.jdbc.ISQLServerConnection)5 PooledConnection (javax.sql.PooledConnection)5 DBConnection (com.microsoft.sqlserver.testframework.DBConnection)4 Connection (java.sql.Connection)4 ISQLServerDataSource (com.microsoft.sqlserver.jdbc.ISQLServerDataSource)1 SQLServerConnectionPoolDataSource (com.microsoft.sqlserver.jdbc.SQLServerConnectionPoolDataSource)1 SQLServerDataSource (com.microsoft.sqlserver.jdbc.SQLServerDataSource)1 PreparedStatement (java.sql.PreparedStatement)1 SQLException (java.sql.SQLException)1 Statement (java.sql.Statement)1 UUID (java.util.UUID)1