List of usage examples for org.springframework.jdbc.datasource SimpleDriverDataSource SimpleDriverDataSource
public SimpleDriverDataSource(Driver driver, String url, String username, String password)
From source file:be.solidx.hot.spring.config.DataConfig.java
public DataSource db2SimpleDriverDataSource(String host, int port, String dbname, String username, String password) throws Exception { Driver db2Driver = (Driver) Class.forName("com.ibm.db2.jcc.DB2Driver").newInstance(); return new SimpleDriverDataSource(db2Driver, String.format(DB2_JDBC_URL, host, port, dbname), username, password);/* ww w .j a v a 2 s. c om*/ }
From source file:be.solidx.hot.spring.config.DataConfig.java
public DataSource mysqlSimpleDriverDataSource(String host, int port, String dbname, String username, String password) throws Exception { Driver mysqlDriver = (Driver) Class.forName("com.mysql.jdbc.Driver").newInstance(); return new SimpleDriverDataSource(mysqlDriver, String.format(MYSQL_JDBC_URL, host, port, dbname), username, password);/*from ww w .j ava 2 s .c o m*/ }
From source file:be.solidx.hot.spring.config.DataConfig.java
public DataSource pgsqlSimpleDriverDataSource(String host, int port, String dbname, String username, String password) throws Exception { Driver pgsqlDriver = (Driver) Class.forName("org.postgresql.Driver").newInstance(); return new SimpleDriverDataSource(pgsqlDriver, String.format(PGSQL_JDBC_URL, host, port, dbname), username, password);//from w w w . j ava 2s . com }
From source file:be.solidx.hot.spring.config.DataConfig.java
public DataSource hsqldbSimpleDriverDataSource(String dbname, String username, String password) throws Exception { Driver h2Driver = (Driver) Class.forName("org.hsqldb.jdbcDriver").newInstance(); return new SimpleDriverDataSource(h2Driver, String.format(HSQLDB_JDBC_URL, dbname), username, password); }
From source file:net.collegeman.grails.e3db.Template.java
public final void dataSource(Map<String, Object> config) { Driver driverInstance = null; Object driver = config.get("driver"); try {/* w w w . ja v a 2 s.co m*/ if (driver == null) throw new IllegalArgumentException("driver configuration parameter cannot be null."); if (driver instanceof Class) { driverInstance = (Driver) ((Class) driver).newInstance(); } else if (driver instanceof String) { driverInstance = (Driver) Class.forName((String) driver).newInstance(); } else if (driver instanceof Driver) { driverInstance = (Driver) driver; } else { throw new IllegalArgumentException("driver is unrecognized type: " + driver.getClass()); } } catch (InstantiationException e) { throw new RuntimeException(e); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } dataSource(new SimpleDriverDataSource(driverInstance, String.valueOf(config.get("url")), String.valueOf(config.get("username")), String.valueOf(config.get("password")))); }