Index: impl/src/main/java/org/apache/taglibs/standard/tag/common/sql/DataSourceWrapper.java =================================================================== --- impl/src/main/java/org/apache/taglibs/standard/tag/common/sql/DataSourceWrapper.java (revision 911675) +++ impl/src/main/java/org/apache/taglibs/standard/tag/common/sql/DataSourceWrapper.java (working copy) @@ -19,8 +19,10 @@ import java.io.PrintWriter; import java.sql.Connection; +import java.sql.Driver; import java.sql.DriverManager; import java.sql.SQLException; +import java.util.Properties; import javax.sql.DataSource; @@ -34,7 +36,7 @@ * @author Hans Bergsten */ public class DataSourceWrapper implements DataSource { - private String driverClassName; + private Driver driver; private String jdbcURL; private String userName; private String password; @@ -43,8 +45,6 @@ throws ClassNotFoundException, InstantiationException, IllegalAccessException { - this.driverClassName = driverClassName; - //get the classloader ClassLoader cl; SecurityManager sm = System.getSecurityManager(); @@ -57,7 +57,10 @@ } //done getting classloader - Class.forName(driverClassName, true, cl).newInstance(); + Object instance = Class.forName(driverClassName, true, cl).newInstance(); + if (instance instanceof Driver) { + driver = (Driver) instance; + } } public void setJdbcURL(String jdbcURL) { @@ -77,16 +80,27 @@ * set properties. */ public Connection getConnection() throws SQLException { - Connection conn = null; - if (userName != null) { - conn = DriverManager.getConnection(jdbcURL, userName, password); - } - else { - conn = DriverManager.getConnection(jdbcURL); - } - return conn; + Connection conn = null; + if (driver != null) { + Properties props = new Properties(); + if (userName != null) { + props.put("user", userName); + } + if (password != null) { + props.put("password", password); + } + conn = driver.connect(jdbcURL, props); + } + if (conn == null) { + if (userName != null) { + conn = DriverManager.getConnection(jdbcURL, userName, password); + } else { + conn = DriverManager.getConnection(jdbcURL); + } + } + return conn; } - + /** * Always throws a SQLException. Username and password are set * in the constructor and can not be changed.