From: <mwl...@us...> - 2009-12-30 20:54:07
|
Revision: 1001 http://cishell.svn.sourceforge.net/cishell/?rev=1001&view=rev Author: mwlinnem Date: 2009-12-30 20:53:59 +0000 (Wed, 30 Dec 2009) Log Message: ----------- We now attempt to connect to the new data sources we create. This way if the connection is faulty we'll get an error immediately rather than when we try to use it later. Modified Paths: -------------- trunk/core/org.cishell.reference.service.database/src/org/cishell/reference/service/database/DerbyDatabaseService.java Modified: trunk/core/org.cishell.reference.service.database/src/org/cishell/reference/service/database/DerbyDatabaseService.java =================================================================== --- trunk/core/org.cishell.reference.service.database/src/org/cishell/reference/service/database/DerbyDatabaseService.java 2009-12-30 17:41:04 UTC (rev 1000) +++ trunk/core/org.cishell.reference.service.database/src/org/cishell/reference/service/database/DerbyDatabaseService.java 2009-12-30 20:53:59 UTC (rev 1001) @@ -139,11 +139,17 @@ connectionFactory, connectionPool, stmtPool, null, false, true); DataSource dataSource = new PoolingDataSource(connectionPool); + //test the connection (this will throw an exception if the connection is faulty) + + dataSource.getConnection(); + //return that data source. return dataSource; } catch (ClassNotFoundException e) { throw new DatabaseCreationException( "Database driver '" + driver + "' could not be found", e); + } catch (SQLException e) { + throw new DatabaseCreationException(e.getMessage(), e); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |