java中调存储过程和函数时出错!!!怎么解决,谢谢!
java.sql.SQLException: ORA-06550: 第 1 行, 第 13 列:
PLS-00201: 必须说明标识符 'T_PKG.GET_VALUE '
ORA-06550: 第 1 行, 第 7 列:
PL/SQL: Statement ignored
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:573)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1891)
at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:1093)
at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2047)
at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1940)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2709)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:589)
at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:656)
at com.inventec.packages.JDBCDemo.test(JDBCDemo.java:45)
at com.inventec.packages.JDBCDemo.main(JDBCDemo.java:32)
我的代码:
--创建表
CREATE TABLE T
(COL1 NUMBER PRIMARY KEY, COL2 VARCHAR2(10));
insert into t values (1, 'Hello ');
insert into t values (2, 'World ');
--创建包和声明函数
CREATE OR REPLACE
PACKAGE T_PKG AS
G_COUNT NUMBER := 0;
FUNCTION GET_VALUE(p_col1 NUMBER) RETURN VARCHAR2;
PROCEDURE GET_VALUE2(p_col1 NUMBER, p_col2 OUT VARCHAR2);
END;
--创建包中函数的实现
create OR REPLACE
PACKAGE BODY T_PKG AS
FUNCTION GET_VALUE(p_col1 NUMBER) RETURN VARCHAR2
IS
v_value VARCHAR2(10);
BEGIN
g_count := g_count + 1;
SELECT col2 INTO v_value FROM t WHERE col1 = p_col1;
RETURN v_value|| ', Execution Count = '||g_count;
END;
PROCEDURE GET_VALUE2(p_col1 NUMBER, p_col2 OUT VARCHAR2)
IS
BEGIN
g_count := g_count + 1;
SELECT col2 INTO p_col2 FROM t WHERE col1 = p_col1;
p_col2 := p_col2|| ', Execution Count = '||g_count;
END;
END;
--在java中的实现------------
import java.sql.*;
import oracle.jdbc.driver.OracleDriver;
public class JDBCDemo {
static Connection conn;
public static void main(String[] args) {
try {
DriverManager.registerDriver( new OracleDriver());
conn = DriverManager.getConnection( "jdbc:oracle:thin:@localhost:1521:orcl ", "ora15 ", "oracle ");