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

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

    点击我下载

  • 相关阅读:
    WMI介绍
    进程间通信
    回调函数(C/C++)
    漏洞名词介绍
    MD5 详解
    jQuery插件的写法
    node爬虫
    nodejs应用:文件上传
    node开发备注
    node生成自定义命令(yargs/commander)
  • 原文地址:https://www.cnblogs.com/lansor/p/2530680.html
Copyright © 2011-2022 走看看