Search in sources :

Example 31 with DBConnection

use of com.microsoft.sqlserver.testframework.DBConnection 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 32 with DBConnection

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

the class BulkCopyCSVTest method setUpConnection.

/**
 * Create connection, statement and generate path of resource file
 */
@BeforeAll
static void setUpConnection() {
    con = new DBConnection(connectionString);
    stmt = con.createStatement();
    filePath = Utils.getCurrentClassPath();
}
Also used : DBConnection(com.microsoft.sqlserver.testframework.DBConnection) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 33 with DBConnection

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

the class WrapperTest method isKatmaiServer.

private static boolean isKatmaiServer() throws Exception {
    DBConnection conn = new DBConnection(connectionString);
    double version = conn.getServerVersion();
    conn.close();
    return ((version >= 10.0) ? true : false);
}
Also used : DBConnection(com.microsoft.sqlserver.testframework.DBConnection)

Example 34 with DBConnection

use of com.microsoft.sqlserver.testframework.DBConnection 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 35 with DBConnection

use of com.microsoft.sqlserver.testframework.DBConnection 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)

Aggregations

DBConnection (com.microsoft.sqlserver.testframework.DBConnection)38 DBStatement (com.microsoft.sqlserver.testframework.DBStatement)25 Test (org.junit.jupiter.api.Test)16 DBResultSet (com.microsoft.sqlserver.testframework.DBResultSet)14 SQLException (java.sql.SQLException)8 DBTable (com.microsoft.sqlserver.testframework.DBTable)6 BeforeAll (org.junit.jupiter.api.BeforeAll)6 Connection (java.sql.Connection)5 Statement (java.sql.Statement)5 ResultSet (java.sql.ResultSet)4 BeforeEach (org.junit.jupiter.api.BeforeEach)4 SQLServerBulkCopy (com.microsoft.sqlserver.jdbc.SQLServerBulkCopy)3 AbstractTest (com.microsoft.sqlserver.testframework.AbstractTest)3 SQLServerCallableStatement (com.microsoft.sqlserver.jdbc.SQLServerCallableStatement)2 SQLServerPreparedStatement (com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement)2 SQLServerStatement (com.microsoft.sqlserver.jdbc.SQLServerStatement)2 DBColumn (com.microsoft.sqlserver.testframework.DBColumn)2 DBPreparedStatement (com.microsoft.sqlserver.testframework.DBPreparedStatement)2 DisplayName (org.junit.jupiter.api.DisplayName)2 SQLServerColumnEncryptionJavaKeyStoreProvider (com.microsoft.sqlserver.jdbc.SQLServerColumnEncryptionJavaKeyStoreProvider)1