use of com.microsoft.sqlserver.testframework.sqlType.SqlType in project mssql-jdbc by Microsoft.
the class TVPAllTypes method testTVPDataTable.
/**
* Test TVP with DataTable
*
* @throws SQLException
*/
@Test
public void testTVPDataTable() throws SQLException {
setupVariation();
SQLServerDataTable dt = new SQLServerDataTable();
int numberOfColumns = tableDest.getColumns().size();
Object[] values = new Object[numberOfColumns];
for (int i = 0; i < numberOfColumns; i++) {
SqlType sqlType = tableDest.getColumns().get(i).getSqlType();
dt.addColumnMetadata(tableDest.getColumnName(i), sqlType.getJdbctype().getVendorTypeNumber());
values[i] = sqlType.createdata();
}
int numberOfRows = 10;
for (int i = 0; i < numberOfRows; i++) {
dt.addRow(values);
}
SQLServerPreparedStatement pstmt = (SQLServerPreparedStatement) connection.prepareStatement("INSERT INTO " + tableDest.getEscapedTableName() + " select * from ? ;");
pstmt.setStructured(1, tvpName, dt);
pstmt.execute();
}
use of com.microsoft.sqlserver.testframework.sqlType.SqlType 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;
}
Aggregations