连接管理器准备语句语法

时间:2013-03-26 18:39:48

标签: java oracle

当我在SQL开发人员中运行它时,此语句可以正常工作,但是,当我尝试通过这样的连接管理器运行它时,我一直得到“表或视图未找到”。我想知道这是否是因为连接管理器可能有不同的语法规则或者什么?有没有人对问题可能有什么了解?感谢。

ps = con.prepareStatement("select receipts.ordernumber, receipts.part, receipts.location, receipts.site, 
                           receipts.orderqty,  receipts.supplier, receipts.mfr, receipts.mfrpart, 
                           receipts.ponumber, orders.poline, orders.porelease, orders.price, 
                           orders.uom, orders.currency_r, orders.datecreated, orders.datelate, 
                           orders.approval_time, orders.userid, orders.buyer, orders.note_r, 
                           orders.qtyopen, orders.orderstate, supplier.accountnumber, 
                           delivery.method, 
                           CASE WHEN delivery.method = 'EDI' and delivery.process = 'ORDER' THEN 'YES' ELSE 'NO' END AS EDI, 
                           receipts.userid " +
"from receipts, orders, supplier, delivery " + 
"where receipts.customerix=43 and 
       orders.wip_order = 1 and supplier.suppliercode = orders.supplier and 
       supplier.customerix = orders.customerix and 
       delivery.supplierix = supplier.supplierix and 
       receipts.consigned = '1' and 
       orders.custordernumber(+) = receipts.ordernumber AND 
       orders.CUSTOMERIX(+) = receipts.CUSTOMERIX and 
       receipts.exported=0 and 
       receipts.export_active=1 
       order by receipts.ordernumber");


            statement = update.prepareStatement(" update receipts set export_active = 1 where receiptix in " +
                "(SELECT receipts.receiptix FROM pours.receipts, pours.orders, pours.supplier " +
                "WHERE receipts.customerix =7021 AND orders.wip_order = 1 AND supplier.suppliercode = orders.supplier " +
                "AND supplier.customerix = orders.customerix " +
                "AND receipts.consigned = '1' AND orders.custordernumber(+) = receipts.ordernumber " +
                "AND orders.CUSTOMERIX(+) = receipts.CUSTOMERIX AND receipts.exported = 0)");

2 个答案:

答案 0 :(得分:0)

看看这里: http://docs.oracle.com/javase/6/docs/api/java/sql/PreparedStatement.html

另外,尝试进行更简单的查询,看看是否可以访问表中的数据;

问候! /托马斯

答案 1 :(得分:0)

I Think you went wrong with the DBName, for the connection..检查一旦为连接提供了正确的数据库

当您的数据库没有此表

时,您才会收到此错误
DB_DRIVER = "oracle.jdbc.driver.OracleDriver";
DB_CONNECTION = "jdbc:oracle:thin:@localhost:1521:DBName";
DB_USER = "user";
DB_PASSWORD = "password";