Java 类org.springframework.jdbc.datasource.SimpleDriverDataSource 实例源码

项目:infobip-spring-data-jpa-querydsl    文件:SqlServerFlywayTestMigrationStrategy.java   
public SqlServerFlywayTestMigrationStrategy(DataSourceProperties dataSourceProps) {
    Pattern jdbcBaseUrlWithDbNamePattern = Pattern.compile(DB_URL_PATTERN);
    Matcher matcher = jdbcBaseUrlWithDbNamePattern.matcher(dataSourceProps.getUrl());

    if(!matcher.matches()) {
        throw new IllegalArgumentException(dataSourceProps.getUrl() + " does not match " + DB_URL_PATTERN);
    }

    String jdbcBaseUrl = matcher.group("jdbcBaseUrl");
    String databaseName = matcher.group("databaseName");
    databaseExistsQuery = String.format("SELECT count(*) FROM sys.databases WHERE name='%s'", databaseName);
    createDatabaseQuery = String.format("CREATE DATABASE %s", databaseName);
    this.template = new JdbcTemplate(new SimpleDriverDataSource(
            getDriver(jdbcBaseUrl),
            jdbcBaseUrl,
            dataSourceProps.getUsername(),
            dataSourceProps.getPassword()));
}
项目:EntityGenerator    文件:EntityGenApplication.java   
private Connection getConn(String url, String userName, String password) throws SQLException {
    Driver driver = null;
    if (url.contains("mysql")) {
        driver = new com.mysql.jdbc.Driver();
    } else if (url.contains("postgresql")) {
        driver = new org.postgresql.Driver();
    } else if (url.contains("sqlserver")) {
        driver = new com.microsoft.sqlserver.jdbc.SQLServerDriver();
    } else if (url.contains("oracle")) {
        driver = new oracle.jdbc.OracleDriver();
    } else {
        throw new RuntimeException("不支持此类型数据库");
    }

    DataSource dataSource = new SimpleDriverDataSource(driver, url, userName, password);
    try {
        return dataSource.getConnection();
    } catch (SQLException e) {
        throw new RuntimeException(e);
    }
}
项目:plugin-bt-jira    文件:JiraExportPluginResourceTest.java   
/**
 * Initialize data base with 'MDA' JIRA project.
 */
@BeforeClass
public static void initializeJiraDataBaseForSla() throws SQLException {
    final DataSource datasource = new SimpleDriverDataSource(new JDBCDriver(), "jdbc:hsqldb:mem:dataSource", null, null);
    final Connection connection = datasource.getConnection();
    try {
        ScriptUtils.executeSqlScript(connection, new EncodedResource(new ClassPathResource("sql/sla/jira-create.sql"), StandardCharsets.UTF_8));
        ScriptUtils.executeSqlScript(connection, new EncodedResource(new ClassPathResource("sql/sla/jira.sql"), StandardCharsets.UTF_8));
    } finally {
        connection.close();
    }
}
项目:plugin-bt-jira    文件:AbstractJiraTest.java   
/**
 * Initialize data base with 'MDA' JIRA project.
 */
@BeforeClass
public static void initializeJiraDataBase() throws SQLException {
    datasource = new SimpleDriverDataSource(new JDBCDriver(), "jdbc:hsqldb:mem:dataSource", null, null);
    final Connection connection = datasource.getConnection();
    final JdbcTemplate jdbcTemplate = new JdbcTemplate(datasource);
    try {
        ScriptUtils.executeSqlScript(connection,
                new EncodedResource(new ClassPathResource("sql/base-1/jira-create.sql"), StandardCharsets.UTF_8));
        ScriptUtils.executeSqlScript(connection,
                new EncodedResource(new ClassPathResource("sql/base-1/jira.sql"), StandardCharsets.UTF_8));
        jdbcTemplate.queryForList("SELECT * FROM pluginversion WHERE ID = 10075");
    } finally {
        connection.close();
    }
}
项目:plugin-bt-jira    文件:JiraUpdateDaoTest.java   
/**
 * Initialize data base with 'MDA' JIRA project.
 */
@BeforeClass
public static void initializeJiraDataBaseForImport() throws SQLException {
    datasource = new SimpleDriverDataSource(new JDBCDriver(), "jdbc:hsqldb:mem:dataSource", null, null);
    final Connection connection = datasource.getConnection();
    try {
        ScriptUtils.executeSqlScript(connection,
                new EncodedResource(new ClassPathResource("sql/base-1/jira-create.sql"), StandardCharsets.UTF_8));
        ScriptUtils.executeSqlScript(connection,
                new EncodedResource(new ClassPathResource("sql/base-2/jira-create.sql"), StandardCharsets.UTF_8));
        ScriptUtils.executeSqlScript(connection,
                new EncodedResource(new ClassPathResource("sql/upload/jira-create.sql"), StandardCharsets.UTF_8));

        ScriptUtils.executeSqlScript(connection, new EncodedResource(new ClassPathResource("sql/base-1/jira.sql"), StandardCharsets.UTF_8));
        ScriptUtils.executeSqlScript(connection, new EncodedResource(new ClassPathResource("sql/base-2/jira.sql"), StandardCharsets.UTF_8));
        ScriptUtils.executeSqlScript(connection, new EncodedResource(new ClassPathResource("sql/upload/jira.sql"), StandardCharsets.UTF_8));
    } finally {
        connection.close();
    }
}
项目:spring4-understanding    文件:EmbeddedDatabaseFactory.java   
/**
 * Hook to shutdown the embedded database. Subclasses may call this method
 * to force shutdown.
 * <p>After calling, {@link #getDataSource()} returns {@code null}.
 * <p>Does nothing if no embedded database has been initialized.
 */
protected void shutdownDatabase() {
    if (this.dataSource != null) {

        if (logger.isInfoEnabled()) {
            if (this.dataSource instanceof SimpleDriverDataSource) {
                logger.info(String.format("Shutting down embedded database: url='%s'",
                    ((SimpleDriverDataSource) this.dataSource).getUrl()));
            }
            else {
                logger.info(String.format("Shutting down embedded database '%s'", this.databaseName));
            }
        }

        this.databaseConfigurer.shutdown(this.dataSource, this.databaseName);
        this.dataSource = null;
    }
}
项目:JavaWeb20160124-Team1    文件:InsertComment.java   
public void sqlInsertComment() {
    String comment = "something"; // TODO: 17.02.2016 задание строки юзером
    SimpleDriverDataSource dataSource = new SimpleDriverDataSource();
    dataSource.setDriverClass(com.mysql.jdbc.Driver.class);
    dataSource.setUsername("root");
    dataSource.setUrl("jdbc:mysql://localhost/wlogs");
    dataSource.setPassword("root");
    JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
    System.out.println("checking connection...");
    try {
        System.out.println("getting current statistic table...");
        createTable();
        System.out.println("Insert comment");
        jdbcTemplate.update("INSERT INTO statistic (comment) VALUE (?)", comment);
    } catch (Exception e) {
        sqlCheck = "Have error " + e;
        System.err.println(sqlCheck);
    }
}
项目:JavaWeb20160124-Team2    文件:CreateDataTable.java   
public void sqlInsert() {
        SimpleDriverDataSource dataSource = new SimpleDriverDataSource();
        dataSource.setDriverClass(com.mysql.jdbc.Driver.class);
        dataSource.setUsername("root");
        dataSource.setUrl("jdbc:mysql://localhost/webstore");
        dataSource.setPassword("root");
        JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
        System.out.println("try to update db...");
        try {
            System.out.println("Creating tables");
            /*jdbcTemplate.execute("DROP TABLE IF EXISTS products");
            jdbcTemplate.execute("create table products(ID INT NOT NULL,"
                    + " pName MEDIUMTEXT NOT NULL, description LONGTEXT)");*/
//            jdbcTemplate.update("INSERT INTO products(ID, pName, description) VALUES(1, 'apple', 'red')");
//            jdbcTemplate.update("INSERT INTO products(ID, pName, description) VALUES(2, 'banan', 'yellow')");
//            jdbcTemplate.update("INSERT INTO products(ID, pName, description) VALUES(3, 'bread', null)");
            jdbcTemplate.update("INSERT INTO products(ID, pName, description) VALUES(4, 'milk', 'natural')");
            jdbcTemplate.update("INSERT INTO products(ID, pName, description) VALUES(5, 'becon', null)");
            jdbcTemplate.update("INSERT INTO products(ID, pName, description) VALUES(6, 'bread', 'black')");
            sqlCheck = "db updated";
        } catch (Exception e) {
            sqlCheck = "Have error: " + e;
            System.err.println(sqlCheck);
        }
    }
项目:JavaWeb20160124-Team2    文件:InsertDataTable.java   
public void sqlInsert() {
    SimpleDriverDataSource dataSource = new SimpleDriverDataSource();
    dataSource.setDriverClass(com.mysql.jdbc.Driver.class);
    dataSource.setUsername("root");
    dataSource.setUrl("jdbc:mysql://localhost/webstore");
    dataSource.setPassword("root");
    JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
    System.out.println("try to update db...");
    try {
        System.out.println("Creating tables");
        jdbcTemplate.execute("DROP TABLE IF EXISTS products");
        jdbcTemplate.execute("create table products(ID INT NOT NULL,"
                + " pname MEDIUMTEXT NOT NULL, description MEDIUMTEXT NOT NULL)");
        jdbcTemplate.update("INSERT INTO products(ID, pName, description) VALUES(7, 'milk', 'cow')");
        jdbcTemplate.update("INSERT INTO products(ID, pName, description) VALUES(8, 'bread', 'grey')");
        sqlCheck = "db updated";
    } catch (Exception e) {
        sqlCheck = "Have error: " + e;
        System.err.println(sqlCheck);
    }
}
项目:gerbil    文件:DataMigrationTool.java   
public static void main(String[] args) {
    ExperimentDAO source = null;
    ExperimentDAO target = null;
    try {
        source = new ExperimentDAOImpl(
                new SimpleDriverDataSource(new org.hsqldb.jdbc.JDBCDriver(), "jdbc:hsqldb:file:" + SOURCE_DB_PATH));
        source.initialize();
        target = new ExperimentDAOImpl(
                new SimpleDriverDataSource(new org.hsqldb.jdbc.JDBCDriver(), "jdbc:hsqldb:file:" + TARGET_DB_PATH));
        target.initialize();
        performMigration(source, target);
    } finally {
        IOUtils.closeQuietly(source);
        IOUtils.closeQuietly(target);
    }
}
项目:ddth-dao    文件:DdthJdbcHelperTCase.java   
@Override
protected AbstractJdbcHelper buildJdbcHelper() throws SQLException {
    String hostAndPort = System.getProperty("mysql.hostAndPort", "localhost:3306");
    String user = System.getProperty("mysql.user", "travis");
    String password = System.getProperty("mysql.pwd", "");
    String db = System.getProperty("mysql.db", "test");
    String url = "jdbc:mysql://" + hostAndPort + "/" + db
            + "?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false";
    DataSource ds = new SimpleDriverDataSource(DriverManager.getDriver(url), url, user,
            password);

    DdthJdbcHelper jdbcHelper = new DdthJdbcHelper();
    jdbcHelper.setDataSource(ds);

    jdbcHelper.init();
    return jdbcHelper;
}
项目:ddth-dao    文件:JdbcTemplateJdbcHelperTCase.java   
@Override
protected AbstractJdbcHelper buildJdbcHelper() throws SQLException {
    String hostAndPort = System.getProperty("mysql.hostAndPort", "localhost:3306");
    String user = System.getProperty("mysql.user", "travis");
    String password = System.getProperty("mysql.pwd", "");
    String db = System.getProperty("mysql.db", "test");
    String url = "jdbc:mysql://" + hostAndPort + "/" + db
            + "?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false";
    DataSource ds = new SimpleDriverDataSource(DriverManager.getDriver(url), url, user,
            password);

    JdbcTemplateJdbcHelper jdbcHelper = new JdbcTemplateJdbcHelper();
    jdbcHelper.setDataSource(ds);

    jdbcHelper.init();
    return jdbcHelper;
}
项目:ddth-dao    文件:DdthJdbcHelperTCase.java   
@Override
protected AbstractJdbcHelper buildJdbcHelper() throws SQLException {
    String hostAndPort = System.getProperty("mysql.hostAndPort", "localhost:3306");
    String user = System.getProperty("mysql.user", "travis");
    String password = System.getProperty("mysql.pwd", "");
    String db = System.getProperty("mysql.db", "test");
    String url = "jdbc:mysql://" + hostAndPort + "/" + db
            + "?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false";
    DataSource ds = new SimpleDriverDataSource(DriverManager.getDriver(url), url, user,
            password);

    DdthJdbcHelper jdbcHelper = new DdthJdbcHelper();
    jdbcHelper.setDataSource(ds);

    jdbcHelper.init();
    return jdbcHelper;
}
项目:ddth-dao    文件:JdbcTemplateJdbcHelperTCase.java   
@Override
protected AbstractJdbcHelper buildJdbcHelper() throws SQLException {
    String hostAndPort = System.getProperty("mysql.hostAndPort", "localhost:3306");
    String user = System.getProperty("mysql.user", "travis");
    String password = System.getProperty("mysql.pwd", "");
    String db = System.getProperty("mysql.db", "test");
    String url = "jdbc:mysql://" + hostAndPort + "/" + db
            + "?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false";
    DataSource ds = new SimpleDriverDataSource(DriverManager.getDriver(url), url, user,
            password);

    JdbcTemplateJdbcHelper jdbcHelper = new JdbcTemplateJdbcHelper();
    jdbcHelper.setDataSource(ds);

    jdbcHelper.init();
    return jdbcHelper;
}
项目:ddth-dao    文件:JdbcTemplateGenericJdbcDaoTCase.java   
@Override
protected UserBoJdbcDao buildUserDao() throws SQLException {
    String hostAndPort = System.getProperty("mysql.hostAndPort", "localhost:3306");
    String user = System.getProperty("mysql.user", "travis");
    String password = System.getProperty("mysql.pwd", "");
    String db = System.getProperty("mysql.db", "test");
    String url = "jdbc:mysql://" + hostAndPort + "/" + db
            + "?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false";
    DataSource ds = new SimpleDriverDataSource(DriverManager.getDriver(url), url, user,
            password);

    JdbcTemplateJdbcHelper jdbcHelper = new JdbcTemplateJdbcHelper();
    jdbcHelper.setDataSource(ds);
    jdbcHelper.init();

    GenericUserBoRowMapper rowMapper = new GenericUserBoRowMapper();

    UserBoJdbcDao userDao = new UserBoJdbcDao();
    userDao.setTableName("tbl_user_gjd").setRowMapper(rowMapper).setJdbcHelper(jdbcHelper);
    userDao.init();
    return userDao;
}
项目:ddth-dao    文件:DdthGenericJdbcDaoTCase.java   
@Override
protected UserBoJdbcDao buildUserDao() throws SQLException {
    String hostAndPort = System.getProperty("mysql.hostAndPort", "localhost:3306");
    String user = System.getProperty("mysql.user", "travis");
    String password = System.getProperty("mysql.pwd", "");
    String db = System.getProperty("mysql.db", "test");
    String url = "jdbc:mysql://" + hostAndPort + "/" + db
            + "?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false";
    DataSource ds = new SimpleDriverDataSource(DriverManager.getDriver(url), url, user,
            password);

    DdthJdbcHelper jdbcHelper = new DdthJdbcHelper();
    jdbcHelper.setDataSource(ds);
    jdbcHelper.init();

    GenericUserBoRowMapper rowMapper = new GenericUserBoRowMapper();

    UserBoJdbcDao userDao = new UserBoJdbcDao();
    userDao.setTableName("tbl_user_gjd").setRowMapper(rowMapper).setJdbcHelper(jdbcHelper);
    userDao.init();
    return userDao;
}
项目:netxilia    文件:DataSourceConfigurationServiceImpl.java   
@SuppressWarnings("unchecked")
public DataSource buildSimpleDataSource(DataSourceConfiguration cfg) {
    SimpleDriverDataSource dataSource = new SimpleDriverDataSource();

    Class<? extends Driver> driverClass;
    try {
        driverClass = (Class<? extends Driver>) Class.forName(cfg.getDriverClassName());
    } catch (ClassNotFoundException e) {
        throw new NetxiliaResourceException("Cannot find class driver:" + cfg.getDriverClassName());
    }
    dataSource.setDriverClass(driverClass);
    dataSource.setUrl(cfg.getUrl().replace(NETXILIA_HOME_VAR, path));
    dataSource.setUsername(cfg.getUsername());
    dataSource.setPassword(cfg.getPassword());
    return dataSource;
}
项目:adaptive-spring    文件:ServiceConfiguration.java   
@Bean
@ConditionalOnPropertiesPresent({
        postgresUser, postgresPassword,
        postgresUrl, postgresDriverClass
})
public DataSource postgres(Environment e) {
    try {
        String user = e.getProperty(postgresUser),
                pw = e.getProperty(postgresPassword),
                url = e.getProperty(postgresUrl);
        Class<? extends Driver> driverClass = e.getPropertyAsClass(
                postgresDriverClass, Driver.class);

        Driver actualDriverInstance = driverClass.newInstance();
        return new SimpleDriverDataSource(actualDriverInstance, url, user, pw);
    } catch (Exception exception) {
        throw new RuntimeException(exception);
    }
}
项目:adaptive-spring    文件:SwappableDataSourceConfiguration.java   
@Bean
public DataSource dataSourceRefreshableBeanFactoryBean(final Environment environment) throws Exception {
    RefreshableFactoryBean<DataSource> ds = new RefreshableFactoryBean<DataSource>(
                new Provider<DataSource>() {
        @Override
        public DataSource get() {
            try {
                String url = environment.getProperty(DB_URL);
                String pw = environment.getProperty(DB_PASSWORD);
                String user = environment.getProperty(DB_USER);
                Class<? extends Driver> driverClass = environment.getPropertyAsClass(DB_DRIVER_CLASS, Driver.class);
                Driver newInstance = driverClass.newInstance();
                log.info(String.format("refreshing dataSource configuration" +
                        " with new values: url=%s, password=%s, user=%s", url, pw, user));
                return new SimpleDriverDataSource(newInstance, url, user, pw);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }

        }
    });
    return ds.getObject();
}
项目:quickmon    文件:JdbcSampler.java   
public JdbcSampler(JdbcSamplerBuilder builder) {
    this.sql = builder.getSql();
    this.url = builder.getUrl();
    this.timeout = builder.getTimeout();

    SimpleDriverDataSource simpleDriverDataSource = new SimpleDriverDataSource(
            getDriver(builder),
            builder.getUrl()
    );

    this.jdbcTemplate = new JdbcTemplate(simpleDriverDataSource);
    this.jdbcTemplate.setQueryTimeout(builder.getTimeout());
}
项目:FastSQL    文件:SQLFactoryTest.java   
@Test
public void crateFactory() {
    DataSource dataSource = new SimpleDriverDataSource();

    SQLFactory sqlFactory = new SQLFactory();
    sqlFactory.setDataSource(dataSource);
}
项目:FastSQL    文件:SQLFactoryTest.java   
@Test
    public void crateSQL() {
        DataSource dataSource = new SimpleDriverDataSource();

        SQLFactory sqlFactory = new SQLFactory();
        sqlFactory.setDataSource(dataSource);

        SQL sql = sqlFactory.createSQL();
//        Student student = sql.SELECT("*").FROM("student").WHERE("id=101").queryOne(Student.class);
    }
项目:uPortal-start    文件:PortalPersonDirUserPasswordDaoTest.java   
@Override
protected void setUp() throws Exception {
    this.dataSource =
            new SimpleDriverDataSource(
                    new org.hsqldb.jdbcDriver(), "jdbc:hsqldb:mem:CasTest", "sa", "");

    this.jdbcTemplate = new JdbcTemplate(this.dataSource);
    this.jdbcTemplate.execute(
            "CREATE TABLE UP_PERSON_DIR (USER_NAME VARCHAR(1000), ENCRPTD_PSWD VARCHAR(1000))");

    this.userPasswordDao = new PortalPersonDirUserPasswordDao();
    this.userPasswordDao.setDataSource(this.dataSource);
}
项目:jwala    文件:TestJpaConfiguration.java   
@Bean
public DataSource getDataSource() {
    return new SimpleDriverDataSource(new Driver(),
            "jdbc:h2:mem:test-services;DB_CLOSE_DELAY=-1;LOCK_MODE=0",
            "sa",
            "");
}
项目:plugin-bt-jira    文件:JiraBaseResource.java   
/**
 * Return the data source of JIRA database server.
 * 
 * @param parameters
 *            the subscription parameters containing at least the data source
 *            configuration.
 * @return the data source of JIRA database server.
 */
protected DataSource getDataSource(final Map<String, String> parameters) {
    try {
        return new SimpleDriverDataSource(
                (Driver) Class.forName(StringUtils.defaultIfBlank(parameters.get(PARAMETER_JDBC_DRIVER), "com.mysql.cj.jdbc.Driver"))
                        .newInstance(),
                StringUtils.defaultIfBlank(parameters.get(PARAMETER_JDBC_URL),
                        "jdbc:mysql://localhost:3306/jira6?useColumnNamesInFindColumn=true&useUnicode=yes&characterEncoding=UTF-8&autoReconnect=true&maxReconnects=3"),
                parameters.get(PARAMETER_JDBC_USER), parameters.get(PARAMETER_JDBC_PASSSWORD));
    } catch (final Exception e) {
        log.error("Database connection issue for JIRA", e);
        throw new TechnicalException("Database connection issue for JIRA", e);
    }
}
项目:plugin-bt-jira    文件:JiraExportPluginResourceTest.java   
/**
 * Clean data base with 'MDA' JIRA project.
 */
@AfterClass
public static void cleanJiraDataBaseForSla() throws SQLException {
    final DataSource datasource = new SimpleDriverDataSource(new JDBCDriver(), "jdbc:hsqldb:mem:dataSource", null, null);
    final Connection connection = datasource.getConnection();

    try {
        ScriptUtils.executeSqlScript(connection, new EncodedResource(new ClassPathResource("sql/sla/jira-drop.sql"), StandardCharsets.UTF_8));
    } finally {
        connection.close();
    }
}
项目:plugin-bt-jira    文件:AbstractJiraUploadTest.java   
/**
 * Initialize data base with 'MDA' JIRA project.
 */
@BeforeClass
public static void initializeJiraDataBaseForImport() throws SQLException {
    final DataSource datasource = new SimpleDriverDataSource(new JDBCDriver(), "jdbc:hsqldb:mem:dataSource", null, null);
    final Connection connection = datasource.getConnection();
    try {
        ScriptUtils.executeSqlScript(connection,
                new EncodedResource(new ClassPathResource("sql/upload/jira-create.sql"), StandardCharsets.UTF_8));
        ScriptUtils.executeSqlScript(connection, new EncodedResource(new ClassPathResource("sql/upload/jira.sql"), StandardCharsets.UTF_8));
    } finally {
        connection.close();
    }
}
项目:plugin-bt-jira    文件:AbstractJiraUploadTest.java   
/**
 * Clean data base with 'MDA' JIRA project.
 */
@AfterClass
public static void cleanJiraDataBaseForImport() throws SQLException {
    final DataSource datasource = new SimpleDriverDataSource(new JDBCDriver(), "jdbc:hsqldb:mem:dataSource", null, null);
    final Connection connection = datasource.getConnection();

    try {
        ScriptUtils.executeSqlScript(connection, new EncodedResource(new ClassPathResource("sql/upload/jira-drop.sql"), StandardCharsets.UTF_8));
    } finally {
        connection.close();
    }
}
项目:services-in-one    文件:FlywayTest.java   
private SimpleDriverDataSource createDataSource() {
    SimpleDriverDataSource simpleDriverDataSource = new SimpleDriverDataSource();
    simpleDriverDataSource.setDriverClass(org.h2.Driver.class);
    simpleDriverDataSource.setUrl("jdbc:h2:mem:prod;MODE=MySQL;DB_CLOSE_DELAY=-1;INIT=CREATE SCHEMA IF NOT EXISTS \"public\"");
    simpleDriverDataSource.setUsername("sa");
    simpleDriverDataSource.setPassword("");
    return simpleDriverDataSource;
}
项目:dawn-marketplace-server    文件:DatabaseConfiguration.java   
private SimpleDriverDataSource createDataSource() {
    SimpleDriverDataSource simpleDriverDataSource = new SimpleDriverDataSource();
    simpleDriverDataSource.setDriverClass(org.hsqldb.jdbcDriver.class);
    simpleDriverDataSource.setUrl(environment.getProperty("marketplace.system-db"));
    simpleDriverDataSource.setUsername("");
    simpleDriverDataSource.setPassword("");
    return simpleDriverDataSource;
}
项目:spring4-understanding    文件:EmbeddedDatabaseFactory.java   
/**
 * Hook to initialize the embedded database.
 * <p>If the {@code generateUniqueDatabaseName} flag has been set to {@code true},
 * the current value of the {@linkplain #setDatabaseName database name} will
 * be overridden with an auto-generated name.
 * <p>Subclasses may call this method to force initialization; however,
 * this method should only be invoked once.
 * <p>After calling this method, {@link #getDataSource()} returns the
 * {@link DataSource} providing connectivity to the database.
 */
protected void initDatabase() {
    if (this.generateUniqueDatabaseName) {
        setDatabaseName(UUID.randomUUID().toString());
    }

    // Create the embedded database first
    if (this.databaseConfigurer == null) {
        this.databaseConfigurer = EmbeddedDatabaseConfigurerFactory.getConfigurer(EmbeddedDatabaseType.HSQL);
    }
    this.databaseConfigurer.configureConnectionProperties(
            this.dataSourceFactory.getConnectionProperties(), this.databaseName);
    this.dataSource = this.dataSourceFactory.getDataSource();

    if (logger.isInfoEnabled()) {
        if (this.dataSource instanceof SimpleDriverDataSource) {
            SimpleDriverDataSource simpleDriverDataSource = (SimpleDriverDataSource) this.dataSource;
            logger.info(String.format("Starting embedded database: url='%s', username='%s'",
                simpleDriverDataSource.getUrl(), simpleDriverDataSource.getUsername()));
        }
        else {
            logger.info(String.format("Starting embedded database '%s'", this.databaseName));
        }
    }

    // Now populate the database
    if (this.databasePopulator != null) {
        try {
            DatabasePopulatorUtils.execute(this.databasePopulator, this.dataSource);
        }
        catch (RuntimeException ex) {
            // failed to populate, so leave it as not initialized
            shutdownDatabase();
            throw ex;
        }
    }
}
项目:hive-broker    文件:ServiceInstanceProvisioningConfig.java   
@Bean
public JdbcOperations hiveOperations(Driver driver) throws IOException {
  String hiveUrl = hiveClient.getConnectionUrl();
  LOGGER.info("Creating jdbc template for url: " + hiveUrl);
  if(!hiveClient.isKerberosEnabled()) {
    return new JdbcTemplate(new SimpleDriverDataSource(driver, hiveUrl));
  }
  return kerberizedHiveOperations(hiveUrl);
}
项目:mybatis-spring-multiple-mysql-reproducible-example    文件:DataConfigDatabaseB.java   
@Bean(name="dataSourceB")
public DataSource dataSourceB() throws SQLException {
    SimpleDriverDataSource dataSource = new SimpleDriverDataSource();
    dataSource.setDriver(new org.apache.derby.jdbc.ClientDriver());
    dataSource.setUrl("jdbc:derby://" + dbHostB + ":"+ dbPortB + "/" + dbDatabaseB + ";create=false");
    dataSource.setUsername(dbUserB);
    dataSource.setPassword(dbPasswordB);
    return dataSource;
}
项目:mybatis-spring-multiple-mysql-reproducible-example    文件:DataConfigDatabaseA.java   
@Bean(name="dataSourceA")
@Primary
public DataSource dataSourceA() throws SQLException {
    SimpleDriverDataSource dataSource = new SimpleDriverDataSource();
    dataSource.setDriver(new com.mysql.jdbc.Driver());
    dataSource.setUrl("jdbc:mysql://" + dbHostA + ":" + dbPortA + "/" + dbDatabaseA);
    dataSource.setUsername(dbUserA);
    dataSource.setPassword(dbPasswordA);
    return dataSource;
}
项目:flowable-engine    文件:DatabaseConfiguration.java   
@Bean
public DataSource dataSource() {
    SimpleDriverDataSource ds = new SimpleDriverDataSource();
    ds.setDriverClass(org.h2.Driver.class);

    // Connection settings
    ds.setUrl("jdbc:h2:mem:flowable;DB_CLOSE_DELAY=1000");
    ds.setUsername("sa");

    return ds;
}
项目:flowable-engine    文件:EngineConfiguration.java   
@Bean
public DataSource dataSource() {
    SimpleDriverDataSource ds = new SimpleDriverDataSource();
    ds.setDriverClass(org.h2.Driver.class);

    // Connection settings
    ds.setUrl("jdbc:h2:mem:flowable;DB_CLOSE_DELAY=1000");
    ds.setUsername("sa");

    return ds;
}
项目:JavaWeb20160124-Team2    文件:SelectDataFromTable.java   
public void initConnection() {
    dataSource = new SimpleDriverDataSource();
    dataSource.setDriverClass(com.mysql.jdbc.Driver.class);
    dataSource.setUsername("root");
    dataSource.setUrl("jdbc:mysql://localhost/webstore");
    dataSource.setPassword("root");
    jdbcTemplate = new JdbcTemplate(dataSource);
}
项目:myjavacode    文件:InitProcessEngineBySpringAnnotation.java   
/**
 * 定义数据源
 * @return
 * @throws ClassNotFoundException
 */
@Bean
public DataSource dataSource() throws ClassNotFoundException {
    SimpleDriverDataSource simpleDriverDataSource = new SimpleDriverDataSource();
    simpleDriverDataSource.setDriverClass((Class<? extends Driver>) Class.forName("org.h2.Driver"));
    simpleDriverDataSource.setUrl("jdbc:h2:mem:aia-chapter7;DB_CLOSE_DELAY=1000");
    simpleDriverDataSource.setUsername("sa");
    simpleDriverDataSource.setPassword("");
    return simpleDriverDataSource;
}
项目:activiti-in-action-codes    文件:InitProcessEngineBySpringAnnotation.java   
/**
 * 定义数据源
 * @return
 * @throws ClassNotFoundException
 */
@Bean
public DataSource dataSource() throws ClassNotFoundException {
    SimpleDriverDataSource simpleDriverDataSource = new SimpleDriverDataSource();
    simpleDriverDataSource.setDriverClass((Class<? extends Driver>) Class.forName("org.h2.Driver"));
    simpleDriverDataSource.setUrl("jdbc:h2:mem:aia-chapter7;DB_CLOSE_DELAY=1000");
    simpleDriverDataSource.setUsername("sa");
    simpleDriverDataSource.setPassword("");
    return simpleDriverDataSource;
}
项目:fitnesse-jdbc-slim    文件:JdbcFixture.java   
/**
 * Registers a database to further execute SQL commands
 *
 * <p><code>
 * | connect jdbc on | <i>database</i> | with url | <i>url</i> | and driver | <i>driver</i> | and username | <i>username</i> | and | <i>password</i> |
 * </code></p>
 * @param url
 */
@SuppressWarnings("unchecked")
public boolean connectJdbcOnWithUrlAndDriverAndUsernameAndPassword(String dataBaseId, String url, String driverClassName, String username, String password) throws ReflectiveOperationException {
    SimpleDriverDataSource dataSource = new SimpleDriverDataSource();
    dataSource.setUrl(url);
    dataSource.setDriverClass((Class<Driver>) Class.forName(driverClassName));
    dataSource.setUsername(username);
    dataSource.setPassword(password);
    this.templateMap.put(dataBaseId, new JdbcTemplate(dataSource));
    return true;
}