View | Details | Raw Unified | Return to bug 51264
Collapse All | Expand All

(-)a/java/org/apache/catalina/session/JDBCStore.java (-10 / +20 lines)
Lines 874-884 public class JDBCStore extends StoreBase { Link Here
874
     * @return <code>Connection</code> if the connection succeeded
874
     * @return <code>Connection</code> if the connection succeeded
875
     */
875
     */
876
    protected Connection getConnection() {
876
    protected Connection getConnection() {
877
        Connection _conn = null;
877
        try {
878
        try {
878
            if (dbConnection == null || dbConnection.isClosed()) {
879
            _conn = open();
880
            if (_conn == null || _conn.isClosed()) {
879
                manager.getContainer().getLogger().info(sm.getString(getStoreName() + ".checkConnectionDBClosed"));
881
                manager.getContainer().getLogger().info(sm.getString(getStoreName() + ".checkConnectionDBClosed"));
880
                open();
882
                _conn = open();
881
                if (dbConnection == null || dbConnection.isClosed()) {
883
                if (_conn == null || _conn.isClosed()) {
882
                    manager.getContainer().getLogger().info(sm.getString(getStoreName() + ".checkConnectionDBReOpenFail"));
884
                    manager.getContainer().getLogger().info(sm.getString(getStoreName() + ".checkConnectionDBReOpenFail"));
883
                }
885
                }
884
            }
886
            }
Lines 887-893 public class JDBCStore extends StoreBase { Link Here
887
                    ex.toString()));
889
                    ex.toString()));
888
        }
890
        }
889
891
890
        return dbConnection;
892
        return _conn;
891
    }
893
    }
892
894
893
    /**
895
    /**
Lines 916-923 public class JDBCStore extends StoreBase { Link Here
916
        }
918
        }
917
        
919
        
918
        if (dataSource != null) {
920
        if (dataSource != null) {
919
            dbConnection = dataSource.getConnection();
921
            Connection _conn = dataSource.getConnection();
920
            return dbConnection;
922
            return _conn;
921
        }
923
        }
922
924
923
        // Instantiate our database driver if necessary
925
        // Instantiate our database driver if necessary
Lines 1014-1026 public class JDBCStore extends StoreBase { Link Here
1014
    }
1016
    }
1015
1017
1016
    /**
1018
    /**
1017
     * Release the connection, not needed here since the
1019
     * Release the connection, if it
1018
     * connection is not associated with a connection pool.
1020
     * is associated with a connection pool.
1019
     *
1021
     *
1020
     * @param conn The connection to be released
1022
     * @param conn The connection to be released
1021
     */
1023
     */
1022
    protected void release(Connection conn) {
1024
    protected void release(Connection conn) {
1023
        // NOOP
1025
        if (dataSource != null) {
1026
            close(conn); 
1027
        }
1024
    }
1028
    }
1025
1029
1026
    /**
1030
    /**
Lines 1034-1040 public class JDBCStore extends StoreBase { Link Here
1034
    protected synchronized void startInternal() throws LifecycleException {
1038
    protected synchronized void startInternal() throws LifecycleException {
1035
1039
1036
        // Open connection to the database
1040
        // Open connection to the database
1037
        this.dbConnection = getConnection();
1041
        Connection _conn = getConnection();
1042
        if (dataSource != null) {
1043
            // if connection was created by a dataSource, we will release it
1044
            close(_conn);
1045
        } else {
1046
            this.dbConnection = _conn;
1047
        }
1038
        
1048
        
1039
        super.startInternal();
1049
        super.startInternal();
1040
    }
1050
    }
(-)a/java/org/apache/catalina/session/LocalStrings.properties (-1 / +1 lines)
Lines 27-33 JDBCStore.checkConnectionDBClosed=The database connection is null or was found t Link Here
27
JDBCStore.checkConnectionDBReOpenFail=The re-open on the database failed. The database could be down.
27
JDBCStore.checkConnectionDBReOpenFail=The re-open on the database failed. The database could be down.
28
JDBCStore.checkConnectionSQLException=A SQL exception occurred {0}
28
JDBCStore.checkConnectionSQLException=A SQL exception occurred {0}
29
JDBCStore.checkConnectionClassNotFoundException=JDBC driver class not found {0}
29
JDBCStore.checkConnectionClassNotFoundException=JDBC driver class not found {0}
30
JDBCStore.wrongDataSource=Can't open JNDI DataSource [{0}]
30
JDBCStore.wrongDataSource=Can not open JNDI DataSource [{0}]
31
JDBCStore.missingDataSourceName=No valid JNDI name was given.
31
JDBCStore.missingDataSourceName=No valid JNDI name was given.
32
managerBase.createRandom=Created random number generator for session ID generation in {0}ms.
32
managerBase.createRandom=Created random number generator for session ID generation in {0}ms.
33
managerBase.createSession.ise=createSession: Too many active sessions
33
managerBase.createSession.ise=createSession: Too many active sessions
(-)a/webapps/docs/config/manager.xml (-1 / +4 lines)
Lines 360-366 Link Here
360
      <p>Name of the JNDI resource for a JDBC DataSource-factory. If this option
360
      <p>Name of the JNDI resource for a JDBC DataSource-factory. If this option
361
      is given and a valid JDBC resource can be found, it will be used and any
361
      is given and a valid JDBC resource can be found, it will be used and any
362
      direct configuration of a JDBC connection via <code>connectionURL</code>
362
      direct configuration of a JDBC connection via <code>connectionURL</code>
363
      and <code>driverName</code> will be ignored.</p>
363
      and <code>driverName</code> will be ignored. Since this code uses prepared
364
      statements, you might want to configure pooled prepared statements as
365
      shown in <a href="../jndi-resources-howto.html">the JNDI resources
366
      HOW-TO</a>.</p>
364
    </attribute>
367
    </attribute>
365
368
366
    <attribute name="driverName" required="true">
369
    <attribute name="driverName" required="true">

Return to bug 51264