本文整理汇总了Java中java.sql.CallableStatement.setNull方法的典型用法代码示例。如果您正苦于以下问题:Java CallableStatement.setNull方法的具体用法?Java CallableStatement.setNull怎么用?Java CallableStatement.setNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.sql.CallableStatement
的用法示例。
在下文中一共展示了CallableStatement.setNull方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testBug60816
import java.sql.CallableStatement; //导入方法依赖的package包/类
/**
* Tests fix for BUG#60816 - Cannot pass NULL to an INOUT procedure parameter
*
* @throws Exception
*/
public void testBug60816() throws Exception {
createProcedure("test60816_1", "(INOUT x INTEGER)\nBEGIN\nSET x = x + 1;\nEND");
createProcedure("test60816_2", "(x INTEGER, OUT y INTEGER)\nBEGIN\nSET y = x + 1;\nEND");
createProcedure("test60816_3", "(INOUT x INTEGER)\nBEGIN\nSET x = 10;\nEND");
CallableStatement call = this.conn.prepareCall("{ call test60816_1(?) }");
call.setInt(1, 1);
call.registerOutParameter(1, Types.INTEGER);
call.execute();
assertEquals(2, call.getInt(1));
call = this.conn.prepareCall("{ call test60816_2(?, ?) }");
call.setInt(1, 1);
call.registerOutParameter(2, Types.INTEGER);
call.execute();
assertEquals(2, call.getInt(2));
call = this.conn.prepareCall("{ call test60816_2(?, ?) }");
call.setNull(1, Types.INTEGER);
call.registerOutParameter(2, Types.INTEGER);
call.execute();
assertEquals(0, call.getInt(2));
assertTrue(call.wasNull());
call = this.conn.prepareCall("{ call test60816_1(?) }");
call.setNull(1, Types.INTEGER);
call.registerOutParameter(1, Types.INTEGER);
call.execute();
assertEquals(0, call.getInt(1));
assertTrue(call.wasNull());
call = this.conn.prepareCall("{ call test60816_3(?) }");
call.setNull(1, Types.INTEGER);
call.registerOutParameter(1, Types.INTEGER);
call.execute();
assertEquals(10, call.getInt(1));
}