Index: C:/workspace/c4/java/net/sf/l2j/L2DatabaseFactory.java =================================================================== --- C:/workspace/c4/java/net/sf/l2j/L2DatabaseFactory.java (revision 1689) +++ C:/workspace/c4/java/net/sf/l2j/L2DatabaseFactory.java (working copy) @@ -84,13 +84,13 @@ // testing OnCheckin used with IdleConnectionTestPeriod is faster than testing on checkout config.setIdleConnectionTestPeriod(60); // test idle connection every 60 sec - config.setMaxIdleTime(60*60); // 0 = idle connections never expire + config.setMaxIdleTime(0); // 0 = idle connections never expire // *THANKS* to connection testing configured above // but I prefer to disconnect all connections not used // for more than 1 hour // enables statement caching, there is a "semi-bug" in c3p0 0.9.0 but in 0.9.0.2 and later it's fixed - config.setMaxStatements(100); + config.setMaxStatementsPerConnection(100); config.setBreakAfterAcquireFailure(false); // never fail if any way possible // setting this to true will make @@ -174,16 +174,22 @@ // ========================================================= // Property - Public - public static L2DatabaseFactory getInstance() throws SQLException + public static L2DatabaseFactory getInstance() //throws SQLException { if (_instance == null) { - _instance = new L2DatabaseFactory(); + try + { + _instance = new L2DatabaseFactory(); + } catch (SQLException e) + { + _log.severe("L2DatabaseFactory: init failed."); + } } return _instance; } - public Connection getConnection() //throws SQLException + public Connection getConnection() { Connection con=null; @@ -196,10 +202,27 @@ { _log.warning("L2DatabaseFactory: getConnection() failed, trying again "+e); } - }; + } return con; } + public Connection getConnection(boolean use_transactions) + { + Connection con=getConnection(); + + if(use_transactions) + { + try + { + con.setAutoCommit(false); + } catch (SQLException e) + { + _log.warning("L2DatabaseFactory: Failed to disable AutoCommit"); + } + } + return con; + } + public int getBusyConnectionCount() throws SQLException { return ((PooledDataSource) _source).getNumBusyConnectionsDefaultUser();