Search in sources :

Example 21 with DBStatement

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

the class lobsTest method createTable.

private static DBTable createTable(DBTable table, String[] types, boolean populateTable) throws Exception {
    DBStatement stmt = new DBConnection(connectionString).createStatement();
    table = new DBTable(false);
    for (String type1 : types) {
        SqlType type = Utils.find(type1);
        table.addColumn(type);
    }
    stmt.createTable(table);
    if (populateTable) {
        stmt.populateTable(table);
    }
    stmt.close();
    return table;
}
Also used : DBConnection(com.microsoft.sqlserver.testframework.DBConnection) DBTable(com.microsoft.sqlserver.testframework.DBTable) DBStatement(com.microsoft.sqlserver.testframework.DBStatement) SqlType(com.microsoft.sqlserver.testframework.sqlType.SqlType)

Example 22 with DBStatement

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

the class BulkCopyTestUtil method performBulkCopy.

/**
 * @param bulkWrapper
 * @param srcData
 * @param dstTable
 */
static void performBulkCopy(BulkCopyTestWrapper bulkWrapper, ISQLServerBulkRecord srcData, DBTable dstTable) {
    try (DBConnection con = new DBConnection(bulkWrapper.getConnectionString());
        DBStatement stmt = con.createStatement();
        SQLServerBulkCopy bc = new SQLServerBulkCopy(bulkWrapper.getConnectionString())) {
        bc.setDestinationTableName(dstTable.getEscapedTableName());
        bc.writeToServer(srcData);
        validateValues(con, srcData, dstTable);
    } catch (Exception e) {
        fail(e.getMessage());
    }
}
Also used : DBConnection(com.microsoft.sqlserver.testframework.DBConnection) DBStatement(com.microsoft.sqlserver.testframework.DBStatement) SQLServerBulkCopy(com.microsoft.sqlserver.jdbc.SQLServerBulkCopy) SQLException(java.sql.SQLException)

Example 23 with DBStatement

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

the class bvtTestSetup method init.

@BeforeAll
public static void init() throws SQLException {
    try (DBConnection conn = new DBConnection(connectionString);
        DBStatement stmt = conn.createStatement()) {
        // create tables
        table1 = new DBTable(true);
        stmt.createTable(table1);
        stmt.populateTable(table1);
        table2 = new DBTable(true);
        stmt.createTable(table2);
        stmt.populateTable(table2);
    }
}
Also used : DBConnection(com.microsoft.sqlserver.testframework.DBConnection) DBTable(com.microsoft.sqlserver.testframework.DBTable) DBStatement(com.microsoft.sqlserver.testframework.DBStatement) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 24 with DBStatement

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

the class MergeTest method runTest.

/**
 * Merge test
 *
 * @throws Exception
 */
@Test
@DisplayName("Merge Test")
public void runTest() throws Exception {
    try (DBConnection conn = new DBConnection(connectionString)) {
        if (conn.getServerVersion() >= 10) {
            try (DBStatement stmt = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE)) {
                stmt.executeUpdate(setupTables);
                stmt.executeUpdate(mergeCmd2);
                int updateCount = stmt.getUpdateCount();
                assertEquals(updateCount, 3, "Received the wrong update count!");
            }
        }
    }
}
Also used : DBConnection(com.microsoft.sqlserver.testframework.DBConnection) DBStatement(com.microsoft.sqlserver.testframework.DBStatement) Test(org.junit.jupiter.api.Test) AbstractTest(com.microsoft.sqlserver.testframework.AbstractTest) DisplayName(org.junit.jupiter.api.DisplayName)

Aggregations

DBStatement (com.microsoft.sqlserver.testframework.DBStatement)24 DBConnection (com.microsoft.sqlserver.testframework.DBConnection)21 DBResultSet (com.microsoft.sqlserver.testframework.DBResultSet)15 Test (org.junit.jupiter.api.Test)12 DBTable (com.microsoft.sqlserver.testframework.DBTable)6 SQLException (java.sql.SQLException)6 ResultSet (java.sql.ResultSet)3 ResultSetMetaData (java.sql.ResultSetMetaData)3 SQLServerBulkCopy (com.microsoft.sqlserver.jdbc.SQLServerBulkCopy)2 AbstractTest (com.microsoft.sqlserver.testframework.AbstractTest)2 BeforeAll (org.junit.jupiter.api.BeforeAll)2 ColumnMap (com.microsoft.sqlserver.jdbc.bulkCopy.BulkCopyTestWrapper.ColumnMap)1 DBColumn (com.microsoft.sqlserver.testframework.DBColumn)1 DBPreparedStatement (com.microsoft.sqlserver.testframework.DBPreparedStatement)1 DBResultSetTypes (com.microsoft.sqlserver.testframework.DBResultSetTypes)1 SqlType (com.microsoft.sqlserver.testframework.sqlType.SqlType)1 BufferedInputStream (java.io.BufferedInputStream)1 InputStream (java.io.InputStream)1 Reader (java.io.Reader)1 Connection (java.sql.Connection)1