use of com.microsoft.sqlserver.testframework.DBConnection in project mssql-jdbc by Microsoft.
the class BulkCopyTestSetUp method setUpSourceTable.
/**
* Create source table needed for testing bulk copy
* @throws SQLException
*/
@BeforeAll
static void setUpSourceTable() throws SQLException {
try (DBConnection con = new DBConnection(connectionString);
DBStatement stmt = con.createStatement();
DBPreparedStatement pstmt = new DBPreparedStatement(con)) {
sourceTable = new DBTable(true);
stmt.createTable(sourceTable);
pstmt.populateTable(sourceTable);
}
}
use of com.microsoft.sqlserver.testframework.DBConnection in project mssql-jdbc by Microsoft.
the class bvtTest method testTwoResultsetsDifferentStmt.
/**
* Verify two concurrent resultsets from same connection, separate statements
*
* @throws SQLException
*/
@Test
public void testTwoResultsetsDifferentStmt() throws SQLException {
String query = "SELECT * FROM " + table1.getEscapedTableName();
String query2 = "SELECT * FROM " + table2.getEscapedTableName();
try (DBConnection conn = new DBConnection(connectionString);
DBStatement stmt1 = conn.createStatement();
DBStatement stmt2 = conn.createStatement()) {
DBResultSet rs1 = stmt1.executeQuery(query);
DBResultSet rs2 = stmt2.executeQuery(query2);
// Interleave resultset calls
rs1.next();
rs1.verifyCurrentRow(table1);
rs2.next();
rs2.verifyCurrentRow(table2);
rs1.next();
rs1.verifyCurrentRow(table1);
rs1.verify(table1);
rs1.close();
rs2.next();
rs2.verify(table2);
rs2.close();
}
}
use of com.microsoft.sqlserver.testframework.DBConnection in project mssql-jdbc by Microsoft.
the class bvtTest method terminate.
/**
* drops tables
*
* @throws SQLException
*/
@AfterAll
public static void terminate() throws SQLException {
try (DBConnection conn = new DBConnection(connectionString);
DBStatement stmt = conn.createStatement()) {
stmt.execute("if object_id('" + table1.getEscapedTableName() + "','U') is not null" + " drop table " + table1.getEscapedTableName());
stmt.execute("if object_id('" + table2.getEscapedTableName() + "','U') is not null" + " drop table " + table2.getEscapedTableName());
}
}
use of com.microsoft.sqlserver.testframework.DBConnection in project mssql-jdbc by Microsoft.
the class bvtTest method testCreatepreparedStatement.
/**
* Create a preparedStatement, call close
*
* @throws SQLException
*/
@Test
public void testCreatepreparedStatement() throws SQLException {
String colName = table1.getColumnName(7);
String value = table1.getRowData(7, 0).toString();
String query = "SELECT * from " + table1.getEscapedTableName() + " where [" + colName + "] = ? ";
try (DBConnection conn = new DBConnection(connectionString);
DBPreparedStatement pstmt = conn.prepareStatement(query)) {
pstmt.setObject(1, new BigDecimal(value));
DBResultSet rs = pstmt.executeQuery();
rs.verify(table1);
rs.close();
}
}
use of com.microsoft.sqlserver.testframework.DBConnection in project mssql-jdbc by Microsoft.
the class bvtTest method testStmtScrollSensitiveReadOnly.
/**
* Create a statement ResultSet.SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY, executeQuery verify cursor by using next and absolute and verify
* data
*
* @throws SQLException
*/
@Test
public void testStmtScrollSensitiveReadOnly() throws SQLException {
String query = "SELECT * FROM " + table1.getEscapedTableName();
try (DBConnection conn = new DBConnection(connectionString);
DBStatement stmt = conn.createStatement(DBResultSetTypes.TYPE_SCROLL_SENSITIVE_CONCUR_READ_ONLY);
DBResultSet rs = stmt.executeQuery(query)) {
rs.next();
rs.next();
rs.verifyCurrentRow(table1);
rs.absolute(3);
rs.verifyCurrentRow(table1);
rs.absolute(1);
rs.verify(table1);
}
}
Aggregations