Return ROWID Parameter from insert statement using JDBC connection to oracle

前端 未结 5 749
迷失自我
迷失自我 2020-12-15 13:58

I can\'t seem to get the right magic combination to make this work:


OracleDataSource ods = new oracle.jdbc.pool.OracleDataSource();
ods.setURL(\"jdbc:oracle         


        
5条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-15 14:12

    Don't know if this applies or not since you don't specify what version you're using.

    From Oracle Metalink:

    Cause

    In the 10.1.0.x JDBC driver, returning DML is not supported:

    Per the JDBC FAQ: "10.1.0 (10g r1) Is DML Returning Supported ? Not in the current drivers. However, we do have plans to support it in post 10.1.0 drivers. We really mean it this time."

    As the application code is trying to use unsupported JDBC features, errors are raised.

    Solution

    Upgrade the JDBC driver to 10.2.0.x, because per the FAQ the 10.2.0.x JDBC drivers do support returning clause:

    "10.2.0 (10g r2) Is DML Returning Supported ? YES! And it's about time. See the Developer's Guide for details. "

    EDIT Just for grins, you can check the version of JDBC Oracle thinks it's using with:

     // Create Oracle DatabaseMetaData object
      DatabaseMetaData meta = conn.getMetaData();
    
      // gets driver info:
      System.out.println("JDBC driver version is " + meta.getDriverVersion());
    

    If that shows a JDBC driver 10.2.0.x or later, then I'm out of ideas and perhaps a support request to oracle is in order...

提交回复
热议问题