PreparedStatement.setString doesn't work with Oracle 10g.

Hi all,
I newbie question regarding the method setString of class java.sql.PreparedStatement. My process require to pass throught a file and check agaisnt a Oracle table if the product id of the given record exist in the table .
I use the SQL
select matnr from zncorart_ap where zartleg = ? and zentrleg = ?
to do that. When i try to replace the ? with the setString method it doesn't work and the query always return no row as ? is not a valid value.
Thx for your help.
// Here code snippet of the caller class
public class Inventory2SAP {
private ETLSQL productXRef;
private ResultSet productXRefResult;
private String inRecord;
private String prdCat;
protected void acquireResource() {
  try {       
//  Instantiate product XRef object.
    productXRef = new ETLSQL();
    productXRef.loadDriver(ch.getProperties("Inventory2SAP.JDBCDriver"));
    productXRef.connectDB(true);
    prdXRefLookup = "select matnr from zncorart_ap where zartleg = ? and zentrleg = ?";
    productXRef.createPrepared(prdXRefLookup);
  catch (SQLException sqle) {
    sqle.printStackTrace();
    System.exit(-1);            
// Loop this method until EOF        
protected boolean transform() {
   try {
      productXRef.setString(1, inRecord.substring(0, 8));
      productXRef.setString(2, prdCat);       
      productXRefResult = productXRef.executePrepared();
      if (productXRefResult.next()) {
         System.out.println("Nerver branch here because setString doesn't work");
      else {
         System.out.println("Always row not found");
   catch (SQLException sqle) {
      sqle.printStackTrace();
      System.exit(-1);
protected void releaseResource() {
   try {
      productXRef.disconnectDB();
   catch (SQLException sqle) {
      sqle.printStackTrace();
      System.exit(-1);
public class ETLSQL {
    private static Connection con;
    private PreparedStatement pstm;
    private ResultSet rs;
    protected ETLSQL() {
    protected void loadDriver(String driverID) {
       try {
          if (driverID.equals("oracle")) {
             Class.forName(ch.getProperties("OracleDriver")).newInstance();
       catch(ClassNotFoundException cnfe) {
          cnfe.printStackTrace();
          System.exit(-1);                  
      catch (InstantiationException ie) {
         ie.printStackTrace();
         System.exit(-1);  
      catch (IllegalAccessException iae) {
          iae.printStackTrace();
         System.exit(-1);               
protected void connectDB(boolean isReadOnly) throws SQLException {
   if (driverID.equals("oracle")) {
      con = DriverManager.getConnection(ch.getProperties("OracleURL"),
      ch.getProperties("OracleUser"), ch.getProperties("OraclePassword"));         
    else {
       System.out.println("Can't connect to the Database");
       System.exit(-1);                
protected void createPrepared(String SQLString) throws SQLException {
   pstm = con.prepareStatement(SQLString);
protected void setString(int pos, String s) throws SQLException {
   pstm.setString(pos, s);
protected ResultSet executePrepared() throws SQLException {
   rs  = pstm.executeQuery();
   return rs;
protected void disconnectDB() throws SQLException {
   if (pstm != null) {
      pstm.close();     
   if (!con.isClosed()) {
      con.close();
}

Ever solve this problem? Seems I'm having the same problem. I'm at a bit of a loss.
**** Specifically, I get this
Jan 23, 2007 12:49:51 PM test.JdbcTestHarness doItGood
INFO: ======= doItGood =======
Jan 23, 2007 12:49:52 PM test.JdbcTestHarness doItGood
INFO: It worked...my name is mvalerio
Jan 23, 2007 12:49:52 PM test.JdbcTestHarness doItBad
INFO: ======= doItBad =======
Jan 23, 2007 12:49:52 PM test.JdbcTestHarness doItBad
INFO: It didn't work my name is mud
**** When I do this
package test;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
public class JdbcTestHarness {
     private Logger logger = null;
     * @param args
     public static void main(String[] args) {
          JdbcTestHarness jdbcTest = new JdbcTestHarness();
          jdbcTest.doItGood();
          jdbcTest.doItBad();
     public JdbcTestHarness() {
          this.logger = Logger.getLogger("test");
     public void doItGood() {
          logger.log(Level.INFO, "======= doItGood =======");
          Connection conn = null;
          PreparedStatement stmt = null;
          ResultSet rs = null;
          try {
               Class.forName("oracle.jdbc.driver.OracleDriver");
               conn = DriverManager.getConnection(
                         "jdbc:oracle:thin:@db1-dev.lis.state.oh.us:2521:test",
                         "dir", "dir");
               stmt = conn
                         .prepareStatement("select username,password,'true' from account where account.username = 'mvalerio'");
               rs = stmt.executeQuery();
               if (rs.next()) {
                    this.logger.log(Level.INFO, "It worked...my name is "
                              + rs.getString(1));
               } else {
                    this.logger.log(Level.INFO, "It didn't work my name is mud");
          } catch (ClassNotFoundException e) {
               // TODO Auto-generated catch block
               e.printStackTrace();
          } catch (SQLException e) {
               // TODO Auto-generated catch block
               e.printStackTrace();
          } finally {
               if (conn != null) {
                    try {
                         conn.close();
                    } catch (SQLException e) {
                         // TODO Auto-generated catch block
                         e.printStackTrace();
     public void doItBad() {
          logger.log(Level.INFO, "======= doItBad =======");
          Connection conn = null;
          PreparedStatement stmt = null;
          ResultSet rs = null;
          try {
               Class.forName("oracle.jdbc.driver.OracleDriver");
               conn = DriverManager.getConnection(
                         "jdbc:oracle:thin:@db1-dev.lis.state.oh.us:2521:test",
                         "dir", "dir");
               stmt = conn
                         .prepareStatement("select username,password from account where account.username = ? ");
               stmt.setString(1, "mvalerio");
               rs = stmt.executeQuery();
               if (rs.next()) {
                    this.logger.log(Level.INFO, "It worked...my name is "
                              + rs.getString(1));
               } else {
                    this.logger.log(Level.INFO, "It didn't work my name is mud");
          } catch (ClassNotFoundException e) {
               // TODO Auto-generated catch block
               e.printStackTrace();
          } catch (SQLException e) {
               // TODO Auto-generated catch block
               e.printStackTrace();
          } finally {
               if (conn != null) {
                    try {
                         conn.close();
                    } catch (SQLException e) {
                         // TODO Auto-generated catch block
                         e.printStackTrace();
Any help would be appriciated.......

Similar Messages

  • APEX 3.1.0.00.32 doesn't work with ORACLE 10g SE 10.2.0.1.0

    I have Oracle 10g Express Edition 10.2.0.1.0 under Windows XP SP2 on my Personal Computer. There is installed the too , which is working fine.
    Also I have Oracle 10g Standard Edition 10.2.0.1.0 (after installing Oracle 10g BI SE One) under Windows 2000 Adv. Server (On remote Server named URAN).
    I tried to install the APEX 3.1.0.00.32 on URAN Server.
    I made all points from the list in the Oracle Database Application Express Installation Guide Release 3.1 E10496-02 (the same steps on my Personal Computer where APEX 3.1.0.00.32 is working fine).
    But!!!
    When I’m starting APEX 3.1.0.00.32 (on the Server - http://URAN:8080/apex/apex_admin) then I get errror:
    Unauthorized
    after 3 time entering the correct user & password ( from URAN accounts list ) in XDB user window.
    QUESTION 1: Why version number of Database on my PC & on Server is same, but
    APEX 3.1.0.00.32 on my PC is working fine while its is not working on the Server?
    I found out in Internet the APEX 3.1.0.00.32 is working correctly on ORACLE SE from version 10.2.0.3. But ! I have Oracle 10g Express Edition VERSION ‘s 10.2.0.1.0 and the APEX 3.1.0.00.32 is working fine there. What ?! Oracle 10g XE 10.2.0.1.0 & Oracle 10g SE 10.2.0.1.0 have different the data dictionary?
    QUESTION 2: In Oracle® Database Application Express Installation Guide
    Release 3.1 E10496-02 , in section
    4.3 About Configuring the Embedded PL/SQL Gateway
    said
    Note:
    The Oracle XML DB HTTP Server with the embedded PL/SQL gateway is not supported prior to Oracle Database 11g.
    But! My Oracle 10g Express Edition has version is 10.2.0.1.0 (less than 11g) AND …
    And APEX 3.1.0.00.32 is working fine by using XML DB HTTP Server nevertheless!
    By starting - http://127.0.0.1:8080/apex/apex_admin
    SUMMARY: Could I launch APEX 3.1.0.00.32 on the Server ( after any magic pass )?
    OR I need upgrade my Oracle 10g Standard Edition 10.2.0.1.0 to version 10.2.0.3.0 (what very difficultly and idly for me)?

    Firstly, XE 10.2.0.1 isn't the same as 10gR2 10.2.0.1
    It was released a bit later and had some fixes that were in later 10.2.0.x patchsets (and also had some different security settings). Maybe they should have gone with 10.2.1.1.
    Second, the embedded PL/SQL gateway was okay for XE, but isn't supported for Apex on the Standard/Enterprise Edition until 11g. It doesn't mean it never works, but it does mean that you shouldn't rely on it.
    That said, there are other issues with 10.2.0.1 so I'd recommend going for the latest patchset anyway.
    Thirdly, if you get the XDB login dialog box, something has gone wrong. For the embedded PL/SQL gateway, XDB is acting as a virtual webserver. Generally what should happen is you connect to the webserver (XDB) and request a page (the APEX login page) and XDB should give it to you, no questions asked.
    If it asks you to login then the XDB webserver is running but is trying to get authorisation before it gives you the page. [By the way, if it does prompt for a username/password, it is expecting a database username/password, not an apex one or an O/S one] I'd suspect something is wrong with the setup.
    What happens if you ask for a simple image like
    http://URAN:8080/i/bottom_left.gif

  • APEX 3.1.0.00.32 doesn't work with ORACLE 10g SE 10.2.0.1.0 (altered)

    I have Oracle 10g Express Edition 10.2.0.1.0 under Windows XP SP2 on my Personal Computer. There is installed the APEX 3.1.0.00.32 too , which is working fine.
    Also I have Oracle 10g Standard Edition 10.2.0.1.0 (after installing Oracle 10g BI SE One) under Windows 2000 Adv. Server (On remote Server named URAN).
    I tried to install the APEX 3.1.0.00.32 on URAN Server.
    I made all points from the list in the Oracle Database Application Express Installation Guide Release 3.1 E10496-02 (the same steps on my Personal Computer where APEX 3.1.0.00.32 is working fine).
    But!!!
    When I’m starting APEX 3.1.0.00.32 (on the Server - http://URAN:8080/apex/apex_admin) then I get errror:
    Unauthorized
    after 3 time entering the correct user & password ( from URAN accounts list ) in XDB user window.
    QUESTION 1: Why version number of Database on my PC & on Server is same, but
    APEX 3.1.0.00.32 on my PC is working fine while its is not working on the Server?
    I found out in Internet the APEX 3.1.0.00.32 is working correctly on ORACLE SE from version 10.2.0.3. But ! I have Oracle 10g Express Edition VERSION ‘s 10.2.0.1.0 and the APEX 3.1.0.00.32 is working fine there. What ?! Oracle 10g XE 10.2.0.1.0 & Oracle 10g SE 10.2.0.1.0 have different the data dictionary?
    QUESTION 2: In Oracle® Database Application Express Installation Guide
    Release 3.1 E10496-02 , in section
    4.3 About Configuring the Embedded PL/SQL Gateway
    said
    Note:
    The Oracle XML DB HTTP Server with the embedded PL/SQL gateway is not supported prior to Oracle Database 11g.
    But! My Oracle 10g Express Edition has version is 10.2.0.1.0 (less than 11g) AND …
    And APEX 3.1.0.00.32 is working fine by using XML DB HTTP Server nevertheless!
    By starting - http://127.0.0.1:8080/apex/apex_admin
    SUMMARY: Could I launch APEX 3.1.0.00.32 on the Server ( after any magic pass )?
    OR I need upgrade my Oracle 10g Standard Edition 10.2.0.1.0 to version 10.2.0.3.0 (what very difficultly and idly for me)?

    Firstly, XE 10.2.0.1 isn't the same as 10gR2 10.2.0.1
    It was released a bit later and had some fixes that were in later 10.2.0.x patchsets (and also had some different security settings). Maybe they should have gone with 10.2.1.1.
    Second, the embedded PL/SQL gateway was okay for XE, but isn't supported for Apex on the Standard/Enterprise Edition until 11g. It doesn't mean it never works, but it does mean that you shouldn't rely on it.
    That said, there are other issues with 10.2.0.1 so I'd recommend going for the latest patchset anyway.
    Thirdly, if you get the XDB login dialog box, something has gone wrong. For the embedded PL/SQL gateway, XDB is acting as a virtual webserver. Generally what should happen is you connect to the webserver (XDB) and request a page (the APEX login page) and XDB should give it to you, no questions asked.
    If it asks you to login then the XDB webserver is running but is trying to get authorisation before it gives you the page. [By the way, if it does prompt for a username/password, it is expecting a database username/password, not an apex one or an O/S one] I'd suspect something is wrong with the setup.
    What happens if you ask for a simple image like
    http://URAN:8080/i/bottom_left.gif

  • Does Informatica 7.1 work with Oracle 10g?

    Hi All,
    I have Oracle 10g (10.2.0.1.0) and I just installed Informatica 7.1. While creating a new repository in Informatica Repository Admin Console, I am getting error as:
    "Unable to create the repository content. Make sure that the database connection and the license keys are correct. Check the activity log for more details."
    I confirmed that the license keys are correct. The database connection is also good as I could connect using the same username/password in SQLPlus. The activity log says:
    WARNING : RS_39204 [Mon Mar 22 15:05:38 2010] : (5160|5392) Bad config file [Config\infrepo-es.cfg]. Has it been manually named and placed in the Config directory? The expected name is [Config\_Yrepository_0name_Z-es.cfg].
    ERROR : RS_39194 [Mon Mar 22 15:51:52 2010] : (5160|5568) Failure in running command-line request type[100401] [pmrepagent create -r "Info_Repo" -t "Oracle" -u infrep -c orcl -d "MS1252" -h sathe-3766a91ad -o 9999  -a Info_0Repo-es.lic -H "sathe-3766a91ad" -O 5001 -K 2082340862]. Error is [An error occurred while creating the repository.
    I did not change anything manually,as it says in the warning. I have no idea what the error says.
    My friend has Oracle 9i and he do not get any error like this. So does Informatica 7.1 works with Oracle 10g ?
    Please help.
    Yogini                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Hi,
    I found that with Oracle 10g you have to grant all DBA privileges to the repository user. This is not needed in Oracle 9i. Thats why I was getting error.
    Now it works fine.
    Thanks!
    Yogini

  • Does Oracle Designer 10g work with Oracle 10g Express?

    Guys:
    Does anybody know if Oracle Designer works with Oracle 10g Express?
    Regards,
    Mike Gorman

    Designer will not work on express edition of the Oracle Database. You will need the Standard or the Enterprise Edition of the Database.

  • Insert Record with Parent/Child Tables doesn't work with Oracle - unlike AC

    Hi,
    I just Migrated a MS Access 2010 Database to an Oracle 11g Backend with the SQL Developer Tool.
    The Migration went fine, all the Tables and Views are migrated.
    I'm working with MS Access as Frontend.
    The application has some Datasheets with Subdatasheets with Parent/Child Relationship. (1-n Relationship)
    After changing to Oracle, it's not possible, to Insert a new Record in a Subdatasheet I always get the following Error Message:
    "The Microsoft Access database engine cannot find a record in the table 'xxxx' with key matching field(s) 'zzzzz'"
    It used to work perfect with the MS Access Backend, do I need a trigger which first adds the child Record ?
    Or what should I do?
    Thank you

    Hi Klaus,
    Thanks for your answer. I still haven't solved my problem. The only way would be to use a singel 1:n Relationship, but in fact I need a n:m Relationship.
    I tried the same scenario with a new Access Application, same result.
    To clearify my problem.
    Goal: Parent Form with Parent Records, Linked Child Form with Child Records in a Datasheet View => Insert of a NEW Child Record.
    I have 3 Tables (table1 = Parent tabel, table2 = Child Table, table12 = n:m Tabel with PK and two FK)
    The Recordsource of the Parent Form is Tabel1
    The Recordsource of the Child Form is Table2 joined with Table12.
    In my Old Access Project, Access Triggered the Insert and filled Table12 with the NEW PK of Table2.
    It seems like Access can't do that anymore....
    I'm pretty desperate and I'm sure it is just a litte thing to fix.....

  • Can i work with oracle 10g express edition by connecting it with visuval studio 2010?

    i have oracle 10g-express edition,and visuval studio 2010, can i have a connectivity between these two?or it requires any additional installations,or any special procedures for installing it? HELP ME..

    You might want to post this in the Oracle 10g XE support forum, where you might get a better response. The is is the support form for Oracle App Express..
    Thank you,
    Tony Miller
    Monroe, WA

  • Response.sendRedirect doesn't work with IAS 10g

    Hello,
    I'm moving my application to JDK 1.4 and IAS 10g.
    It's alright, but I noticed one problem.
    For long operation I created my way to display my "Working in progress..." page.
    I create an HTML file into a cache folder and I redirect to that file that reload itself every five seconds.
    Once the operation is terminated it change a session variable that is loaded by the HTML page and it ends the "Working in progress..." message.
    The problem is that in IAS 10g it doesn't redirect to the HTML file immediately, it seems that "wait" the operation is almost finished: il redirect to the HTML file, and after 5 seconds it loads the end message of the operation.
    This is the part of the code:
    [WRITE FILE IN c:\application\tools\template\cache as tempxyz.html]
    String urlToLoad = "/myApp/tools/template/cache/tempxyz.html";
    response.sendRedirect(urlToLoad);
    [OPERATIONS]
    [CHANGE SESSION VALUE]
    -END-
    The "response.sendRedirect(urlToLoad);" instruction pass without errors.
    I hope I explained my situation.
    Thanks in advance for any suggestions,
    EP

    Thanks Qiang,
    Ive done exactly as youve said and it must be a rewriting problem as you suggested. Here is the header from accessing the servlet on the Linux host machine (IP 192.168.5.121 called 'BEAST')
    --10:12:27-- http://192.168.5.121:7780/webapp/test
    => `test'
    Connecting to 192.168.5.121:7780... connected.
    HTTP request sent, awaiting response...
    1 HTTP/1.1 302 Moved Temporarily
    2 Date: Wed, 11 May 2005 09:12:27 GMT
    3 Server: Oracle-Application-Server-10g/10.1.2.0.0 Oracle-HTTP-Server
    4 Content-Length: 183
    5 Cache-Control: private
    6 Location: http://BEAST:7779/webapp/testJ.jsp
    7 Keep-Alive: timeout=15, max=100
    8 Connection: Keep-Alive
    9 Content-Type: application/octet-stream
    Location: http://BEAST:7779/webapp/testJ.jsp [following]
    --10:12:27-- http://beast:7779/webapp/testJ.jsp
    => `testJ.jsp.3'
    Resolving beast... done.
    Connecting to beast[127.0.0.1]:7779... connected.
    That worked fine. Here is the header on my windows machine on the network ( IP 192.168.5.120) :
    HTTP/1.1 302 Moved Temporarily
    Date: Wed, 11 May 2005 09:03:21 GMT
    Server: Oracle-Application-Server-10g/10.1.2.0.0 Oracle-HTTP-Server
    Content-Length: 183
    Cache-Control: private
    Location: http://BEAST:7779/webapp/testJ.jsp
    Keep-Alive: timeout=15, max=100
    Connection: Keep-Alive
    Content-Type: application/octet-stream
    I think the problem must be that the response is telling it to redirect to BEAST (which is the name of the server) but the windows box cant resolve the name. Must be why i get the page cannot be displayed.
    The code in the servlet 'test' to redirect is just:
    response.sendRedirect("testJ.jsp");
    Any ideas would be much appreciated on how I can fix this other than setting up a local DNS server?!
    Cheers,
    Rob.

  • Quck Find/Replace doesn't work with Oracle Db Proj (ODT 11.1.0.5.10 beta)

    There seems to be a bug with the Oracle Database Project that prevents Quick Find and Quick Replace from working. To recreate, just open the new Oracle Database Project, open a sql script, ctrl-F, search for a text string. The text will not be found.

    I guess the work around (not so ideal) is to use Find in Files (shift/ctrl-F) and Replace in Files (shift/ctrl-H).

  • Web Cache doesn't work with Oracle Enterprise Manager

    In my Oracle 9i Application Server Release 2 since I have changed the administrator and invalidator password in the Web Cache Manager the Web Cache appears as unavailable in the Oracle Enterprise Manager, but it's working!! Any idea?

    You have to modify the password manually in OEM's target.xml.

  • SetRollbackOnly() doesn't work with Oracle

    Hi all,
    I'm using an Oracle database and Weblogic server. However, when I execute the following code (which is contained within an ejb session bean method):
    // Lookup datasource
    Context ctx = new InitialContext();
    DataSource ds = (DataSource) ctx.lookup(DATASOURCE);
    connection = ds.getConnection();
    // Insert some data
    connection.createStatement().executeUpdate("some insert statement");
    // Rollback the insert statement
    sessionContext.setRollbackOnly()... the insert statement is not rolled back even though I explicitly call setRollbackOnly().
    Could anyone help?

    Transaction attribute for the method is 'Required'.
    Any suggestions...?

  • SunOneAppServ with Oracle 10g vers. 10.1.0.3.0

    Hello,
    I'm using two different versions of SunOneAppServer,
    Sun Java System Application Server Enterprise Edition 8.1_02(build b19-p08) and
    Sun Java System Application Server 7 2004Q2UR2.
    These two instances of Application Servers work over two different databases, Oracle 8 and Oracle 10g vers. 10.1.0.3.0.
    When working with Oracle 10 I get locks over some records during transactions and that transactions don't run correctly so the records remain locked and all following transactions go on waiting indefinitely or until I kill the session using toad.
    Looking at the query locking the record it seems to me it's a query done by the application server.
    Using the same software and making the same operation over the database with Oracle 8 this doesn't happen.
    Does anyone has the same problem or knows how to solve it?
    A collegue of mines told me that these versions of application servers doesn't support Oracle 10g. Is it true?

    Both versions of the appserver below will work with Oracle 10g.
    There is not enough details as to asist with your problem, but it could well be a change in semantics for locking in 10g that is causing your issue

  • Oracle 11g XE not working with oracle BI publisher 10g after enabling ACL

    Hello,
    I previously work with oracle 10gXE and Oracle BI publisher 10g and it work fine. now i install oracle 11g XE and try to configure it with oracle Bi Publlisher, it show this error
    "ORA-29273: HTTP request failed ORA-06512: at "SYS.UTL_HTTP", line 1324 ORA-12570: TNS:packet reader failure" after runing the ACL package to neable network service.
    on the database.
    Please can any body tell be why this is not working. Tanx.

    You'll need to add the apex engine owner to the ACL (Access Control List). Depending on your version of apex the user name varies. i.e. 4.0 is APEX_040000
    See Joel's blog for info about the ACL and APEX.
    [http://joelkallman.blogspot.com/2010/10/application-express-network-acls-and.html]

  • Does ORACLE functions work with Oracle Database 10G

    Hi,
    I am wondering if ORACLE functions work with Oracle Database 10G or is it mandatory to use OCI functions?
    Thanks in advance!

    I was able to run a simple query with ora_* functions using 10g on Windows.
    The Oracle OCI calls used by PHP's ora extension still exist in the Oracle 10g libraries
    But I cannot recommend this obsolete extension.
    -- cj

  • Does JPublisher 10g work with Oracle 9i

    I want to expose PL/SQL as Web Services and need to know if using JPublisher from JDeveloper 10.1.2.0 will work

    JPublisher from JDev 10.1.2 should work with Oracle 9i databases.

Maybe you are looking for