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());

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

    点击我下载

  • 相关阅读:
    iOS很重要的 block回调
    怎样写具体设计文档
    ORM框架
    RapidXml用法
    【Android Training
    ORACLE触发器具体解释
    LeetCode 131 Palindrome Partitioning
    Git管理工具对照(GitBash、EGit、SourceTree)
    Android下将图片载入到内存中
    怎样破解邮箱password
  • 原文地址:https://www.cnblogs.com/lansor/p/2530680.html
Copyright © 2011-2022 走看看