ora-03001在java中运行select时未实现的功能

时间:2014-02-27 18:59:49

标签: java sql oracle11g ojdbc

当我收到错误代码时,我尝试在java上运行oracle 11g上的select查询(使用瘦驱动程序)。 我的问题是为什么我得到这个错误?我认为它必须是瘦驱动程序的问题,但我无法弄清楚它可能是什么,因为它确实支持选择查询...请帮助我!

java.sql.SQLException: ora-03001 unimplemented feature

ora版本:

Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
"CORE   11.2.0.1.0  Production"
TNS for 64-bit Windows: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production

查询是:

    query = "select e.eq_nr as \"Eqiptmentnummer\", f.file_name as \"Dateiname\" e.adress as \"Adresse\","
            + " e.city as \"Ort\", e.county as \"Bundesland\", e.zip_code as \"PLZ\","
            + " e.manufacturer as \"Hersteller\" f.doc_info as \"DOC INFO\""
            + " from elevators e join files f on(e.eq_nr = (select eq_nr from file_links where file_id = f.file_id))";

使用preparedStatement和executeQuery:

PreparedStatement ps = c.getCon().prepareStatement(query);
ResultSet rs = ps.executeQuery();

我在sql developer中运行了这个查询,它给了我这个输出(所有电梯及其相关文件),这是正确的:

eq_nr | file_name     |      adress    | city  |county| zip  |manufaturer|  note
1000    testname1.pdf   somestreet 12   Vienna  Vienna  1200    OTIS    test insert brown 1
1000    testname2.pdf   somestreet 12   Vienna  Vienna  1200    OTIS    test insert brown 2
1000    testname4.pdf   somestreet 12   Vienna  Vienna  1200    OTIS    test insert brown 4
1001    testname.pdf    somestreet 123  Vienna  Vienna  1200    KONE    test insert brown
1001    testname3.pdf   somestreet 123  Vienna  Vienna  1200    KONE    test insert brown 3
1001    testname5.pdf   somestreet 123  Vienna  Vienna  1200    KONE    test insert brown5 
1001    testname6.pdf   somestreet 123  Vienna  Vienna  1200    KONE    test insert brown 6

asd select * from elevators:

elevator id|         adress        | city | county | zip  | manufacturer
1000        somestreet 12   Vienna  Vienna  1200    OTIS
1001        somestreet 123  Vienna  Vienna  1200    KONE

从文件中选择*:

[FILE_ID]  [FILE_NAME]  [FILE_PATH]     [FILE_TYPE] [LAST_CHANGED]         [ARCHIVE_FLAG][DOC_INFO]
77       [testname.pdf] [C:\testname.pdf]   [pdf]   27.02.14 19:08:39,720000000  0      [test insert brown]
987     [testname1.pdf] [C:\testname1.pdf]  [pdf]   27.02.14 19:08:55,195000000  0      [test insert brown 1]
76523   [testname2.pdf] [C:\testname2.pdf]  [pdf]   27.02.14 19:09:09,735000000  0      [test insert brown 2]
123323  [testname3.pdf] [C:\testname3.pdf]  [pdf]   27.02.14 19:09:35,912000000  0      [test insert brown 3]
1232    [testname4.pdf] [C:\testname4.pdf]  [pdf]   27.02.14 19:09:49,219000000  0      [test insert brown 4]
8888212 [testname5.pdf] [C:\testname5.pdf]  [pdf]   27.02.14 19:10:08,267000000  0      [test insert brown5 ]
5678    [testname6.pdf] [C:\testname6.pdf]  [pdf]   27.02.14 19:10:22,213000000  0      [test insert brown 6]

从file_links中选择*:

eq_ nr     file_id  valid
1000    76523   0
1000    1232    0
1000    987 0
1001    5678    0
1001    8888212 0
1001    123323  0
1001    77  0

2 个答案:

答案 0 :(得分:1)

这可能只是一个复制粘贴问题。在您发布的每个查询中,您都缺少逗号

f.file_name as \"Dateiname\" e.adress as \"Adresse\",

但上面的编辑没有。

f.file_name as \"Dateiname\", e.adress as \"Adresse\",

可以这么简单吗? ;)

答案 1 :(得分:0)

我认为join / subselect组合不是标准的。我会建议像

这样的东西
query = "select e.eq_nr as \"Eqiptmentnummer\", f.file_name as \"Dateiname\" e.adress as \"Adresse\","
        + " e.city as \"Ort\", e.county as \"Bundesland\", e.zip_code as \"PLZ\","
        + " e.manufacturer as \"Hersteller\" f.doc_info as \"DOC INFO\""
        + " from elevators e"
        + " join files f on (e.eq_nr = f.eq_nr)"
        + " where e.eq_nr in ("
        + "   select f.eq_nr"
        + "   from files f"
        + "   join file_links fl"
        + "   where fl.file_id = f.file_id"
        + ")";

修改

query = "select e.eq_nr as \"Eqiptmentnummer\", f.file_name as \"Dateiname\", e.adress as \"Adresse\", e.city as \"Ort\", e.county as \"Bundesland\", e.zip_code as \"PLZ\",  e.manufacturer as \"Hersteller\", f.doc_info as \"DOC INFO\""
    + " from elevators e"
    + " join file_links fl on (e.eq_id = fl.eq_id)"
    + " join files f on (f.file_id = fl.file_id)";