import java.sql.*;
public class TestProc {
public static void main(String[] args) throws Exception{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@192.168.1.101:1521:ORCL","scott","372158");
CallableStatement cstmt = conn.prepareCall("{call p(?, ?, ?, ?)}");
cstmt.registerOutParameter(3, Types.INTEGER);
cstmt.registerOutParameter(4, Types.INTEGER);
cstmt.setInt(1, 3);
cstmt.setInt(2, 4);
cstmt.setInt(4, 5);
cstmt.execute();
System.out.println(cstmt.getInt(3));
System.out.println(cstmt.getInt(4));
cstmt.close();
conn.close();
}
}
------ Solution ------------------------------------- -------
very clear ah, " the number and types of arguments error" , you look at the stored procedure parameter it
------ For reference only ---- -----------------------------------
Exception in thread "main" java.sql.SQLException: ORA-06550: line 1 , section 7 :
PLS-00306: When calling 'P' number of parameters or the wrong type
ORA-06550: line 1 , Section 7 :
PL / SQL: Statement ignored
at oracle.jdbc.driver.DatabaseError.throwSqlException (DatabaseError.java: 112)
at oracle.jdbc.driver.T4CTTIoer.processError (T4CTTIoer.java: 331)
at oracle.jdbc.driver.T4CTTIoer.processError (T4CTTIoer.java: 288)
at oracle.jdbc.driver.T4C8Oall.receive (T4C8Oall.java: 745)
at oracle.jdbc.driver.T4CCallableStatement.doOall8 (T4CCallableStatement.java: 215)
at oracle.jdbc.driver.T4CCallableStatement.executeForRows (T4CCallableStatement.java: 965)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout (OracleStatement.java: 1170)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal (OraclePreparedStatement.java: 3339)
at oracle.jdbc.driver.OraclePreparedStatement.execute (OraclePreparedStatement.java: 3445)
at oracle.jdbc.driver.OracleCallableStatement.execute (OracleCallableStatement.java: 4394)
at TestProc.main (TestProc.java: 13)
This is the newspaper 's fault
------ For reference only ----------------------------- ----------

------ For reference only -------------------------- -------------


------ For reference only ---------------------------------------
landlord, I have encountered this problem, you can not talk about Kazakhstan ?
on this example how to create a stored procedure
没有评论:
发表评论