IO Exception Broken Pipe ORA-17002 while using connection pooling

Hi
We are experiencing "broken pipe ORA-17002 error" when using connection pooling. This seems to be a common error when implementing connection pooling, but I didn't find any solution anywhere.
we are using Oracle 9i 9.2.0.1 JDBC thin driver
Our database is Oracle 8.1.7 running on HP Unix
The middle tier(Tomcat) runs on RedHat linux server
We are using JDK1.3
It seems the connections automatically get stale or bad after certain period of time.Iam checking to see if the connection is closed, before giving the connection from the pool to the appilcation.It seems its still open.But when I start using the connection to open a callable statement or setAutocommit to false, it says Broken pipe or No more data to read from the socket.
We are implementing our own connection pooling class(we experimented with OracleConnectionCacheImpl but it too gave the same errors).
Does anybody have a solution for this problem??
Is there a workaround for this?I would like to know how connection pooling is implemented in most of the applications that use oracle database?Or do we need to explicitly test the connection before using it, and reopen a connection if that is bad??
Thanks
Anil

kalle
Thank you very much for your advice!!!
Like you said, I started to check whether the connections are fine before giving them from the pool.I am executing a simple "select 'anil' from dual" and if its fine only then I return the connection. So far it seems to be fine. Also I am reopening the connections(closing the old ones and opening new connections) after every 12 hours.
As far as the JDBC driver is concerned, I already tried with Oracle 8i driver, it gave the same problems. I read that 9i driver might solve this problem, so I changed to the latest 9i driver (classes12_g.zip).
Sometimes before(before I started checking whether the connection is good )the application used to hang up at the point where I am issuing setAutoCommit(false).It never comes out from that statement.Is this something to do with theconnections being closed?
What I am afraid is, will the appilation get hung up even after I check the connection with select query and then issue autocommit(false)??
Or will it hang up while I check with a select query??
As long as it doesn't hung up, I am fine. Because i am cathching the exceptions.
Thanks In ADVANCE
Anil

Similar Messages

  • ORA-22990 ( Cannot span lob... ) while using connection pooling...

    Hi all, I am maintaining a web site that has lots of requests ( about 10 requests a second ) to an Oracle table that has a BLOB field. Those requests create new blobs, updates them and reads them... My program worked fine until I started using connection pooling ( Before that, I used a single connection that was initialized at startup ). Although I had to synchronized the methods that interact with blob field, everything worked great. So now, to optimize my site, I want to use connection pooling so that even if my methods are synchonized on the connection object, there will be more than one connection available so it will not affect performance.
    So once I introduced my connection pooling system with the oracle.jdbc.pool.OracleConnectionCacheImpl class, I started getting ORA-22990 ( Cannot span lob objects... ). I get the error on the flush() method when I try to write the blob to the database. Here is my function that writes a row in the databse.
      private synchronized void writeSession(CapSession pSession) throws Exception
            javax.sql.PooledConnection pc = pool.getPooledConnection();
            Connection conn = pc.getConnection();
            CallableStatement stmt=conn.prepareCall(writeObjSQL);
            stmt.setString(1,pSession.getSessionId()+pSession.getPassword());
            stmt.setLong(2,pSession.getLastAccess());
            stmt.setLong(3,pSession.getTimeout());
            stmt.registerOutParameter(4,java.sql.Types.BLOB);
            stmt.executeUpdate();
            oracle.sql.BLOB blob=(BLOB)stmt.getBlob(4);
            OutputStream os=blob.getBinaryOutputStream();
            ObjectOutputStream oop=new ObjectOutputStream(os);
            oop.writeObject(pSession);
            oop.flush();
            oop.close();
            os.close();
            stmt.close();
            conn.commit();
            conn.close();
            pc.close();
      } If anyone could help me, I would deeply appreciate it!
    Thank you for your time.

    kalle
    Thank you very much for your advice!!!
    Like you said, I started to check whether the connections are fine before giving them from the pool.I am executing a simple "select 'anil' from dual" and if its fine only then I return the connection. So far it seems to be fine. Also I am reopening the connections(closing the old ones and opening new connections) after every 12 hours.
    As far as the JDBC driver is concerned, I already tried with Oracle 8i driver, it gave the same problems. I read that 9i driver might solve this problem, so I changed to the latest 9i driver (classes12_g.zip).
    Sometimes before(before I started checking whether the connection is good )the application used to hang up at the point where I am issuing setAutoCommit(false).It never comes out from that statement.Is this something to do with theconnections being closed?
    What I am afraid is, will the appilation get hung up even after I check the connection with select query and then issue autocommit(false)??
    Or will it hang up while I check with a select query??
    As long as it doesn't hung up, I am fine. Because i am cathching the exceptions.
    Thanks In ADVANCE
    Anil

  • Web Service Error: java.sql.SQLException: Io exception: Broken pipe

    Hi,
    I am using JDeveloper PL/SQL web service generator. After some time we start receiving the "java.sql.SQLException: Io exception: Broken pipe" exception when we invoke the web service. I've noticed that the error starts occuring once all the connections in the database have been closed.
    Here are the Data Source configurations I tried using:
    <data-source name="jdev-connection-SACS" class="com.evermind.sql.DriverManagerDataSource" location="jdbc/SACSCoreDS" xa-location="jdbc/xa/SACSXADS" ejb-location="jdbc/SACSDS" pooled-location="jdbc/MACSPooledDS" connection-driver="oracle.jdbc.driver.OracleDriver" username="xxx" password="xxxx" url="jdbc:oracle:thin:@test:1521:SACS" inactivity-timeout="30" connection-retry-interval="3" max-connections="5" min-connections="0" wait-timeout="20"/>
    AND I also tried:
    <data-source name="jdev-connection-SACS" class="com.evermind.sql.DriverManagerDataSource" location="jdbc/SACSCoreDS" xa-location="jdbc/xa/SACSXADS" ejb-location="jdbc/SACSDS" pooled-location="jdbc/SACSPooledDS" connection-driver="oracle.jdbc.driver.OracleDriver" username="xxxx" password="xxxx" url="jdbc:oracle:thin:@xxxx:1521:SACS" inactivity-timeout="30"/>
    That did not make any changes.
    I then changed ConnectionContext.KEEP_CONNECTION to ConnectionContext.CLOSE_CONNECTION in the <name>Base.sqlj:
    public void release() throws SQLException
    { if (__tx!=null && __onn!=null) __tx.close(ConnectionContext.CLOSE_CONNECTION);
    __onn = null; __tx = null;
    That did not help either. We are running these web services on the standalone OC4J and Oracle 8.1.7.2 database with the MTS installed on it.

    Hi,
    I don't use JDeveloper to develop stored procedure web services. However, I do use WebServicesAssembler.jar to generate stored procedure web services.
    I had the same problem as you did. After some research in this forum, I was informed that it's a bug in the web services generator itself. I was also informed that the newest version of WebServicesAssembler.jar is supposed to fix the problem.
    If you want, you can always write a batch job to restart the OC4J periodically. The command is
    dcmctl -ct oc4j -co home
    If I come across the posting containing the answer to your solution, I will forward it to you.
    Good luck
    Jack

  • IO Exception: Broken Pipe

    Hi,
    I use WLS6.0/Linux. I'm accessing EJBs on the server from a standalone Java
    Client application. From time to time, I suddenly get this error:
    IO Exception: Broken Pipe
    The error has not been reproducible (so far...). Any ideas what causes this
    error?
    thx
    Heiko

    I too am having the same problem with using an OAS 9.0.4. server talking to a 9iAS db. I have a Struts application that if you leave the application over night will have broken pipes in the morning. The connections should not have persisted, but might have. This problem only happens when the Servlet is left up and no activity over night.
    They claim that no restart of the server or DB happened during that time so I am betting on a timeout somewhere in the system too.
    I have two problems:
    One to set up a situation that reproduces the problem.
    Two finding out some way through JDBC to effectively test for this situation and
    be able to re-create, or re-open a connection to continue processing.
    Error in fetcAllDBRecord java.sql.SQLException: Io exception: Broken
    pipe06/09/26 09:05:25 java.sql.SQLException: Io exception: Broken pipe
    06/09/26 09:05:25 at
    oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:189)
    06/09/26 09:05:25 at
    oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:231)
    06/09/26 09:05:25 at
    oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:345)
    06/09/26 09:05:25 at
    oracle.jdbc.driver.OracleStatement.open(OracleStatement.java:717)
    06/09/26 09:05:25 at
    oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2605)
    06/09/26 09:05:25 at
    oracle.jdbc.driver.OracleStatement.executeQuery(OracleStatement.java:777)
    ......app specific levels
    Any help would be appreciated.
    ---John Putnam

  • Java.sql.SQLException: Io exception: Broken pipe

    To whom it may concern:
    Anyone who can help me with my problem? We have Java application(Loading2Staging) that calls a series of stored procedures in Oracle. This job takes about 30 hours to complete. We have other Java applications that is running and calling Oracle on the same machine and database. All of the applications are using "Java connection pooling". I'm encountering problem with the said application. When Loading2Staging is running and then other jobs would start to establish a connection, Loading2Staging then fails with this error: java.sql.SQLException: Io exception: Broken pipe
    The procedures of Loading2Staging is taking too long to complete. So my question is, "Is the job failing because of its inactivity or do some other applications steal the 'connection pooling' assigned to it for it to run smoothly?"
    If that's the case, could I create a "dedicated connection" or "connection pooling" to prevent the stealing of connection among jobs?
    This is a very urgent issue. Your immediate response will be much appreciated.
    Thank you.
    wletmp5

    Having exactly the same problem, does anybody know where the problem is?
    Thanks
    PD

  • Issue while creating connection pool in weblogic using SERVICE NAME

    Found two issues while creating connection pool in weblogic using SERVICE NAME
    1. While running apps from jdeveloper using xxx-jdbc.xml
    weblogic.common.ResourceException: Could not create pool connection. The DBMS driver exception was: Io exception: The Network Adapter could not establish the connection
         at weblogic.jdbc.common.internal.ConnectionEnvFactory.createResource(ConnectionEnvFactory.java:253)
         at weblogic.common.resourcepool.ResourcePoolImpl.makeResources(ResourcePoolImpl.java:1109)
         at weblogic.common.resourcepool.ResourcePoolImpl.makeResources(ResourcePoolImpl.java:1033)
         at weblogic.common.resourcepool.ResourcePoolImpl.start(ResourcePoolImpl.java:214)
         at weblogic.jdbc.common.internal.ConnectionPool.doStart(ConnectionPool.java:1051)
    2. Configuriing the jndi in Weblogic server
    weblogic.common.ResourceException: Could not create pool connection. The DBMS driver exception was: Listener refused the connection with the following error:
    ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
    The Connection descriptor used by the client was:
    localhost:1521:SERVICENAME
         at weblogic.jdbc.common.internal.ConnectionEnvFactory.createResource(ConnectionEnvFactory.java:253)
         at weblogic.common.resourcepool.ResourcePoolImpl.makeResources(ResourcePoolImpl.java:1109)
         at weblogic.common.resourcepool.ResourcePoolImpl.makeResources(ResourcePoolImpl.java:1033)
    Problem
    database url is generated based on SID
    eg: jdbc:oracle:thin:@localhost:1521:SID
    Solution
    (generate seperate url for SERVICE NAME)
    jdbc:oracle:thin:@localhost:1521/SERVICENAME
    ------------------------

    It is so clear: host not found error for network connection and the other SID servcie name not found means your oracle instance name is not up. check with srvctl status for given servcie name or node, else check CRS_Stat -t if you are using RAC.

  • Help with circumvention of ORA-01472: cannot use connect by on view with ..

    Hi,
    Any help resolving the following would be v. helpful.
    The Aim
    Produce a hierarchical report of all users and the privileges they have via the various roles they are granted.
    The SQL
    select lpad(' ', level*2,' ')|| granted_role from (select grantee, granted_role
    from dba_role_privs
    union
    select role, granted_role
    from role_role_privs
    union
    select role, privilege
    from role_sys_privs
    union
    select 'All users', username
    from dba_users)
    start with grantee='All users'
    connect by prior granted_role = grantee;
    The error
    ORA-0147: cannot use connect by on view with DISTINCT, GROUP BY, etc.
    The database
    Oracle 8.1.7.4 (Yes I know ....)
    The Solution
    [Thanks in advance]

    What if you create a table first
    create table role_grants as
        select granted_role, grantee
           from (select grantee, granted_role
                   from dba_role_privs
                 union
                 select role, granted_role
                   from role_role_privs
                 union
                 select role, privilege
                   from role_sys_privs
                 union
                 select 'All users', username
                  from dba_users)
    Then run the hierarchical report
    select lpad(' ', level*2,' ')|| granted_role
       from role_grants
       start with grantee='All users'
       connect by prior granted_role = grantee

  • 'timezone region not found' while updating connection pool

    Hi Experts,
    We have upgraded our weblogic server from 10.3.3.0(11.1.1.3.0) to 10.3.6.0(11.1.1.6.0)
    All the data sources and connection pools were created in the previous version(11.1.1.3.0) and it worked fine.
    After the upgrade has done, we tried to run a BPEL web service which is using a database connection to get some data.
    Then the below error has thrown out in EM.
    *<part name="summary">*
    *<summary>Exception occured when binding was invoked. Exception occured during invocation of JCA binding: "JCA Binding execute of Reference operation 'Validate_Invoice' failed due to: Could not create/access the TopLink Session. This session is used to connect to the datastore. Caused by Exception [EclipseLink-7060] (Eclipse Persistence Services - 2.3.1.v20111018-r10243): org.eclipse.persistence.exceptions.ValidationException Exception Description: Cannot acquire data source [jdbc/EBSAPPS]. Internal Exception: javax.naming.NameNotFoundException: Unable to resolve 'jdbc.EBSAPPS'. Resolved 'jdbc'; remaining name 'EBSAPPS'. You may need to configure the connection settings in the deployment descriptor (i.e. DbAdapter.rar#META-INF/weblogic-ra.xml) and restart the server. This exception is considered not retriable, likely due to a modelling mistake. ". The invoked JCA adapter raised a resource exception. Please examine the above error message carefully to determine a resolution. </summary>*
    *</part>*
    *<part name="detail">*
    *<detail> Exception Description: Cannot acquire data source [jdbc/EBSAPPS]. Internal Exception: javax.naming.NameNotFoundException: Unable to resolve 'jdbc.EBSAPPS'. Resolved 'jdbc'; remaining name 'EBSAPPS'</detail>*
    *</part>*
    Then I tried to recreate the data source and jndi name.
    Then I got below error while creating connection pool,
    An error occured during activation of changes. Please see the log for details.
    Weblogic.Application.ModuleExeption
    ORA-00604: Error occurred at recursive sql level 1ORA 1882:timezone region not found.
    Database OS level timezone is - SLT
    Weblogic server OS level timezone is - IST
    As i remember above are the timezones there earlier also....
    What can do??
    Thanks in advance....

    Hi Joe,
    Thanks for the reply...
    But it seems answers are given related to 'Application Express Listener'.
    The thing is we got this issue once we upgrade the middleware tier. We cannot do anything on database side. (Remote database)
    The solution should be in middleware, Weblogic server side.
    Our live environment still in the 10.3.3.0 version. It works fine..
    any suggestions ???
    Thanks....

  • Error Message while creating connection pool

    Hi all,
    I got the following error message while creating connection pool for the
    SQL Server thru the Application Server Admin Console.
    The message is,
    An error has occured.
    Operation 'create.Jdbc.ConnectionPool' failed in 'resources' Config Mbean. Target exception message :
    JdbcConnectionPool Already Exists: cannot add duplicate.
    But the connection pool for the SQL Server was not there in the list.
    What may be the possible reason for this error.
    i was trying to deploy a BMP entiy bean using the Sun Application Server.
    Prior deploying i just tried to create connection pool and test the connection using the Admin Console
    Please help me by providing a solution.

    Kriti Sundar Mazumder wrote:
    Hi
    I am getting an following error message, while creating database connection pool
    in weblogic 7.
    "<Jun 18, 2004 4:52:36 AM CDT> <Error> <JDBC> <001060> <Cannot startup connection
    pool "MyJDBCConnectionPool" java.sql.SQLException: [IBM][JDBC Driver] CLI0647E
    Error allocating DB2 environment handle, rc=-1.>"
    Can anyone help me out in this regard
    Regards
    KritiHi. I am no expert, but it sounds like a problem with the privileges the user
    has... The best thing is to step back to a simpler environment. Can you try
    connecting to DB2 with a simple program like utils.dbping? Please look at our
    driver docs for the DB2 driver, because there are several variations in connect
    properties depending on the type of DB2 you are connecting to...
    Joe

  • Problem in using connection pool in netbeans

    Hi,
    I am using Net Beans and Sun java application server and Derby as database.
    I have created data connnection and also configure JDBC resources (ie. DataResource and connectionPool).
    Now i want to use this connection pool in my class, I have create one DataConnection class and put this code
    private javax.sql.DataSource getMyDatabase () throws javax.naming.NamingException {
            javax.naming.Context c = new javax.naming.InitialContext();
            return (javax.sql.DataSource) c.lookup("java:comp/env/jdbc/myDatabase");
        }I got this code by right click and selecting Enterprise Resources->Use Data, But while running i got the exception
    javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
    Plz tell me How can we overcome this exception and is there any other way do use connection pool.
    Thanks.

    Thanks bamkin-ov-lesta,
    DbConnectionBroker is good for servlet or other java application. If i use this class, it is like i am writing code for connection pool. I am using NetBeans and sun java application server which provide its default connection pool configuration and i want to use that only.
    And I am not getting which class name to be set in environment variable under what name in the following exception.
    javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
    Help me plz.

  • How to access database from applet using connection pooling.

    Hi,
    I am using tomcat 4.1, JRE 1.4.2_10, MySQL 5.0, and IE 6.0. I can access the database using connection pooling from JSP without problems. But, if I try to acess from the applet, I get the following exception (related to JNDI.):
    javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
    at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
    at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
    at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
    at javax.naming.InitialContext.lookup(Unknown Source)
    I know what this acception means, but I don't know how to fix it. I set up connection pooling in my Tomcat 4.1 that talks to MySQL 5.0. As I said, when I access from jsp, JNDI works. But, applet complains. Please help. In my applet, the following code accesses the database:
    ArrayList toolTipData =
          access.getToolTipData (projectName,interfac);This is the snipet of my Access class:
    public ArrayList getToolTipData (String projectName, String interfac) {
        System.out.println("In getToolTipData");
        ArrayList toolTipData = new ArrayList();
       try{
        Context ctx = new InitialContext();
        if(ctx == null )
            throw new Exception("No Context");
        DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/interfacesDB");
        if (ds != null) {
          Connection conn = ds.getConnection();
          if(conn != null)  {
              Statement s = conn.createStatement();
              //For some reason paramtized queries don't work, so I am forced
              //to this in slighly less eficient way.
              ResultSet rst = s.executeQuery("select * from interfaces");
              while (rst.next()) {
                 if (rst.getString("Project_Name").equals(projectName) &&
                     rst.getString("Interface").equals(interfac)) {
                   System.out.println("getToolTipData: ITG #" + rst.getString("ITG"));
                   toolTipData.add("ITG #: " + rst.getString("ITG"));
                   toolTipData.add("SPNE Prime Name: " +
                                   rst.getString("SPNE_Prime_Name"));
                   toolTipData.add("PD Prime Name: " +
                                   rst.getString("PD_Prime_Name"));
                   toolTipData.add("IT Prime Name: " +
                                   rst.getString("IT_Prime_Name"));
                   toolTipData.add("MLC Priority: " +
                                   rst.getString("MLC_Priority"));
                   toolTipData.add("Gary's Prime: " + rst.getString("Garys_Prime"));
                   toolTipData.add("QA Prime: " + rst.getString("QA_Prime"));
                   toolTipData.add("Brief Description: " +
                                   rst.getString("Brief_Description"));
                   toolTipData.add("Project_Status: " +
                                   rst.getString("Project_Status"));
              conn.close();
      }catch(Exception e) {
        e.printStackTrace();
      return toolTipData;
    ....

    The jsp runs on the server, whereas the applet runs on the client so
    you must package with your applet any jndi implementation specific classes
    and
    Properties props = new Properties();
    props.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory" );
    props.setProperty("java.naming.provider.url", "url:1099");
    Context ctx = new InitialContext(props);
    Object ref = ctx.lookup("...");

  • Fatal error while filling connection pool

    I was not getting a connection to an Oracle database and I was getting the following error in cms.log: "FATAL  Connector - Unable to create connection pool for T_Orbis_Oracle: Fatal error while filling connection pool for jdbc:oracle:thin:@MESDB:1521:ASPENB21" where T_Orbis_Oracle is the xMII link name and the database ASPENB21 is on server MESDB. I changed the database username in the link to SYSTEM and I then got a connection and a Created Connection pool message in the log. I then changed back to the username which originally was giving the error and it now also gave me a successful connection. I am now worried that there is an issue in the background which is gradually building up and will begin to fail again as previously. Can anyone explain what is causing this problem and suggest how I can correct it? Thanks, John.

    John,
    Check you have installed the JDBC driver ojdbc14.jar (works for both 9 and 10).
    Also check the server package:
    MII 11.x--->ServerPackage com.lighthammer.Illuminator.connectors.IDBC
    MII 12.x--->com.sap.xmii.Illuminator.connectors.IDBC
    Carefull when you set up the string because some oracle databases have servicenames instead of SID, and the url was different if you use them instead of the SID.
    For services names the url is jdbc:oracle:thin@host:port:SID
    Also check your Network firewall between MII and DB and ports too.
    Oracle9i installs with a number of default accounts.You must unlock all other accounts before using them. Oracle recommends changing all user passwords immediately after installation.
    -Suresh
    Edited by: Suresh Hiremath on Jul 29, 2009 8:20 AM

  • How to use Connection Pool in ADF ear file creaion from jDev 10.1.3

    Hi,
    We are developing big application in ADF with 10 different modules. We are creating ear file with data source setting.
    How to use connection pool while creating ear file from jDev. Connection pool is alreday created in Application Server 10g.
    What all the setting we need do to make use of connection pool while creating ear file jDev.
    Thanks

    User,
    If you are using ADF Business Components, you can right-click each application module, select "configurations" and edit the configuration you are using. On the initial page of the configuration dialog, you can specify to use either a JDBC URL or a Datasource - you just need to choose Datasource and then provide the name by which to access it.
    John

  • Repost-Best way of using connection pooling

    I am reposting this, seems best suitable in this category.
    I am using Eclipse 3.1 along with Tomcat 5.0, MySQL 4.1, J2EE1.4. I could set up the JNDI Dataresource connection pooling and tested with small test servlet. Now thinking of having common methods for getting connection / closing / commiting ....etc.
    I wrote following. [Please let me know whether it is correct way of doing it - as i am not very sure]
    package common;
    import java.sql.*;
    import javax.sql.*;
    import javax.naming.*;
    import org.apache.log4j.Logger;
    public final class connectionManager {
         private static Logger logger = Logger.getLogger(common.connectionManager.class);
         public connectionManager() {}
         public static Connection getConn () throws NamingException, SQLException
    //JNDI DataSource connection pooling
              Connection conn = null;
              try{
                   Context initContext = new InitialContext();
                   Context envContext  = (Context)initContext.lookup("java:/comp/env");
                   DataSource ds = (DataSource)envContext.lookup("jdbc/TQ3DB");
                   conn = ds.getConnection();
              }catch (NamingException ne) {
                  new GlobalExceptionHandler(logger, ne);
                   conn = null;
                   throw new NamingException();
              }catch (SQLException e){
                   new GlobalExceptionHandler(logger, e);
                   conn = null;
                   throw new SQLException();
              return conn;
           }//getConnection
         public static void commit(Connection conn) throws SQLException
              conn.commit();
         public static void rollback(Connection conn) throws SQLException
              conn.rollback();
           public static void setAutoCommit(Connection conn, boolean autoCommit)
                                        throws SQLException
                conn.setAutoCommit(autoCommit );
         public static void closeConnection(Connection conn) throws SQLException{
              if (conn != null) {
                   conn.close();
                   conn = null;
         }//closeConnection
         public static void closeResources(ResultSet oRS, PreparedStatement pstmt) throws SQLException
              if (oRS != null) {
                   oRS.close();
                   oRS = null;
              if (pstmt != null) {
                        pstmt.close();
                        pstmt = null;
         } // closeResources
    }//ConnectionManager
    I am having a login form which submits user name and password. I am checking this against the database. Following is the servlet to do that.
    package login;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    import common.*;
    public class loginServlet extends HttpServlet {
         public void doGet(HttpServletRequest request, HttpServletResponse response)
                   throws ServletException, IOException {          
              doPost(request, response);
         }//doGet
         public void doPost(HttpServletRequest request, HttpServletResponse response)
                   throws ServletException,IOException{
              String userId = request.getParameter("userId");
              String password = request.getParameter("password");
              ** call a method to validate the password which will return the
              ** User Name for authorized users and null string for un-authorised.
              String uName = validateUser(userId, password);
              //if uName is null .. user is not authorized.
              if (uName == null){
                   //redirect to jsp page with error message
                  RequestDispatcher rd =
                       getServletContext().getRequestDispatcher("/jsps/mainmenu.jsp");
                  if (rd != null){
                       rd.forward(request,response);
              else{
                   // the user is valid - create a seesion for this user.
                   HttpSession userSession = request.getSession(true);
                   // put the user name session variable.
                   userSession.setAttribute("userName", uName);
                   //redirect to Main menu page
                   RequestDispatcher rd =
                        getServletContext().getRequestDispatcher("/jsps/mainmenu.jsp");
                   if (rd != null){
                        rd.forward(request,response);
         }// end of doPost
         private String validateUser(String userId, String password)
                   throws SQLException{
              String returnVal = null;
              connectionManager cm = new connectionManager();
              Connection conn = null;
              PreparedStatement pstmt = null;
              ResultSet oRS = null;
              try{
                   //get the connection
                   conn = cm.getConn ();
                   //get records from user table for this user id and password
                   String sQry = "SELECT  user_login FROM user "
                             + "where user_login = ? AND user_pwd = ? ";
                   pstmt = conn.prepareStatement(sQry);
                   pstmt.setString(1, userId);
                   pstmt.setString(2, password);
                   oRS = pstmt.executeQuery();
                   //check for record
                   if (oRS.next()) {
                        returnVal = oRS.getString("user_login");
                   }else {returnVal = null;}
                 }catch (Exception e){            
                      returnVal = null;
              }finally{
                   cm.closeResources(oRS, pstmt);
                   cm.closeConnection(conn);
              return returnVal;
    }// end of servlet class
    But i am unable to compile it and i am also getting lots of warnings.
    I am getting error at line
    1)String uName = validateUser(userId, password);
    Unhandled exception type SQLException loginServlet.java TQ3/WEB-INF/src/login line
    Following warnings:
    2)For loginServlet Declaration
    The serializable class DBTest does not declare a static final serialVersionUID field of type long loginServlet.java
    3)The static method getConn() from the type connectionManager should be accessed in a static way
    4)The static method closeResources(ResultSet, PreparedStatement) from the type connectionManager should be accessed in a static way
    5)The static method closeConnection(Connection) from the type connectionManager should be accessed in a static way
    Definitely I am doing it wrong but exactly where? I am having very strong doubt the way i am using connections is not the correct way. Pls help me.
    regards
    Manisha

    I am in a search of best way to use connection pooling. Initially was using simple JDBC call, then modified to JNDI, afterwards tried to have common class. Later came accross the idea of Singleton/Static. I wanted to have a common class which will handle all connection related issues and at the same time give good performance.
    With due respect to all Java Gurus: i got all from web articles/tutorials/java forum etc. There is a long discussion regarding Singlet vs static in this forum. But finally got confused and could not figure out in my case which method shall i make use of, so tried both.
    What I want is somebody pointing out flwas inside my 2 code snippets and guide me about which method shall i adopt in future.
    Static way:
    package common;
    import java.sql.Connection;
    import javax.sql.DataSource;
    import java.sql.SQLException;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    public final class ConnectionManager_Static {
         private static InitialContext ctx = null;
         private static DataSource ds = null;
         public ConnectionManager_Static(){     }
         //as the staic method is updating static var i am synchonizing it
         private static synchronized void getDatasource () throws NamingException, SQLException
              if (ds == null){
                   ctx = new InitialContext();
                   ds = (DataSource)ctx.lookup("java:comp/env/jdbc/MySql");
         //making getConnection() also static as it is not instance specific     
         public static Connection getConnection () throws NamingException, SQLException, Exception
              Connection conn = null;
              try{     
                   if (ds == null) {getDatasource ();}
                   if (ds != null) {
                        conn = ds.getConnection();                 
              }catch (Exception e){
                   throw new Exception("From ConnectionManager_Static",e);
              return conn;
           }//getConnection
    }Singleton:
    package common;
    import java.sql.*;
    import javax.sql.*;
    import javax.naming.*;
    public final class ConnectionManager_Singleton {
             private static ConnectionManager_Singleton INSTANCE = null;
              private DataSource datasource = null;
              // Private constructor for singleton pattern
             private ConnectionManager_Singleton() throws NamingException{
                   Context ctx = new InitialContext();
                   datasource = (DataSource)ctx.lookup("java:comp/env/jdbc/MySql");
             //synchronized creator for  multi-threading issues
             //another if check to avoid multiple instantiation
             private synchronized static void createInstance() throws NamingException{
                 if (INSTANCE == null) {
                     INSTANCE = new ConnectionManager_Singleton();
             public static ConnectionManager_Singleton getInstance() throws NamingException {
                 if (INSTANCE == null) createInstance();
                 return INSTANCE;
              public Connection getConnection() throws Exception
                   Connection con = null;
                   try{
                        con = datasource.getConnection();
                   }catch(Exception e){
                        throw new Exception("From connection manager singleton ", e);
                   return con;
    }Sorry, It's becoming long.
    Thanaks in advance,
    Manisha

  • Problems using connection pooling

    I'm having problems configuring connection pooling in oc4j. Have specified my datasource/connection pool in my data-sources.xml. I always get the following error when I try to access it with an instance of OracleConnectionPoolDataSource within my apps. The app server dosen't seem to create the connections when started 'cos its not displayed within Oracle dba studio. Can anyone tell what I need to do pls.
    regards!
    dyzke
    //-- error displayed
    Exception in thread "main" java.sql.SQLException: Io exception: The Network Adap
    ter could not establish the connection
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:210)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:323)
    at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:260)
    at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.ja
    va:365)
    at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:260)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at oracle.jdbc.pool.OracleDataSource.getConnection(OracleDataSource.java
    :111)
    // -- extract
    <data-source
              class="com.evermind.sql.DriverManagerDataSource"
    name="MYDS"
              location="jdbc/XXX"      
    xa-location="jdbc/xa/OracleXADS"
              ejb-location="jdbc/OracleDS"
    pooled-location="xxx/xxxx"
              max-connections="10"
              min-connections="3"                    
              connection-driver="oracle.jdbc.driver.OracleDriver"
              username="admin"
              password="admin"
              url="jdbc:oracle:thin:@localhost:xxx"
              inactivity-timeout="30"
         />

    see my answer in the other newsgroup.
    please don't cross post.
    "M. Hammer" <[email protected]> wrote in message
    news:[email protected]..
    Hi,
    We have problems using connection pooling in a WLS 5.1.x - Cluster. Is it
    possible to use CP in such a cluster at all ? The problem is, connections
    will be opened and never been closed. How can I configure a cluster forCP?
    >
    I have a WLS-Cluster with 2 instances and my webApp uses connectionpooling.
    By the way I get a connection on Instance 1, Instance 2 gets a connection
    also, but never releases it.
    In my opinion, the reference to the connection in the partner-instancewill
    be lost.
    How do I have to configure my cluster to work well with that stuff ?
    Thank a lot,
    Markus.

Maybe you are looking for

  • I can't scan to my iMac

    I have installed printer drivers for my Brother printer and I can print ok but for some reason the printer will not connect to my iMac to scan. Never had this problem with my PC. Any suggestions would be greatly appreciated.

  • Media card out of space

    My bb curve media card is out of space. The options say 85% full from section "other" and i can not find out what the section other includes. So i was wondering if someone could help me?

  • Can't Export Keynote slide show file to iDVD?

    I am having difficulty exporting a 12mb Keynote slide show file to iDVD. When I go to export, a warning stating that 'There is not enough disc space or a problem with the file' appears. I have enough disc space and I don't think that I am corrupting

  • Reactivar compact rio en max por red

    Saludos a todos!! espero me puedan ayudar.. realicé un reinició del MAX en mi pc ya que marcaba algunos errores, por lo cual se borraron todos los registros y todas las tarjetas y módulos que estaba utilizando. ahora quiero volver a integrar el modul

  • Very Strange Rendition of the "Blue Screen" Problems

    So I'm familiar with some of the blue screen freezes, but the problems that I am encountering are very very strange, so let me start: Two computers are affected: a MacBook Pro and an Aluminum iMac. Both computers are running Leopard. The MacBook Pro: