[Oracle JDBC Driver][Oracle]ORA-06575:

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[Oracle JDBC Driver][Oracle]ORA-06575:相关的知识,希望对你有一定的参考价值。

java.sql.SQLException: [Oracle JDBC Driver][Oracle]ORA-06575: Package or function FETCHCHARACVALUE is in an invalid state
我创建的存储过程是
Create or Replace procedure fetchValue(Aid in varchar2, Bid varchar2, p_cursor out types.cursorType)
As
Begin
select rcv.requestid, c.datatype, c.characid, cv.color, cv.datetimevalue, cv.intvalue, cv.stringvalue from charac c, value cv, request rcv
where c.characid = cv.characid and cv.characvalueid = rcv.characvalueid and cv.characid in (Aid) and rcv.requestid in Bid;
End fetchValue;
希望返回数据集合
Java 代码是
String driver_class = "oracle.jdbc.driver.OracleDriver";
String connect_string = "jdbc:oracle:thin:@localhost:1521:DB";
String query = "call fetchCharacValue(?,?,?)";
Connection conn;
Class.forName(driver_class);
conn = DriverManager.getConnection(connect_string,"USER","PASS");
CallableStatement cstmt = con.prepareCall(query);
cstmt.setString(1, AId);
cstmt.setString(2, BID);
cstmt.registerOutParameter(3,OracleTypes.CURSOR);
cstmt.execute();
cvrs = (ResultSet)cstmt.getObject(3);
求高手解决

Package or function FETCHCHARACVALUE is in an invalid state
翻译:你的函数处在非法状态,也就是函数编译不成功,无法引用。
参考技术A oracle.jdbc.OracleDriver与oracle.jdbc.driver.OracleDriver完全一样的 估计是为了与老的版本兼容的问题 如果使用Oracle8i JDBC驱动程序,那么需要导入oracle.追问

导入oracle. 是什么意思

没有找到适合“jdbc:oracle:thin:@****”oracle/jdbc/driver/OracleDriver”的驱动程序;

【中文标题】没有找到适合“jdbc:oracle:thin:@****”oracle/jdbc/driver/OracleDriver”的驱动程序;【英文标题】:No suitable driver found for "jdbc:oracle:thin:@**** "oracle/jdbc/driver/OracleDriver"; 【发布时间】:2013-11-12 07:01:20 【问题描述】:

这是我的java代码

public static Map<String,String> propertyFileReader() 
    Map<String, String> map=new HashMap<String, String>();
    Properties prop = new Properties();
    try 
        InputStream inputStream = Util.class.getClassLoader().getResourceAsStream("jdbc.properties");
        prop.load(inputStream);

        final String DB_DRIVER= prop.getProperty("DB_DRIVER");
        final String DB_CONNECTION = prop.getProperty("DB_CONNECTION2");
        final String DB_USER = prop.getProperty("DB_USER");
        final String DB_PASSWORD = prop.getProperty("DB_PASSWORD");

        map.put("DB_DRIVER",DB_DRIVER);
        map.put("DB_CONNECTION",DB_CONNECTION);
        map.put("DB_USER",DB_USER);
        map.put("DB_PASSWORD",DB_PASSWORD);

     catch (IOException e) 
        e.printStackTrace();
    

    return map;


private static Connection getDBConnection() 
    Map<String , String > map=new HashMap<String, String>();
    map=propertyFileReader();
    String DB_DRIVER=map.get("DB_DRIVER");
    String DB_CONNECTION= map.get("DB_CONNECTION");
    String DB_USER=map.get("DB_USER");
    String DB_PASSWORD=map.get("DB_PASSWORD");
    Connection dbConnection = null;
    try 
        Class.forName(DB_DRIVER);
     catch (ClassNotFoundException e) 
        System.out.println(e.getMessage());
    
    try 
        dbConnection = DriverManager.getConnection(DB_CONNECTION,DB_USER,DB_PASSWORD);
        return dbConnection;
     catch (SQLException e) 
        System.out.println(e.getMessage());
    
    return dbConnection;

这是我的属性文件

DB_DRIVER = "oracle.jdbc.driver.OracleDriver";
DB_CONNECTION2 = "jdbc:oracle:thin:@10.2.5.23:1521:dbslic";
DB_USER = "TSR_MOBILE";
DB_PASSWORD = "TSR_MOBILE";

我将 ojdbc6.jar 添加到我的构建路径 [也尝试使用 ojdbc14.jar]

但有如下错误提示

No suitable driver found for "jdbc:oracle:thin:@10.2.5.23:1521:dbslic";
"oracle/jdbc/driver/OracleDriver";
No suitable driver found for "jdbc:oracle:thin:@10.2.5.23:1521:dbslic";
[ERROR] Exception occurred while trying to invoke service method loginBlock
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.axis2.rpc.receivers.RPCUtil.invokeServiceClass(RPCUtil.java:212)
    at org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic(RPCMessageReceiver.java:117)
    at org.apache.axis2.receivers.AbstractInOutMessageReceiver.invokeBusinessLogic(AbstractInOutMessageReceiver.java:40)
    at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:114)
    at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:181)
    at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:172)
    at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:146)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:643)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
    at mainService.TSR_WEB_SERVICE.loginBlock(TSR_WEB_SERVICE.java:416)
    ... 25 more

请帮我解决这个问题

【问题讨论】:

你将它添加到你的构建路径中,这很好地满足了编译时依赖,如果你有的话。您是否也将它打包在您的 tomcat 的 lib 文件夹中,以便在运行时使用该驱动程序? 【参考方案1】:

您使用了错误的包来引用 OracleDriver 类 改变

oracle.jdbc.driver.OracleDriver  

oracle.jdbc.OracleDriver  

From oracle docs类定义

public class OracleDriver
              extends oracle.jdbc.driver.OracleDriver

实现java.sql.Driver 接口的Oracle JDBC 驱动程序类。

【讨论】:

【参考方案2】:

将其用作 Oracle 驱动程序

oracle.jdbc.OracleDriver 

而不是

oracle.jdbc.driver.OracleDriver

【讨论】:

【参考方案3】:

这个答案“有点”晚了,但接受的答案不正确,所以我将这个答案发布给那些不幸尝试复制/粘贴代码并想知道出了什么问题的人。

接受的答案到目前为止是正确的

oracle.jdbc.driver.OracleDriver

已弃用,但在 2020 年仍然可以使用。发布代码的问题是属性文件使用了分号和引号,即not valid。所以从

更改属性文件
DB_DRIVER = "oracle.jdbc.driver.OracleDriver";
DB_CONNECTION2 = "jdbc:oracle:thin:@10.2.5.23:1521:dbslic";
DB_USER = "TSR_MOBILE";
DB_PASSWORD = "TSR_MOBILE";

DB_DRIVER = oracle.jdbc.driver.OracleDriver
DB_CONNECTION2 = jdbc:oracle:thin:@10.2.5.23:1521:dbslic
DB_USER = SR_MOBILE
DB_PASSWORD = TSR_MOBILE

使错误消失。

【讨论】:

以上是关于[Oracle JDBC Driver][Oracle]ORA-06575:的主要内容,如果未能解决你的问题,请参考以下文章

Java从数据库中检索下一个类似项目[关闭]

ClassNotFoundException:oracle.jdbc.driver.OracleDriver

没有找到适合“jdbc:oracle:thin:@****”oracle/jdbc/driver/OracleDriver”的驱动程序;

[Oracle JDBC Driver][Oracle]ORA-06575:

oracle.jdbc.driver.OracleConnection 的类转换异常

java.sql.SQLException: Driver:oracle.jdbc.driver.OracleDriver 为 URL 返回 null:jdbc:h2:/data/sample;IFE