List of usage examples for org.springframework.jdbc.datasource SingleConnectionDataSource setConnectionProperties
public void setConnectionProperties(@Nullable Properties connectionProperties)
From source file:ca.nrc.cadc.db.DBUtil.java
/** * Create a DataSource with a single connection to the server. All failures * are thrown as RuntimeException with a Throwable (cause). * * @param config//from ww w. j a va2s .co m * @param suppressClose suppress close calls on the underlying Connection * @param test test the datasource before return (might throw) * @return a connected single connection DataSource * @throws DBConfigException */ public static DataSource getDataSource(ConnectionConfig config, boolean suppressClose, boolean test) throws DBConfigException { try { log.debug("server: " + config.getServer()); log.debug("driver: " + config.getDriver()); log.debug("url: " + config.getURL()); log.debug("database: " + config.getDatabase()); // load JDBC driver Class.forName(config.getDriver()); SingleConnectionDataSource ds = new SingleConnectionDataSource(config.getURL(), config.getUsername(), config.getPassword(), suppressClose); Properties props = new Properties(); props.setProperty("APPLICATIONNAME", getMainClass()); ds.setConnectionProperties(props); if (test) testDS(ds, true); return ds; } catch (ClassNotFoundException ex) { throw new DBConfigException("failed to load JDBC driver: " + config.getDriver(), ex); } catch (SQLException ex) { throw new DBConfigException("failed to open connection: " + config.getURL(), ex); } }