1 22 23 24 package com.mchange.v2.c3p0; 25 26 import java.beans.PropertyChangeEvent ; 27 import java.sql.SQLException ; 28 import java.util.Properties ; 29 import javax.sql.DataSource ; 30 31 40 public final class DriverManagerDataSourceFactory 41 { 42 54 public static DataSource create(String driverClass, 55 String jdbcUrl, 56 String dfltUser, 57 String dfltPassword, 58 String refFactoryLoc) 59 throws SQLException 60 { 61 DriverManagerDataSource out = new DriverManagerDataSource(); 62 out.setDriverClass( driverClass ); 63 out.setJdbcUrl( jdbcUrl ); 64 out.setUser( dfltUser ); 65 out.setPassword( dfltPassword ); 66 out.setFactoryClassLocation( refFactoryLoc ); 67 return out; 68 } 69 70 81 public static DataSource create(String driverClass, 82 String jdbcUrl, 83 Properties props, 84 String refFactoryLoc) 85 throws SQLException 86 { 87 DriverManagerDataSource out = new DriverManagerDataSource(); 88 out.setDriverClass( driverClass ); 89 out.setJdbcUrl( jdbcUrl ); 90 out.setProperties( props ); 91 out.setFactoryClassLocation( refFactoryLoc ); 92 return out; 93 } 94 95 104 public static DataSource create(String driverClass, 105 String jdbcUrl, 106 String dfltUser, 107 String dfltPassword) 108 throws SQLException 109 { return create( driverClass, jdbcUrl, dfltUser, dfltPassword, null ); } 110 111 118 public static DataSource create(String driverClass, String jdbcUrl) 119 throws SQLException 120 { return DriverManagerDataSourceFactory.create( driverClass, jdbcUrl, (String ) null, null); } 121 122 134 public static DataSource create(String jdbcUrl, String dfltUser, String dfltPassword) 135 throws SQLException 136 { return DriverManagerDataSourceFactory.create( null, jdbcUrl, dfltUser, dfltPassword ); } 137 138 148 public static DataSource create(String jdbcUrl) 149 throws SQLException 150 { return DriverManagerDataSourceFactory.create( null, jdbcUrl, (String ) null, null ); } 151 152 private DriverManagerDataSourceFactory() 153 {} 154 } 155 | Popular Tags |