use of com.microsoft.sqlserver.jdbc.SQLServerDataTable in project mssql-jdbc by Microsoft.
the class TVPSchemaTest method testSetup.
@BeforeEach
private void testSetup() throws SQLException {
conn = new DBConnection(connectionString);
stmt = conn.createStatement();
dropProcedure();
dropTables();
dropTVPS();
dropAndCreateSchema();
createTVPS();
createTables();
createPreocedure();
tvp = new SQLServerDataTable();
tvp.addColumnMetadata("PlainChar", java.sql.Types.CHAR);
tvp.addColumnMetadata("PlainVarchar", java.sql.Types.VARCHAR);
tvp.addColumnMetadata("PlainVarcharMax", java.sql.Types.VARCHAR);
tvp.addRow(expectecValue1, expectecValue2, expectecValue3);
tvp.addRow(expectecValue1, expectecValue2, expectecValue3);
tvp.addRow(expectecValue1, expectecValue2, expectecValue3);
tvp.addRow(expectecValue1, expectecValue2, expectecValue3);
tvp.addRow(expectecValue1, expectecValue2, expectecValue3);
}
use of com.microsoft.sqlserver.jdbc.SQLServerDataTable in project mssql-jdbc by Microsoft.
the class TVPTypesTest method testTVPLongNVarcharStoredProcedure.
/**
* LongNVarchar with StoredProcedure
*
* @throws SQLException
*/
@Test
public void testTVPLongNVarcharStoredProcedure() throws SQLException {
createTables("nvarchar(max)");
createTVPS("nvarchar(max)");
createPreocedure();
StringBuffer buffer = new StringBuffer();
for (int i = 0; i < 8001; i++) buffer.append("سس");
value = buffer.toString();
tvp = new SQLServerDataTable();
tvp.addColumnMetadata("c1", java.sql.Types.LONGNVARCHAR);
tvp.addRow(buffer.toString());
final String sql = "{call " + procedureName + "(?)}";
SQLServerCallableStatement P_C_statement = (SQLServerCallableStatement) connection.prepareCall(sql);
P_C_statement.setStructured(1, tvpName, tvp);
P_C_statement.execute();
rs = stmt.executeQuery("select * from " + table);
while (rs.next()) assertEquals(rs.getString(1), value);
if (null != P_C_statement) {
P_C_statement.close();
}
}
use of com.microsoft.sqlserver.jdbc.SQLServerDataTable in project mssql-jdbc by Microsoft.
the class TVPTypesTest method testTVPNTextStoredProcedure.
/**
* Text with StoredProcedure
*
* @throws SQLException
*/
@Test
public void testTVPNTextStoredProcedure() throws SQLException {
createTables("ntext");
createTVPS("ntext");
createPreocedure();
StringBuffer buffer = new StringBuffer();
for (int i = 0; i < 9000; i++) buffer.append("س");
value = buffer.toString();
tvp = new SQLServerDataTable();
tvp.addColumnMetadata("c1", java.sql.Types.LONGNVARCHAR);
tvp.addRow(value);
final String sql = "{call " + procedureName + "(?)}";
SQLServerCallableStatement P_C_statement = (SQLServerCallableStatement) connection.prepareCall(sql);
P_C_statement.setStructured(1, tvpName, tvp);
P_C_statement.execute();
rs = stmt.executeQuery("select * from " + table);
while (rs.next()) assertEquals(rs.getString(1), value);
if (null != P_C_statement) {
P_C_statement.close();
}
}
use of com.microsoft.sqlserver.jdbc.SQLServerDataTable in project mssql-jdbc by Microsoft.
the class TVPTypesTest method testTVPLongVarcharStoredProcedure.
/**
* LongVarchar with StoredProcedure
*
* @throws SQLException
*/
@Test
public void testTVPLongVarcharStoredProcedure() throws SQLException {
createTables("varchar(max)");
createTVPS("varchar(max)");
createPreocedure();
StringBuffer buffer = new StringBuffer();
for (int i = 0; i < 8001; i++) buffer.append("a");
value = buffer.toString();
tvp = new SQLServerDataTable();
tvp.addColumnMetadata("c1", java.sql.Types.LONGVARCHAR);
tvp.addRow(value);
final String sql = "{call " + procedureName + "(?)}";
SQLServerCallableStatement P_C_statement = (SQLServerCallableStatement) connection.prepareCall(sql);
P_C_statement.setStructured(1, tvpName, tvp);
P_C_statement.execute();
rs = stmt.executeQuery("select * from " + table);
while (rs.next()) assertEquals(rs.getString(1), value);
if (null != P_C_statement) {
P_C_statement.close();
}
}
use of com.microsoft.sqlserver.jdbc.SQLServerDataTable in project mssql-jdbc by Microsoft.
the class TVPTypesTest method testLongNVarchar.
/**
* Test longnvarchar
*
* @throws SQLException
*/
@Test
public void testLongNVarchar() throws SQLException {
createTables("nvarchar(max)");
createTVPS("nvarchar(max)");
StringBuffer buffer = new StringBuffer();
for (int i = 0; i < 8001; i++) buffer.append("سس");
value = buffer.toString();
tvp = new SQLServerDataTable();
tvp.addColumnMetadata("c1", java.sql.Types.LONGNVARCHAR);
tvp.addRow(value);
SQLServerPreparedStatement pstmt = (SQLServerPreparedStatement) connection.prepareStatement("INSERT INTO " + table + " select * from ? ;");
pstmt.setStructured(1, tvpName, tvp);
pstmt.execute();
rs = conn.createStatement().executeQuery("select * from " + table);
while (rs.next()) {
assertEquals(rs.getString(1), value);
}
if (null != pstmt) {
pstmt.close();
}
}
Aggregations