package fengshu.oracle;
import java.sql.Connection;
import java.sql.*;
public class Test1 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
try {
//1.加载驱动
Class.forName("oracle.jdbc.driver.OracleDriver");
//2.得到连接
Connection ct=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:oracle","scott","tiger");
//3.创建CallableStatement
/* CallableStatement as=ct.prepareCall("{call sp_pr5(?,?,?)}");
//4.给?赋值
cs.setInt(1,10);
cs.setString(2, "笑傲江湖");
cs.setString(3, "清华大学出版社");
*/
CallableStatement as=ct.prepareCall("{call sp_pr5(?,?)}");
as.setInt(1, 7788);
as.registeroutperameter(2,oracle.jdbc.oracleTypes.VARCHAR);
//5.执行
as.execute();
//关闭
String name=as.getString(2);
System.out.println("7788的名字"+name);
as.close();
//ct.close();
}catch (Exception e){
e.printStackTrace();
}
}
}
错误提示如下
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
oracle.jdbc.oracleTypes cannot be resolved to a variable
at fengshu.oracle.Test1.main(Test1.java:25)
------解决方案--------------------
你oracle用什么版本,有oracle的驱动jar吗?
ojdbc14.jar你确定有?
你在ojdbc14.jar中看看是否存在,oracle.jdbc.oracleTypes.class
代码迷推荐解决方案:oracle存储过程,http://www.daimami.com/oracle-develop/177537.html