|
Re: Database connection pooling: msg#00055java.enhydra.general
Richard Edwards wrote: Hi,If you use directly DBConnection objects, you must always explicitly call the DBConnection.handleException(SQLException) method when an SQLException to inform the DatabaseManager. Depending on the reason of the exception, the DatabaseManager will drop the connection from the pool (a SQL syntax error will not drop it, a network error will...). Note : If you have to restart the database server, every DBConnection previously in the pool will be invalid, so an SQL exception will occur for each DBConnection, until every DBConnection is dropped. Here is a sample code on how to safely use DBConnections : DBConnection dbconnection = null; try { try { dbconnection = myApplication.getDatabaseManager().allocateConnection(myDBName); } catch (DatabaseManagerException e) { // custom error handling throw new CustomException("Impossible to get a database connection to database " + myDBName); } // use the connection... // ..... } catch (SQLException esql) { // handle the Exception at the DatabaseMabager level if (dbconnection !=null) { dbconnection.handleException(esql); } // Here some custom error handling... // ... } finally { if (dbconnection != null) dbconnection.release(); } Hope this helps... -- Frederic Garzon <Frederic.Garzon@xxxxxxxx> --------------------------------------------- o 51, rue de Verdun / _ __ _ 92158 Suresnes cedex / /\ /_ / /_ France \/ \/_ / /_/ Tel. +33 (0) 1 41 44 85 45 Inetsys S.A. Fax +33 (0) 1 46 97 20 10
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | RE: Switch Enhydra to URL rewriting mode, Laurent Comte |
|---|---|
| Next by Date: | Re: Enhydra without session management, Achim Weßling |
| Previous by Thread: | Database connection pooling, Richard Edwards |
| Next by Thread: | Re: Enhydra without session management, Achim Weßling |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |