/** * Retrieve a {@code DataSource} for the specified properties. * This can be a JNDI Data Source as well. To do that, * the driver class name must reference a {@code javax.naming.Context} class * (for example {@code javax.naming.InitialContext}), and the URL must be the JNDI URL * (for example {@code java:comp/env/jdbc/Test}). * * @param driver the JDBC driver or the Context class * @param url the database URL * @param user the user name * @param password the password * @return the {@code DataSource} * @throws RepositoryException if the driver could not be loaded * @throws SQLException if the connection could not be established */ public DataSource getDataSource(String driver, String url, String user, String password) throws RepositoryException, SQLException { final String key = driver + url + user; synchronized(lock) { sanityCheck(); DataSource ds = keyToDataSource.get(key); if (ds == null) { ds = createDataSource( driver, url, user, Base64.decodeIfEncoded(password)); keyToDataSource.put(key, ds); } return ds; } }
/** * Retrieve a {@code DataSource} for the specified properties. * This can be a JNDI Data Source as well. To do that, * the driver class name must reference a {@code javax.naming.Context} class * (for example {@code javax.naming.InitialContext}), and the URL must be the JNDI URL * (for example {@code java:comp/env/jdbc/Test}). * * @param driver the JDBC driver or the Context class * @param url the database URL * @param user the user name * @param password the password * @return the {@code DataSource} * @throws RepositoryException if the driver could not be loaded * @throws SQLException if the connection could not be established */ public DataSource getDataSource(String driver, String url, String user, String password) throws RepositoryException, SQLException { final String key = driver + url + user; synchronized(lock) { sanityCheck(); DataSource ds = keyToDataSource.get(key); if (ds == null) { ds = createDataSource( driver, url, user, Base64.decodeIfEncoded(password)); keyToDataSource.put(key, ds); } return ds; } }
/** * Retrieve a {@code DataSource} for the specified properties. * This can be a JNDI Data Source as well. To do that, * the driver class name must reference a {@code javax.naming.Context} class * (for example {@code javax.naming.InitialContext}), and the URL must be the JNDI URL * (for example {@code java:comp/env/jdbc/Test}). * * @param driver the JDBC driver or the Context class * @param url the database URL * @param user the user name * @param password the password * @return the {@code DataSource} * @throws RepositoryException if the driver could not be loaded * @throws SQLException if the connection could not be established */ public DataSource getDataSource(String driver, String url, String user, String password) throws RepositoryException, SQLException { final String key = driver + url + user; synchronized(lock) { sanityCheck(); DataSource ds = keyToDataSource.get(key); if (ds == null) { ds = createDataSource( driver, url, user, Base64.decodeIfEncoded(password)); keyToDataSource.put(key, ds); } return ds; } }