@Override public void setPassword(String password) { dataSource.setPassword(password); } };
/** * 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); }
@Bean("dataSource") public DataSource dataSource() { SimpleDriverDataSource dataSource = new SimpleDriverDataSource(); dataSource.setDriverClass(com.mysql.jdbc.Driver.class); dataSource.setUrl("jdbc:mysql://localhost:3306/mybatis_plus?useSSL=false&useUnicode=true&characterEncoding=UTF-8"); dataSource.setUsername("root"); dataSource.setPassword("123456"); return dataSource; }
@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; }
@Bean public DataSource dataSource(){ SimpleDriverDataSource dataSource = new SimpleDriverDataSource(); dataSource.setDriver(new Driver()); dataSource.setUrl("jdbc:h2:mem:test;MODE=mysql;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE"); dataSource.setUsername("sa"); dataSource.setPassword(""); return dataSource; }
simpleDriverDataSource.setUrl("jdbc:h2:target/database/example;AUTO_RECONNECT=TRUE"); simpleDriverDataSource.setUsername(""); simpleDriverDataSource.setPassword(""); return simpleDriverDataSource;
@Override public void setPassword(String password) { dataSource.setPassword(password); } };
public void setPassword(String password) { dataSource.setPassword(password); } };
@Bean public DataSource someDataSource() throws SQLException { final SimpleDriverDataSource dataSource = new SimpleDriverDataSource(); dataSource.setUrl(System.getProperty("db.url")); dataSource.setUsername(System.getProperty("db.user")); dataSource.setPassword(System.getProperty("db.password")); // Driver, connection properties, if any, and other stuff return dataSource; }
@Bean public DataSource dataSource() { SimpleDriverDataSource ds = new SimpleDriverDataSource(); try { @SuppressWarnings("unchecked") Class<? extends Driver> driverClass = (Class<? extends Driver>) Class.forName(environment.getProperty("jdbc.driver", "org.h2.Driver")); ds.setDriverClass(driverClass); } catch (Exception e) { log.error("Error loading driver class", e); } // Connection settings ds.setUrl(environment.getProperty("jdbc.url", "jdbc:h2:mem:activiti;DB_CLOSE_DELAY=1000")); ds.setUsername(environment.getProperty("jdbc.user", "sa")); ds.setPassword(environment.getProperty("jdbc.password", "")); return ds; }
@Configuration public class SomeConfigClass { @Autowired private Environment env; public DataSource dataSource() { SimpleDriverDataSource ds = new SimpleDriverDataSource(); ds.setUsername(env.getProperty("jdbc.username")); ds.setPassword(env.getProperty("jdbc.password")); ds.setDriverClass(Driver.class); ds.setUrl(env.getProperty("jdbc.url")); return ds; } }
/** * 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); }
@Bean(name="dataSourceRedshift") public DataSource dataSourceRedshift() throws SQLException, JSchException { SimpleDriverDataSource dataSource = new SimpleDriverDataSource(); dataSource.setDriver(new com.amazon.redshift.jdbc41.Driver()); dataSource.setUrl("jdbc:postgresql://" + redshiftHost + ":" + redshiftPort + "/" + redshiftDatabase); dataSource.setUsername(redshiftUser); dataSource.setPassword(redshiftPass); DefaultSessionFactory defaultSessionFactory = new DefaultSessionFactory(); TunneledDataSourceWrapper tunneledDataSource = new TunneledDataSourceWrapper( new TunnelConnectionManager( defaultSessionFactory, redshiftTunnel ), dataSource ); return tunneledDataSource; }
/** * 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); }
dataSource.setUrl(jdbcUrl); dataSource.setUsername("sa"); dataSource.setPassword(""); logger.info("Creating embedded database: '{}'", jdbcUrl); return dataSource;
@Configuration public class SomeConfigClass { @Value("${jdbc.username}") private String username; @Value("${jdbc.password}") private String password; @Value("${jdbc.url}") private String url public DataSource dataSource() { SimpleDriverDataSource ds = new SimpleDriverDataSource(); ds.setUsername(username); ds.setPassword(password); ds.setDriverClass(Driver.class); ds.setUrl(url); return ds; } }