From dd8ac80a09afe07aca168bed55950ccb20f17bd7 Mon Sep 17 00:00:00 2001 From: hns Date: Thu, 17 Nov 2005 16:23:51 +0000 Subject: [PATCH] * Make getConnection() and init() synchronized. * Fix JavaDoc comments. --- src/helma/objectmodel/db/DbSource.java | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/helma/objectmodel/db/DbSource.java b/src/helma/objectmodel/db/DbSource.java index 56bee1db..d81b9aaa 100644 --- a/src/helma/objectmodel/db/DbSource.java +++ b/src/helma/objectmodel/db/DbSource.java @@ -42,10 +42,9 @@ public class DbSource { /** * Creates a new DbSource object. * - * @param name ... - * @param props ... - * - * @throws ClassNotFoundException ... + * @param name the db source name + * @param props the properties + * @throws ClassNotFoundException if the JDBC driver couldn't be loaded */ public DbSource(String name, ResourceProperties props) throws ClassNotFoundException { @@ -55,14 +54,15 @@ public class DbSource { } /** + * Get a JDBC connection to the db source. * + * @return a JDBC connection * - * @return ... - * - * @throws ClassNotFoundException ... - * @throws SQLException ... + * @throws ClassNotFoundException if the JDBC driver couldn't be loaded + * @throws SQLException if the connection couldn't be created */ - public Connection getConnection() throws ClassNotFoundException, SQLException { + public synchronized Connection getConnection() + throws ClassNotFoundException, SQLException { Connection con = null; Transactor tx = null; if (Thread.currentThread() instanceof Transactor) { @@ -93,7 +93,12 @@ public class DbSource { return con; } - private void init() throws ClassNotFoundException { + /** + * Initialize the db source from the properties + * + * @throws ClassNotFoundException if the JDBC driver couldn't be loaded + */ + private synchronized void init() throws ClassNotFoundException { lastRead = (defaultProps == null) ? props.lastModified() : Math.max(props.lastModified(), defaultProps.lastModified());