use of com.microsoft.sqlserver.jdbc.SQLServerConnection in project mssql-jdbc by Microsoft.
the class ConnectionDriverTest method testAbort.
@Test
public void testAbort() throws SQLException {
SQLServerConnection conn = (SQLServerConnection) DriverManager.getConnection(connectionString);
Executor executor = Executors.newFixedThreadPool(2);
conn.abort(executor);
}
use of com.microsoft.sqlserver.jdbc.SQLServerConnection 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.SQLServerConnection in project mssql-jdbc by Microsoft.
the class ConnectionDriverTest method testClosedConnection.
@Test
public void testClosedConnection() throws SQLException {
SQLServerConnection conn = (SQLServerConnection) DriverManager.getConnection(connectionString);
conn.close();
assertTrue(!conn.isValid(0), "Closed connection should be invalid");
}
use of com.microsoft.sqlserver.jdbc.SQLServerConnection in project mssql-jdbc by Microsoft.
the class ConnectionDriverTest method testDeadConnection.
@Test
public void testDeadConnection() throws SQLException {
assumeTrue(!DBConnection.isSqlAzure(DriverManager.getConnection(connectionString)), "Skipping test case on Azure SQL.");
try (SQLServerConnection conn = (SQLServerConnection) DriverManager.getConnection(connectionString + ";responseBuffering=adaptive")) {
Statement stmt = null;
String tableName = RandomUtil.getIdentifier("Table");
tableName = DBTable.escapeIdentifier(tableName);
conn.setAutoCommit(false);
stmt = conn.createStatement();
stmt.executeUpdate("CREATE TABLE " + tableName + " (col1 int primary key)");
for (int i = 0; i < 80; i++) {
stmt.executeUpdate("INSERT INTO " + tableName + "(col1) values (" + i + ")");
}
conn.commit();
try {
stmt.execute("SELECT x1.col1 as foo, x2.col1 as bar, x1.col1 as eeep FROM " + tableName + " as x1, " + tableName + " as x2; RAISERROR ('Oops', 21, 42) WITH LOG");
} catch (SQLException e) {
assertEquals(e.getMessage(), "Connection reset", "Unknown Exception");
} finally {
DriverManager.getConnection(connectionString).createStatement().execute("drop table " + tableName);
}
assertEquals(conn.isValid(5), false, "Dead connection should be invalid");
}
}
use of com.microsoft.sqlserver.jdbc.SQLServerConnection in project mssql-jdbc by Microsoft.
the class ConnectionDriverTest method testGetSchema.
@Test
public void testGetSchema() throws SQLException {
SQLServerConnection conn = (SQLServerConnection) DriverManager.getConnection(connectionString);
conn.getSchema();
}
Aggregations