@Bean("dataSource") public DataSource dataSource() { SimpleDriverDataSource dataSource = new SimpleDriverDataSource(); dataSource.setDriverClass(org.postgresql.Driver.class); dataSource.setUrl("jdbc:postgresql://localhost:5432/mybatis_plus"); dataSource.setUsername("postgres"); dataSource.setPassword("123123"); return dataSource; }
/** * Create a new DriverManagerDataSource with the given standard Driver parameters. * @param driver the JDBC Driver object * @param url the JDBC URL to use for accessing the DriverManager * @param conProps the JDBC connection properties * @see java.sql.Driver#connect(String, java.util.Properties) */ public SimpleDriverDataSource(Driver driver, String url, Properties conProps) { setDriver(driver); setUrl(url); setConnectionProperties(conProps); }
/** * Create a new DriverManagerDataSource with the given standard Driver parameters. * @param driver the JDBC Driver object * @param url the JDBC URL to use for accessing the DriverManager * @see java.sql.Driver#connect(String, java.util.Properties) */ public SimpleDriverDataSource(Driver driver, String url) { setDriver(driver); setUrl(url); }
/** * Create a new DriverManagerDataSource with the given standard Driver parameters. * @param driver the JDBC Driver object * @param url the JDBC URL to use for accessing the DriverManager * @param username the JDBC username to use for accessing the DriverManager * @param password the JDBC password to use for accessing the DriverManager * @see java.sql.Driver#connect(String, java.util.Properties) */ public SimpleDriverDataSource(Driver driver, String url, String username, String password) { setDriver(driver); setUrl(url); setUsername(username); setPassword(password); }
private static DataSource newSimpleDriverDataSource(String jdbcUrl) { try { return new SimpleDriverDataSource(DriverManager.getDriver(jdbcUrl), jdbcUrl); } catch (SQLException e) { throw new RuntimeException("Unable to construct DataSource", e); } }
@BeforeClass public static void setUp() { dbFile = System.getProperty("java.io.tmpdir") + File.separator + "batch_sqlite_inc.db"; dataSource = new SimpleDriverDataSource(); dataSource.setDriverClass(org.sqlite.JDBC.class); dataSource.setUrl("jdbc:sqlite:" + dbFile); template = new JdbcTemplate(dataSource); template.execute("create table max_value (id integer primary key autoincrement)"); }
SimpleDriverDataSource dataSource = new SimpleDriverDataSource(); dataSource.setDriverClass((Class<Driver>)Class.forName("com.mysql.jdbc.Driver"));
@Override public void setDriverClass(Class<? extends Driver> driverClass) { dataSource.setDriverClass(driverClass); }
@Override public void setUrl(String url) { dataSource.setUrl(url); }
@Override public void setPassword(String password) { dataSource.setPassword(password); } };
@Override public void setUsername(String username) { dataSource.setUsername(username); }
private static DataSource newSimpleDriverDataSource(String jdbcUrl) { try { return new SimpleDriverDataSource(DriverManager.getDriver(jdbcUrl), jdbcUrl); } catch (SQLException e) { throw new RuntimeException("Unable to construct DataSource", e); } }
/** * Create a new DriverManagerDataSource with the given standard Driver parameters. * @param driver the JDBC Driver object * @param url the JDBC URL to use for accessing the DriverManager * @see java.sql.Driver#connect(String, java.util.Properties) */ public SimpleDriverDataSource(Driver driver, String url) { setDriver(driver); setUrl(url); }
@Override public void setDriverClass(Class<? extends Driver> driverClass) { dataSource.setDriverClass(driverClass); }
@Override public void setUrl(String url) { dataSource.setUrl(url); }
@Override public void setPassword(String password) { dataSource.setPassword(password); } };
@Override public void setUsername(String username) { dataSource.setUsername(username); }
@Configuration class DevbConfig { @Bean(name = "devbDataSource") DataSource devbDataSource() { try { return new SimpleDriverDataSource(DriverManager.getDriver("jdbc:..."), "jdbc:...", "username", "password"); } catch (SQLException e) { throw new RuntimeException(e); } } @Bean(name = "devbJdbc") JdbcTemplate devbJdbc(@Qualifier("devbDataSource") DataSource dataSource) { return new JdbcTemplate(dataSource); } }
/** * Create a new DriverManagerDataSource with the given standard Driver parameters. * @param driver the JDBC Driver object * @param url the JDBC URL to use for accessing the DriverManager * @param conProps the JDBC connection properties * @see java.sql.Driver#connect(String, java.util.Properties) */ public SimpleDriverDataSource(Driver driver, String url, Properties conProps) { setDriver(driver); setUrl(url); setConnectionProperties(conProps); }
/** * Create a new DriverManagerDataSource with the given standard Driver parameters. * @param driver the JDBC Driver object * @param url the JDBC URL to use for accessing the DriverManager * @see java.sql.Driver#connect(String, java.util.Properties) */ public SimpleDriverDataSource(Driver driver, String url) { setDriver(driver); setUrl(url); }