Oc4j and PreparedStatement

Hello!
Oracle Application Server 10g Release 3 (10.1.3.0.0) have problems with PreparedStatement java class?
WebApp code like ------
PreparedStatement pst4 = null;
pst4 = conn4.prepareStatement("UPDATE users SET LAST_LOG_DATE = SYSDATE WHERE login=?");
pst4.setString(1,login);
rs4 = pst4.executeQuery();
System.out.println(login);
} catch (SQLException e2) {
if (logger.isErrorEnabled()) {
logger.error("login() - connection in "+this.getClass().getName()+" failed "
+ e2.getMessage());
logger.error("UPDATE users SET LAST_LOG_DATE = SYSDATE WHERE login=?");
throw SQLException with message
" SQL string is not Query "
On Tomcat all working with out exceptions...
Thanks
Message was edited by:
rrrookie

Hi,
We run into the same problem and found, that it has nothing to do with OAS itself, but related to Oracle Driver.
We discovered, that OAS comes with older version of ojdbc14.jar (10.1.0_2) than we used (10.2.0.2 ). Creation of the shared library based on version 10.2.0.2 could solve the problem, because this version tolerates use of executeQuery( ) for Insert, Delete and Update.
Anyway, because such use of this executeQuery( ) method does not look correct, I would suggest to use method executeUpdate() instead.
Thanks.

Similar Messages

  • Too many connections - even after closing ResultSets and PreparedStatements

    I'm getting a "Too many connections" error with MySQL when I run my Java program.
    2007-08-06 15:07:26,650 main/CLIRuntime [FATAL]: Too many connections
    com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException: Too many connections
            at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:921)
            at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2870)
            at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:812)
            at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:3269)
            at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1182)
            at com.mysql.jdbc.Connection.createNewIO(Connection.java:2670)I researched on this and found out that I wasn't closing the ResultSet and the PreparedStatement.
    The JDBC connection is closed by a central program that handles connections (custom connection pooling).
    I added the code to close all ResultSets and PreparedStatements, and re-started MySQL as per the instructions here
    but still get "Too many connections" error.
    A few other things come to mind, as to what I may be doing wrong, so I have a few questions:
    1) A few PreparedStatements are created in one method, and they are used in a 2nd method and closed in the 2nd method
    does this cause "Too many connections" error?
    2) I have 2 different ResultSets, in nested while loops where the outer loop iterates over the first ResultSet and
    the inner loop iterates over the second ResultSet.
    I have a try-finally block that wraps the inner while loop, and I'm closing the second ResultSet and PreparedStement
    in the inner while loop.
    I also have a try-finally block that wraps the outer while loop, and I'm closing the first ResulSet and PreparedStatement
    in the outer while loop as soon as the inner while loop completes.
    So, in the above case the outer while loop's ResultSet and PreparedStatements remain open until the inner while loop completes.
    Does the above cause "Too many connections" error?
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    The following is relevant sections of my code ( it is partially pseudo-code ) that shows the above 2 cases:
    init( Connection jdbcConnection ){
       String firstSQLStatement = "....";
       PreparedStatement ps1 = jdbcConnection.prepareStatement( firstSQLStatement );
       String secondSQLStatement = "....";
       PreparedStatement ps2 = jdbcConnection.prepareStatement( secondSQLStatement );
       String thirdSQLStatement = "....";
       PreparedStatement ps3 = null;
       ResultSet rsA = null;
       try{
            ps3 = jdbcConnection.prepareStatement( thirdSQLStatement );
            rsA = ps3.executeQuery();
            if( rsA.next() ){
                   rsA.getString( 1 );
       }finally{
            if( rsA != null )
                   rsA.close();
            if( ps3 != null )
              ps3.close();
       //Notice, how ps1 and ps2 are created here but not used immediately, but only ps3 is
       //used immediately.
       //ps1 and ps2 are used in another method.
    run( Connection jdbcConnection ){
         ResultSet rs1 = ps1.executeQuery();
            try{
               while(rs1.next()){
                    String s = rs1.getString();
                    ps2.setString(1, s);
              ResultSet rs2 = ps2.executeQuery();
                    try{
                   while(rs2.next()){
                        String s2 = rs2.getString();
                    }finally{
                   if( rs2 != null )
                     rs2.close();
                   if( ps2 != null )
                     ps2.close();
         }catch( Exception e ){
              e.printStackTrace();
         }finally{
            if( rs1 != null )
                  rs1.close();
               if( ps1 != null )
                  ps1.close();
    //Notice in the above case rs1 and ps1 are closed only after the inner
    //while loop completes.
    }I appreciate any help.

    Thanks for your reply.
    I will look at the central connection pooling mechanism ( which was written by someone else) , but that is being used by many other Java programs others have written.
    They are not getting this error.
    An addendum to my previous note, I followed the instructions here.
    http://dev.mysql.com/doc/refman/5.0/en/too-many-connections.html
    There's probably something else in my code that is not closing the connection.
    But I just wanted to rule out the fact that opening a PreparedStatement in one method and closing it in another is not a problem.
    Or, if nested ResultSet loops don't cause the problem.
    I've read in a few threads taht "Too many connections" can occur for unclosed RS and PS , and not just JDBC connections.

  • OC4J and FOP installation

    Hi,
    We would like to use the PDF printing of 3.0.1
    I am trying to install FOP but I do not have any knowledge in OC4J and Java ... so I am kind a lost right now.
    I am following the installation guide of OC4J standalone (http://download.oracle.com/docs/cd/B32110_01/web.1013/b28950/install.htm#BABIBGCA)
    I was wondering :
    1- do I need to install oc4j standalone in a separate Oracle Home ?
    2- There is already an OC4J installed in my db Oracle Home , I guess for emdbconsole. So , I created a new directory called oc4j_sa and unzipped the file. When I start OC4J with oc4j -start , it does not give me the prompt back. Then , I can access the web page with port 8888 (192.168.0.21:8888) , but 192.168.0.21:8888/em fails . So I cannot deploy the FOP war file.
    Any pointers or guidance would be great.
    Thanks
    Francis.
    P.S. :
    Oracle 10.1.0.5
    Oracle Linux (RH 4)

    OK, I finally got to the deployment of FOP but now it generates a corrupted PDF.
    Are there any log files that I can check ?
    I created a new Oracle_home for OC4J and ran "EM" to deploy FOP and everything worked like in the viewlet.
    Now I did the setup in APEX and set the following :
    Standard Support
    Print Server Protocol HTTP
    Print Server Host Address 192.168.0.21
    Print Server Port 8888
    Print Server Script /fop/apex_fop.jsp
    I created a sample application to test. In a report , I added the print link.
    When I clic Print, the pdf generated is corrupted and does not work.
    Thanks
    Francis.

  • OC4J and Oracle forms causes ie or firefox to not respond when running form

    When I run a form in Oracle Forms 10g, I have OC4J running, and have the following displayed:
    E:\Windows\system32>E:\DevSuiteHome_5\jdk\bin\java -Doracle.security.jazn.confi
    g=E:\DevSuiteHome_5\j2ee\DevSuite\config\jazn.xml -Doracle.home=E:\DevSuiteHome_
    5 -DORACLE_HOME=E:\DevSuiteHome_5 -jar E:\DevSuiteHome_5\j2ee\home\oc4j.jar -use
    rThreads -config E:\DevSuiteHome_5\j2ee\DevSuite\config\server.xml
    07/11/20 23:11:44 Warning: Error reading transaction-log file (/E:/DevSuiteHome_
    5/j2ee/DevSuite/persistence/transaction.state) for recovery: premature end of fi
    le
    07/11/20 23:11:44 Forced or abrupt (crash etc) server shutdown detected, startin
    g recovery process...
    07/11/20 23:11:44 Recovery completed, 0 connections committed and 0 rolled back.
    07/11/20 23:11:44 Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)
    initialized
    07/11/20 23:18:10 FormsServlet init():
    configFileName: E:\DevSuiteHome_5/forms/server/formsweb.cfg
    testMode: false
    I am running vista, and have the latest version of the dev suite. Does anybody know how I can fix this problem?

    You cannot use Internet Explorer on Windows Vista to run Web Forms.
    <p>But you CAN run web forms through Netscape or Firefox. But you first need to disable Java in the browser.
    <p>And to run OC4J on Vista, you need to set its compatibility mode to Windows XP.
    <p>See my notes on OC4J and "Browser Settings" in this thread:<br>   
    Forms 10g installed and running on Windows Vista

  • Report display is different in report builder, local oc4j and app server

    Hi guys,
    we upgrade reports from sql report writer into report 10g. In the report 10g builder,
    the report format looks fine. but if i use the url as below
    http://applicationserver/reports/rwservlet?report=test.rdf&userid=username/password@service&desformat=pdf&destype=cache
    so the format will be mess up whatever i use this url in my local oc4j or i deployed it into 10g application server. and the format is different in oc4j and application server. Why this issue happend?
    Thanks in advance,
    Appcat

    Hello,
    They are a Fix Pack higher than you which may explain why it's broken on their server.
    Download the Fix Pack for R2 and see if you can duplicate the issue.
    Thank you
    Don

  • DataSource and PreparedStatement

    I am using DataSource and PreparedStatement in weblogic8.1 for a J2EE application.
    It works if we use only EJB..but if we use enterprise app. i.e. servlets,jsp,ejb etc.. it does not work.
    Can somebody tell the reason behind it??

    Why do you feel this is an issue with the PreparedStatements and not just the DataSource? Are you sure you have configured the DataSource correctly for your platforms outside your ejb container?

  • What is the different between statement and preparedstatement?

    hi,
    recently i have attended a telephonic interview. they asked me what is the different between statement and preparedstatement? and when u will use them? Hi! can any one say me the original difference??

    sorry dear,
    i am already shortlisted. and monday is my HR round.
    . Every 1 is not like u.
    So you have read the examples and explanations that you found when you googled, and you have read the javadoc and you still don't understand? And you are shortlisted? For what? I hope you won't do server programming.
    I will give you a few hints.
    Escaping of data
    Storing of dates
    Safer
    Faster

  • Performance Problem - MS SQL 2K and PreparedStatement

    Hi all
    I am using MS SQL 2k and used PreparedStatement to retrieve data. There is strange and serious performance problem when the PreparedStatement contains "?" and using PreparedStatement.setX() functions to set its value. I have performed the test with the following code.
    for (int i = 0; i < 10; i ++) {
    try {
    con = DBConnection.getInstance();
    statement = con.prepareStatement("SELECT * FROM cardno WHERE car_no = '" + cardNo + "'");
    // statement = con.prepareStatement("SELECT * FROM cardno WHERE car_no = ?");
    // statement.setString(1, cardNo);
    rs = statement.executeQuery();
    if (rs.next()) {
    catch(SQLException e) {
    e.printStackTrace();
    finally {
    try {
    rs.close();
    statement.close();
    catch(SQLException e) {
    e.printStackTrace();
    Iteration Time (ms)
    1 961
    10 1061
    200 1803
    for (int i = 0; i < 10; i ++) {
    try {
    con = DBConnection.getInstance();
    // statement = con.prepareStatement("SELECT * FROM cardno WHERE car_no = '" + cardNo + "'");
    statement = con.prepareStatement("SELECT * FROM cardno WHERE car_no = ?");
    statement.setString(1, cardNo);
    rs = statement.executeQuery();
    if (rs.next()) {
    catch(SQLException e) {
    e.printStackTrace();
    finally {
    try {
    rs.close();
    statement.close();
    catch(SQLException e) {
    e.printStackTrace();
    Iteration Time (ms)
    1 1171
    10 2754
    100 18817
    200 36443
    The above test is performed with DataDirect JDBC 3.0 driver. The one uses ? and setString functions take much longer to execute, which supposed to be faster because of precompilation of the statement.
    I have tried different drivers - the one provided by MS, data direct and Sprinta JDBC drivers but all suffer the same problem in different extent. So, I am wondering if MS SQL doesn't support for precompiled statement and no matter what JDBC driver I used I am still having the performance problem. If so, many O/R mappings cannot be used because I believe most of them if not all use the precompiled statement.
    Best regards
    Edmond

    Edmond,
    Most JDBC drivers for MS SQL (and I think this includes all the drivers you tested) use sp_executesql to execute PreparedStatements. This is a pretty good solution as the driver doesn't have to keep any information about the PreparedStatement locally, the server takes care of all the precompiling and caching. And if the statement isn't already precompiled, this is also taken care of transparently by SQL Server.
    The problem with this approach is that all names in the query must be fully qualified. This means that the driver has to parse the query you are submitting and make all names fully qualified (by prepending a db name and schema). This is why creating a PreparedStatement takes so much using these drivers (and why it does so every time you create it, even though it's the same PreparedStatement).
    However, the speed advantage of PreparedStatements only becomes visible if you reuse the statement a lot of times.
    As about why the PreparedStatement with no placeholder is much faster, I think is because of internal optimisations (maybe the statement is run as a plain statement (?) ).
    As a conclusion, if you can reuse the same PreparedStatement, then the performance hit is not so high. Just ignore it. However, if the PreparedStatement is created each time and only used a few times, then you might have a performance issue. In this case I would recommend you try out the jTDS driver ( http://jtds.sourceforge.net ), which uses a completely different approach: temporary stored procedures are created for PreparedStatements. This means that no parsing is done by the driver and PreparedStatement caching is possible (i.e. the next time you are preparing the same statement it will take much less as the previously submitted procedure will be reused).
    Alin.

  • How to make OC4J and IIS on diffrent machines ?

    Hi,
    How to make OC4J and IIS running diffrent machines. following document tells use "standalone ONS daemon",Can anybody tell what standalone ONS daemon means and steps to be done to make IIS working on diffrent machine
    http://download-west.oracle.com/docs/cd/B25221_03/web.1013/b25211/oc4jplugin.htm#i638738
    Thanks & Regards
    Vino joy

    sender,
    the quantize menu is in the top info box in the arrange.
    if you double click on it, an extended parameter box appears with a lot of quantizing options. also RTFM about this bit.
    in the sample editor, there is an audio quantize feature.
    but it is old, and probably hasn't been updated in ten years........try it, you
    'll prolly hate it.
    there is also a quantize audio/groove plug, in the special menu.
    it works....sorta.
    if you're talkin' drums, on seperate tracks, like kik on one, and snr on the next, etc., try strip silence to cut the loop/file up, then select same in the arrange trk and quantize this, as above. (info box).
    this does work well provided you know just where you want the feel to be.
    you could also try making a groove template of the original clip/loop and use this as a timing reference.
    this also works well if you can get a clean footprint of the audio.
    best,
    DR9

  • How Standalone OC4J and the Oracle Application Server linked to each other

    Hi ,
    Please let me know what is the relation between a Standalone OC4J and the Oracle Application Server ?
    In my application The Oracle Application Server is installed in C drive and there is a Stand alone oC4j .
    Please tell me how they are linked to each other .
    Thank you .

    It depends on your need and what features and functionality of Oracle Application Server you are interested in. Note that OC4J is a component of Oracle Application Server that can run as a standalone component or within Oracle Application Server. Question #6 in earlier mentioned FAQ document states:
    OC4J standalone is J2EE 1.3 compatible (1.4 and 1.5 too in later releases of OC4J) and is able to be used in both development and small scale production environments. OC4J standalone provides its own inbuilt HTTP/S listener to allow clients to execute Web applications that it has deployed. Application deployment and server configuration of OC4J standalone is performed by the manual editing of a simple set of XML files.
    For large scale enterprise deployments, the Oracle Application Server product is likely to be more suitable with its comprehensive feature set including Oracle HTTP Server, process monitoring and management capabilities, and its configuration and management console.
    So if you are happy with what you see in standalone OC4J and scalability isn't an issue for you, you can stay with standalone OC4J and don't need to move to Oracle Application Server.
    PS: If you do decide to use OC4J that's embedded with Oracle Application Server, you can't move your standalone OC4J inside Oracle Application Server. You will have to reconfigure embedded OC4J again (as you might have done with standalone OC4J) and redeploy your applications.
    Hope this helps.
    Thanks
    Shail

  • Is the Lastest OC4J and AS9i work with oracle 8i ?

    Hi, a quick question:
    Is the lastest OC4J and Oracle AS9i works/compatible with Oracle 8i?

    Yes, you can use OC4J and Oracle9iAS with Oracle8i also.
    -Arun

  • Standalone oc4j and oracle 9i database on the same windows xp machine

    I m trying to deploy my j2ee application in my local system using standalone oc4j container(Oracle Containers for J2EE 10g (10.1.3.1)).To configure OC4j,I had to mention ORACLE_HOME=d:\oc4j as a user defined env variable.after that the oc4j started running normally.then i installed oracle 9i database in the same system to use it as the database for the application.During installation it prompts that ORACLE_HOME is alredady set.However the installation completes successfully.But when i try opening sql plus,it throws and error asking to check oracle_home.Its only after changing oracle home to d:\oracle,that sql plus opened and i could log in to it.But after that oc4j would not run saying it cannot find relevant files.Is it not possible to have standalone oc4j and a database for a J2ee application on the same system.if its possible,how can we go ahead?Thanks in advance

    user549113,
    Problem with ORACLE_HOME has been discussed several times already in this forum. I suggest you search the forum archives for "ORACLE_HOME".
    Good Luck,
    Avi.

  • OC4J and login failure

    'Install' the embedded OC4J in JDev9i (<Jdev9i_HOME>\j2ee\home) and assign an administrative password of admin.
    Deployment from JDev9i works with no issue - URL uses port 8888.
    Problem is when shutdown machine and come back in I have to go back and reinstall the embedded OC4J. It seems to lose
    the fact that it was installed and had a password of admin.
    What gives - Thanks - Ken Cooper

    First of all i had the exact same problem for few weeks ago.
    I was advised to download the Oracle9iAS Containers for J2EE Standalone ( http://technet.oracle.com/software/products/ias/devuse.html )
    then make own oc4j directory and install this version. This will work!
    Note that if you work with bc4j you need to adjust your configuration
    according to this doc:
    http://otn.oracle.com/products/jdev/htdocs/bc4j9ioc4j.html
    and do the configuration manually.
    You will never have to reinstall oc4j and if for any reason the oc4j does not work properly, you can simply delete the oc4j directory and setup a clean one.
    succes!
    greetz jaime

  • OC4J and JDK version compatibility

    Does anyone know if OC4J 1.0.2.2.1 is certified to work with JDK1.3.1?
    The reason being :
    1. We have a situation where the CPU gets full frequently because of OC4J.
    2. When OC4J is recycled the app works fine. App uses JSP, servlets and JDBC connection to Oracle 8.1.7
    3. Is there any way to find if OC4J 1.0.2.2.1 is not supposed to be used with JDK1.3.1?
    Finally, is there any URL that provides this information so that I can check the same with later versions of OC4J and JDK?
    Thanks,

    OC4J 1.0.2.2.1 is not certified with 1.3.1.x. Certification information should be available in http://metalink.oracle.com. You should have a CSI to get into Metalink.
    thanks
    debu

  • OC4J and OracleAQ

    I've developed an EJB to use in OC4J. This EJB tries to access a Queue in an Oracle8i Database, but i always get an error, saying the connection is invalid. The same code executing as a normal Java Class works fine. Is there any problem with OC4J and oracleAQ?

    I have successfully used AQ with OC4J. I have 2 beans where one bean writes to the queue and another bean reads from the queue. As far as connection is concerned, when you move the EJBs from JServer to OC4J, you can't use the KPRB driver. You can use either Thin/Thick driver. May be you could check that.
    --Rajesh                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Maybe you are looking for