use of com.microsoft.sqlserver.jdbc.SQLServerBulkCopy in project mssql-jdbc by Microsoft.
the class BulkCopyWithSqlVariantTest method bulkCopyTestMoney.
/**
* test money value
*
* @throws SQLException
*/
@Test
public void bulkCopyTestMoney() throws SQLException {
String col1Value = "126.1230";
beforeEachSetup("money", 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.getMoney(1), new BigDecimal(col1Value));
}
}
use of com.microsoft.sqlserver.jdbc.SQLServerBulkCopy in project mssql-jdbc by Microsoft.
the class BulkCopyWithSqlVariantTest method bulkCopyTestReal.
/**
* test real value
*
* @throws SQLException
*/
@Test
public void bulkCopyTestReal() throws SQLException {
int col1Value = 5;
beforeEachSetup("real", 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.getFloat(1), col1Value);
}
}
use of com.microsoft.sqlserver.jdbc.SQLServerBulkCopy in project mssql-jdbc by Microsoft.
the class BulkCopyWithSqlVariantTest method bulkCopyTestDatetime.
/**
* test datetime value
*
* @throws SQLException
*/
@Test
public void bulkCopyTestDatetime() throws SQLException {
String col1Value = "2015-05-08 12:26:24.0";
beforeEachSetup("datetime", "'" + 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.getDateTime(1), col1Value);
}
}
use of com.microsoft.sqlserver.jdbc.SQLServerBulkCopy in project mssql-jdbc by Microsoft.
the class BulkCopyWithSqlVariantTest method bulkCopyTestBigint.
/**
* test Bigint value
*
* @throws SQLException
*/
@Test
public void bulkCopyTestBigint() throws SQLException {
int col1Value = 5;
beforeEachSetup("bigint", 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.getLong(1), col1Value);
}
}
use of com.microsoft.sqlserver.jdbc.SQLServerBulkCopy in project mssql-jdbc by Microsoft.
the class BulkCopyWithSqlVariantTest method bulkCopyTestSmallInt.
/**
* Test smallInt value
*
* @throws SQLException
*/
@Test
public void bulkCopyTestSmallInt() throws SQLException {
int col1Value = 5;
beforeEachSetup("smallint", 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.getShort(1), 5);
}
bulkCopy.close();
}
Aggregations