use of com.microsoft.sqlserver.jdbc.SQLServerBulkCopy in project mssql-jdbc by Microsoft.
the class BulkCopyWithSqlVariantTest method bulkCopyTestNchar.
/**
* test nchar value
*
* @throws SQLException
*/
@Test
public void bulkCopyTestNchar() throws SQLException {
String col1Value = "'a'";
beforeEachSetup("nchar", col1Value);
rs = (SQLServerResultSet) stmt.executeQuery("SELECT * FROM " + tableName);
SQLServerBulkCopy bulkCopy = new SQLServerBulkCopy(con);
bulkCopy.setDestinationTableName(destTableName);
bulkCopy.writeToServer(rs);
bulkCopy.close();
rs = (SQLServerResultSet) stmt.executeQuery("SELECT * FROM " + destTableName);
while (rs.next()) {
assertEquals("'" + rs.getNString(1).trim() + "'", col1Value);
}
}
use of com.microsoft.sqlserver.jdbc.SQLServerBulkCopy in project mssql-jdbc by Microsoft.
the class BulkCopyWithSqlVariantTest method bulkCopyTestBitNull.
/**
* test null value for underlying bit data type
*
* @throws SQLException
*/
// TODO: check bitnull
@Test
public void bulkCopyTestBitNull() throws SQLException {
beforeEachSetup("bit", null);
rs = (SQLServerResultSet) stmt.executeQuery("SELECT * FROM " + tableName);
SQLServerBulkCopy bulkCopy = new SQLServerBulkCopy(con);
bulkCopy.setDestinationTableName(destTableName);
bulkCopy.writeToServer(rs);
bulkCopy.close();
rs = (SQLServerResultSet) stmt.executeQuery("SELECT * FROM " + destTableName);
while (rs.next()) {
assertEquals(rs.getBoolean(1), false);
}
}
use of com.microsoft.sqlserver.jdbc.SQLServerBulkCopy in project mssql-jdbc by Microsoft.
the class BulkCopyWithSqlVariantTest method bulkCopyTestTinyint.
/**
* Test tinyInt value
*
* @throws SQLException
*/
@Test
public void bulkCopyTestTinyint() throws SQLException {
int col1Value = 5;
beforeEachSetup("tinyint", col1Value);
rs = (SQLServerResultSet) stmt.executeQuery("SELECT * FROM " + tableName);
SQLServerBulkCopy bulkCopy = new SQLServerBulkCopy(con);
bulkCopy.setDestinationTableName(destTableName);
bulkCopy.writeToServer(rs);
bulkCopy.close();
rs = (SQLServerResultSet) stmt.executeQuery("SELECT * FROM " + destTableName);
while (rs.next()) {
assertEquals(rs.getByte(1), 5);
}
bulkCopy.close();
}
use of com.microsoft.sqlserver.jdbc.SQLServerBulkCopy in project mssql-jdbc by Microsoft.
the class BulkCopyWithSqlVariantTest method bulkCopyTestInt.
/**
* Test integer value
*
* @throws SQLException
*/
@Test
public void bulkCopyTestInt() throws SQLException {
int col1Value = 5;
beforeEachSetup("int", col1Value);
rs = (SQLServerResultSet) stmt.executeQuery("SELECT * FROM " + tableName);
SQLServerBulkCopy bulkCopy = new SQLServerBulkCopy(con);
bulkCopy.setDestinationTableName(destTableName);
bulkCopy.writeToServer(rs);
bulkCopy.close();
rs = (SQLServerResultSet) stmt.executeQuery("SELECT * FROM " + destTableName);
while (rs.next()) {
assertEquals(rs.getInt(1), 5);
}
}
use of com.microsoft.sqlserver.jdbc.SQLServerBulkCopy in project mssql-jdbc by Microsoft.
the class BulkCopyWithSqlVariantTest method bulkCopyTestSmallmoney.
/**
* test smallmoney
*
* @throws SQLException
*/
@Test
public void bulkCopyTestSmallmoney() throws SQLException {
String col1Value = "126.1230";
String destTableName = "dest_sqlVariant";
Utils.dropTableIfExists(tableName, stmt);
Utils.dropTableIfExists(destTableName, stmt);
stmt.executeUpdate("create table " + tableName + " (col1 sql_variant)");
stmt.executeUpdate("INSERT into " + tableName + "(col1) values (CAST (" + col1Value + " AS " + "smallmoney" + ") )");
stmt.executeUpdate("create table " + destTableName + " (col1 sql_variant)");
rs = (SQLServerResultSet) stmt.executeQuery("SELECT * FROM " + tableName);
SQLServerBulkCopy bulkCopy = new SQLServerBulkCopy(con);
bulkCopy.setDestinationTableName(destTableName);
bulkCopy.writeToServer(rs);
bulkCopy.close();
rs = (SQLServerResultSet) stmt.executeQuery("SELECT * FROM " + destTableName);
while (rs.next()) {
assertEquals(rs.getSmallMoney(1), new BigDecimal(col1Value));
}
}
Aggregations