use of com.microsoft.sqlserver.jdbc.SQLServerBulkCopy in project mssql-jdbc by Microsoft.
the class BulkCopyWithSqlVariantTest method bulkCopyTestVarbinary20.
/**
* test varbinary value
*
* @throws SQLException
*/
@Test
public void bulkCopyTestVarbinary20() throws SQLException {
String col1Value = "hello";
beforeEachSetup("varbinary(20)", "'" + 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()) {
assertTrue(Utils.parseByte(rs.getBytes(1), col1Value.getBytes()));
}
}
use of com.microsoft.sqlserver.jdbc.SQLServerBulkCopy in project mssql-jdbc by Microsoft.
the class BulkCopyWithSqlVariantTest method bulkCopyTestVarbinary8000.
/**
* test varbinary8000
*
* @throws SQLException
*/
@Test
public void bulkCopyTestVarbinary8000() throws SQLException {
String col1Value = "hello";
beforeEachSetup("binary(8000)", "'" + 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()) {
assertTrue(Utils.parseByte(rs.getBytes(1), col1Value.getBytes()));
}
}
use of com.microsoft.sqlserver.jdbc.SQLServerBulkCopy in project mssql-jdbc by Microsoft.
the class BulkCopyWithSqlVariantTest method bulkCopyTestVarChar8000.
/**
* Read VarChar8000 from SqlVariant
*
* @throws SQLException
*/
@Test
public void bulkCopyTestVarChar8000() throws SQLException {
StringBuffer buffer = new StringBuffer();
for (int i = 0; i < 8000; i++) {
buffer.append("a");
}
String col1Value = buffer.toString();
beforeEachSetup("varchar(8000)", "'" + 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.getString(1), col1Value);
}
}
use of com.microsoft.sqlserver.jdbc.SQLServerBulkCopy in project mssql-jdbc by Microsoft.
the class BulkCopyWithSqlVariantTest method bulkCopyTestSmalldatetime.
/**
* test smalldatetime
*
* @throws SQLException
*/
@Test
public void bulkCopyTestSmalldatetime() throws SQLException {
String col1Value = "2015-05-08 12:26:24";
beforeEachSetup("smalldatetime", "'" + 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.getSmallDateTime(1), "2015-05-08 12:26:00.0");
}
}
use of com.microsoft.sqlserver.jdbc.SQLServerBulkCopy in project mssql-jdbc by Microsoft.
the class BulkCopyWithSqlVariantTest method bulkCopyTestDatetime2.
/**
* test datetime2
*
* @throws SQLException
*/
@Test
public void bulkCopyTestDatetime2() throws SQLException {
String col1Value = "2015-05-08 12:26:24.12645";
beforeEachSetup("datetime2(2)", "'" + 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.getTimestamp(1), "2015-05-08 12:26:24.13");
}
}
Aggregations