use of com.microsoft.sqlserver.testframework.DBConnection in project mssql-jdbc by Microsoft.
the class bvtTest method testStmtScrollInsensitiveReadOnly.
/**
* Create a statement, ResultSet.SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY, executeQuery verify cursor by using next, afterlast and previous
* and verify data
*
* @throws SQLException
* @throws ClassNotFoundException
*/
@Test
public void testStmtScrollInsensitiveReadOnly() throws SQLException, ClassNotFoundException {
try (DBConnection conn = new DBConnection(connectionString);
DBStatement stmt = conn.createStatement(DBResultSetTypes.TYPE_SCROLL_INSENSITIVE_CONCUR_READ_ONLY);
DBResultSet rs = stmt.selectAll(table1)) {
rs.next();
rs.verifyCurrentRow(table1);
rs.afterLast();
rs.previous();
rs.verifyCurrentRow(table1);
rs.verify(table1);
}
}
use of com.microsoft.sqlserver.testframework.DBConnection in project mssql-jdbc by Microsoft.
the class bvtTest method testStmtScrollSensitiveUpdatable.
/**
* Create a statement ResultSet.SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE, executeQuery verify cursor by using next and previous and verify
* data
*
* @throws SQLException
*/
@Test
public void testStmtScrollSensitiveUpdatable() throws SQLException {
String query = "SELECT * FROM " + table1.getEscapedTableName();
try (DBConnection conn = new DBConnection(connectionString);
DBStatement stmt = conn.createStatement(DBResultSetTypes.TYPE_SCROLL_SENSITIVE_CONCUR_UPDATABLE);
DBResultSet rs = stmt.executeQuery(query)) {
// Verify resultset behavior
rs.next();
rs.next();
rs.verifyCurrentRow(table1);
rs.absolute(3);
rs.verifyCurrentRow(table1);
rs.absolute(1);
rs.verify(table1);
}
}
use of com.microsoft.sqlserver.testframework.DBConnection in project mssql-jdbc by Microsoft.
the class bvtTest method testStmtForwardOnlyUpdateable.
/**
* Create a statement ResultSet.Type_forward_only, ResultSet.CONCUR_UPDATABLE, executeQuery verify cursor by using next and previous and verify
* data
*
* @throws SQLException
*/
@Test
public void testStmtForwardOnlyUpdateable() throws SQLException {
String query = "SELECT * FROM " + table1.getEscapedTableName();
try (DBConnection conn = new DBConnection(connectionString);
DBStatement stmt = conn.createStatement(DBResultSetTypes.TYPE_FORWARD_ONLY_CONCUR_UPDATABLE);
DBResultSet rs = stmt.executeQuery(query)) {
rs.next();
// Verify resultset behavior
rs.next();
rs.verifyCurrentRow(table1);
rs.next();
rs.verifyCurrentRow(table1);
try {
rs.previous();
assertTrue(false, "Previous should have thrown an exception");
} catch (SQLException ex) {
// expected exception
}
rs.verify(table1);
}
}
use of com.microsoft.sqlserver.testframework.DBConnection in project mssql-jdbc by Microsoft.
the class bvtTest method testResultSetAndCloseStmt.
/**
* Verify resultset closed after statement is closed
*
* @throws SQLException
*/
@Test
public void testResultSetAndCloseStmt() throws SQLException {
String query = "SELECT * FROM " + table1.getEscapedTableName();
try (DBConnection conn = new DBConnection(connectionString);
DBStatement stmt = conn.createStatement();
DBResultSet rs = stmt.executeQuery(query)) {
// this should close the resultSet
stmt.close();
try {
rs.next();
} catch (SQLException e) {
assertEquals(e.toString(), "com.microsoft.sqlserver.jdbc.SQLServerException: The result set is closed.");
}
assertTrue(true, "Previous one should have thrown exception!");
}
}
use of com.microsoft.sqlserver.testframework.DBConnection in project mssql-jdbc by Microsoft.
the class bvtTest method testStmtForwardOnlyReadOnly.
/**
* Create a statement ResultSet.Type_forward_only, ResultSet.CONCUR_READ_ONLY, executeQuery verify cursor by using next and previous and verify
* data
*
* @throws SQLException
* @throws ClassNotFoundException
*/
@Test
public void testStmtForwardOnlyReadOnly() throws SQLException, ClassNotFoundException {
String query = "SELECT * FROM " + table1.getEscapedTableName();
try (DBConnection conn = new DBConnection(connectionString);
DBStatement stmt = conn.createStatement(DBResultSetTypes.TYPE_FORWARD_ONLY_CONCUR_READ_ONLY);
DBResultSet rs = stmt.executeQuery(query)) {
rs.next();
rs.verifyCurrentRow(table1);
rs.next();
rs.verifyCurrentRow(table1);
try {
rs.previous();
assertTrue(false, "Previous should have thrown an exception");
} catch (SQLException ex) {
// expected exception
}
rs.verify(table1);
}
}
Aggregations