Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how can i pass the boolean data type from my java app to oracle function

 
zb cong
Ranch Hand
Posts: 416
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello
i want to call a oracle function(oracle817) from my java application,the function receive two parameter (string and boolean) and return a cursor.my code as:

DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
Connection conn = DriverManager.getConnection("jdbc racle:thin:@192.168.0.200:1521 ral", "ciqfee", "ciqfeepwd");
String query = "begin :1 := test_func(:2,:3); end;";
CallableStatement cstmt = conn.prepareCall(query);
cstmt.registerOutParameter(1, OracleTypes.CURSOR);
cstmt.setString(2, "3703000032");
cstmt.setBoolean(3, true);
cstmt.execute();

when i execute it,it throw following exception:

java.sql.SQLException: ORA-06550: �ƒ���‚���‚�� 1 �ƒ���‚���‚�Œ, �ƒ���‚���‚�� 13 �ƒ���‚�ˆ�‚�—�ƒ���‚���‚�š
PLS-00306: �ƒ���‚���‚�ƒ�ƒ���‚�”�‚�� 'TEST_FUNC' �ƒ���‚�—�‚���ƒ���‚���‚�‚�ƒ���‚�•�‚���ƒ���‚�•�‚���ƒ���‚�‡�‚���ƒ���‚�ˆ�‚�–�ƒ���‚���‚���ƒ���‚�ž�‚�‹�ƒ���‚�”�‚�™�ƒ���‚���‚��
ORA-06550: �ƒ���‚���‚�� 1 �ƒ���‚���‚�Œ, �ƒ���‚���‚�� 7 �ƒ���‚�ˆ�‚�—�ƒ���‚���‚�š
PL/SQL: Statement ignored
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:208)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:543)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1405)
at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:822)
at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:1446)
at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1371)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1900)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:363)
at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:407)
at test.entDbEJBTestClient1.main(entDbEJBTestClient1.java:264)


it is in chinese,means "parameter amount or type error",if i modify my program and the function,use the string as input param only,it works well,so i wonder how i can pass the boolean type param from java app to oracle function?
thanks very much!
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!