use of com.microsoft.sqlserver.jdbc.SQLServerCallableStatement in project mssql-jdbc by Microsoft.
the class CallableStatementTest method testOutputProcedureBatchInorder.
private void testOutputProcedureBatchInorder(String sql) throws SQLException {
try (SQLServerCallableStatement callableStatement = (SQLServerCallableStatement) Util.getCallableStmt(con, sql, stmtColEncSetting)) {
callableStatement.registerOutParameter(1, java.sql.Types.INTEGER);
callableStatement.registerOutParameter(2, java.sql.Types.DOUBLE);
callableStatement.registerOutParameter(3, java.sql.Types.SMALLINT);
callableStatement.registerOutParameter(4, microsoft.sql.Types.SMALLMONEY);
callableStatement.execute();
int intValue2 = callableStatement.getInt(1);
assertEquals("" + intValue2, numericValues[3], "Test for output parameter fails.\n");
double floatValue0 = callableStatement.getDouble(2);
assertEquals("" + floatValue0, numericValues[5], "Test for output parameter fails.\n");
short shortValue3 = callableStatement.getShort(3);
assertEquals("" + shortValue3, numericValues[2], "Test for output parameter fails.\n");
BigDecimal smallmoneyValue = callableStatement.getSmallMoney(4);
assertEquals("" + smallmoneyValue, numericValues[12], "Test for output parameter fails.\n");
} catch (Exception e) {
fail(e.toString());
}
}
use of com.microsoft.sqlserver.jdbc.SQLServerCallableStatement in project mssql-jdbc by Microsoft.
the class CallableStatementTest method testInputProcedure.
private void testInputProcedure(String sql, String[] values) throws SQLException {
try (SQLServerCallableStatement callableStatement = (SQLServerCallableStatement) Util.getCallableStmt(con, sql, stmtColEncSetting)) {
callableStatement.setInt(1, Integer.parseInt(values[3]));
if (RandomData.returnZero)
callableStatement.setBigDecimal(2, new BigDecimal(values[8]), 18, 0);
else
callableStatement.setBigDecimal(2, new BigDecimal(values[8]));
callableStatement.setDouble(3, Double.parseDouble(values[5]));
callableStatement.setFloat(4, Float.parseFloat(values[7]));
if (RandomData.returnZero)
// numeric(18,0)
callableStatement.setBigDecimal(5, new BigDecimal(values[10]), 18, 0);
else
// numeric(18,0)
callableStatement.setBigDecimal(5, new BigDecimal(values[10]));
callableStatement.setSmallMoney(6, new BigDecimal(values[12]));
callableStatement.setMoney(7, new BigDecimal(values[13]));
if (values[0].equalsIgnoreCase("true"))
callableStatement.setBoolean(8, true);
else
callableStatement.setBoolean(8, false);
// smallint
callableStatement.setShort(9, Short.parseShort(values[2]));
// bigint
callableStatement.setLong(10, Long.parseLong(values[4]));
// float30
callableStatement.setDouble(11, Double.parseDouble(values[6]));
// decimal(10,5)
callableStatement.setBigDecimal(12, new BigDecimal(values[9]), 10, 5);
// numeric(8,2)
callableStatement.setBigDecimal(13, new BigDecimal(values[11]), 8, 2);
callableStatement.setBigDecimal(14, new BigDecimal(values[14]), 28, 4);
callableStatement.setBigDecimal(15, new BigDecimal(values[15]), 28, 4);
try (SQLServerResultSet rs = (SQLServerResultSet) callableStatement.executeQuery()) {
rs.next();
assertEquals(rs.getString(1), values[3], "" + "Test for input parameter fails.\n");
}
} catch (Exception e) {
fail(e.toString());
}
}
use of com.microsoft.sqlserver.jdbc.SQLServerCallableStatement in project mssql-jdbc by Microsoft.
the class CallableStatementTest method testMixedProcedure3Inorder.
private void testMixedProcedure3Inorder(String sql) throws SQLException {
try (SQLServerCallableStatement callableStatement = (SQLServerCallableStatement) Util.getCallableStmt(con, sql, stmtColEncSetting)) {
callableStatement.registerOutParameter(1, java.sql.Types.BIGINT);
callableStatement.registerOutParameter(2, java.sql.Types.FLOAT);
callableStatement.setInt(3, Integer.parseInt(numericValues[3]));
callableStatement.setShort(4, Short.parseShort(numericValues[2]));
callableStatement.execute();
long bigintValue = callableStatement.getLong(1);
assertEquals("" + bigintValue, numericValues[4], "Test for output parameter fails.\n");
double floatValue = callableStatement.getDouble(2);
assertEquals("" + floatValue, numericValues[5], "Test for output parameter fails.\n");
} catch (Exception e) {
fail(e.toString());
}
}
use of com.microsoft.sqlserver.jdbc.SQLServerCallableStatement in project mssql-jdbc by Microsoft.
the class CallableStatementTest method testOutputProcedure3ReverseOrder.
private void testOutputProcedure3ReverseOrder(String sql) throws SQLException {
try (SQLServerCallableStatement callableStatement = (SQLServerCallableStatement) Util.getCallableStmt(con, sql, stmtColEncSetting)) {
callableStatement.registerOutParameter(1, java.sql.Types.INTEGER);
callableStatement.registerOutParameter(2, java.sql.Types.INTEGER);
callableStatement.execute();
int intValue2 = callableStatement.getInt(2);
assertEquals("" + intValue2, numericValues[3], "Test for output parameter fails.\n");
int intValue = callableStatement.getInt(1);
assertEquals("" + intValue, numericValues[3], "Test for output parameter fails.\n");
} catch (Exception e) {
fail(e.toString());
}
}
use of com.microsoft.sqlserver.jdbc.SQLServerCallableStatement in project mssql-jdbc by Microsoft.
the class CallableStatementTest method testOutputProcedure2ReverseOrder.
private void testOutputProcedure2ReverseOrder(String sql, String[] values) throws SQLException {
try (SQLServerCallableStatement callableStatement = (SQLServerCallableStatement) Util.getCallableStmt(con, sql, stmtColEncSetting)) {
callableStatement.registerOutParameter(1, java.sql.Types.INTEGER);
callableStatement.registerOutParameter(2, java.sql.Types.INTEGER);
callableStatement.registerOutParameter(3, java.sql.Types.SMALLINT);
callableStatement.registerOutParameter(4, java.sql.Types.SMALLINT);
callableStatement.registerOutParameter(5, java.sql.Types.TINYINT);
callableStatement.registerOutParameter(6, java.sql.Types.TINYINT);
callableStatement.registerOutParameter(7, microsoft.sql.Types.SMALLMONEY);
callableStatement.registerOutParameter(8, microsoft.sql.Types.SMALLMONEY);
callableStatement.registerOutParameter(9, microsoft.sql.Types.MONEY);
callableStatement.registerOutParameter(10, microsoft.sql.Types.MONEY);
callableStatement.execute();
BigDecimal encryptedMoney = callableStatement.getMoney(10);
assertEquals("" + encryptedMoney, values[13], "Test for output parameter fails.\n");
BigDecimal MoneyValue = callableStatement.getMoney(9);
assertEquals("" + MoneyValue, values[13], "Test for output parameter fails.\n");
BigDecimal SmallMoneyValue = callableStatement.getSmallMoney(8);
assertEquals("" + SmallMoneyValue, values[12], "Test for output parameter fails.\n");
BigDecimal encryptedSmallMoney = callableStatement.getSmallMoney(7);
assertEquals("" + encryptedSmallMoney, values[12], "Test for output parameter fails.\n");
short encryptedTinyint = callableStatement.getShort(6);
assertEquals("" + encryptedTinyint, values[1], "Test for output parameter fails.\n");
short tinyintValue = callableStatement.getShort(5);
assertEquals("" + tinyintValue, values[1], "Test for output parameter fails.\n");
short encryptedSmallint = callableStatement.getShort(4);
assertEquals("" + encryptedSmallint, values[2], "Test for output parameter fails.\n");
short smallintValue = callableStatement.getShort(3);
assertEquals("" + smallintValue, values[2], "Test for output parameter fails.\n");
int encryptedInt = callableStatement.getInt(2);
assertEquals("" + encryptedInt, values[3], "Test for output parameter fails.\n");
int intValue = callableStatement.getInt(1);
assertEquals("" + intValue, values[3], "Test for output parameter fails.\n");
} catch (Exception e) {
fail(e.toString());
}
}
Aggregations