zoukankan      html  css  js  c++  java
  • ORA00904:标识符无效,preparedstatement

    今天很郁闷 ,被一个java.sql.SQLException:"CLIENTTYPE" ORA-00904:标识符无效错误给折腾得不行了。

    一直找错,执行的sql扔到pl/sql里没问题,但是运行代码就出错,那个汗颜啊。最后看到网上有同样经历的,顿悟了一下,配置。。。没改过来,java中和ps/sql中连接了不同的库。mark,一下以后小心。

    另外,用preprestatement执行的sql看不见也非常郁闷。找到一个包可以打印出,不过对于spring中使用的dbcp连接池不太好用,不过测试用还可以。

     

    Connection con = DriverManager.getConnection(url);
    DebugLevel debug = DebugLevel.ON;
    String sql = "SELECT name,rate FROM EmployeeTable WHERE rate > ?";
    //Use a factory instead of Connection to get a PreparedStatement.
    //PreparedStatement ps = con.prepareStatement(sql);
    PreparedStatement ps = StatementFactory.getStatement(con,sql,debug);
    ps.setInt(1,25);
    //If ps is a DebuggableStatement, you see the statement,
    //otherwise, an object identifier is displayed
    System.out.println(" debuggable statement= " + ps.toString());

    附件是这段代码中用到的类。 

    点击我下载

  • 相关阅读:
    Easy Install详细参数
    linux.backspace乱码(转)
    RemoteFX
    netsh
    sc.exe
    WinRM和WinRS
    安全配置向导
    使用 Sconfig.cmd 配置服务器核心服务器
    FSMO
    Windows Server 2012之活动目录域服务的卸载
  • 原文地址:https://www.cnblogs.com/lansor/p/2530680.html
Copyright © 2011-2022 走看看