Example usage for org.springframework.jdbc.datasource DriverManagerDataSource setDriverClassName

List of usage examples for org.springframework.jdbc.datasource DriverManagerDataSource setDriverClassName

Introduction

In this page you can find the example usage for org.springframework.jdbc.datasource DriverManagerDataSource setDriverClassName.

Prototype

public void setDriverClassName(String driverClassName) 

Source Link

Document

Set the JDBC driver class name.

Usage

From source file:com.pactera.edg.am.metamanager.extractor.adapter.extract.db.impl.TeradataExtractServiceImpl.java

public static void main(String[] args) throws SQLException, FileNotFoundException, IOException {
    IDBExtractService extractor = new TeradataExtractServiceImpl();
    org.springframework.jdbc.datasource.DriverManagerDataSource dSource = new org.springframework.jdbc.datasource.DriverManagerDataSource();
    // dSource.setDriverClassName("com.ncr.teradata.TeraDriver");
    // dSource.setUrl("jdbc:teradata://172.19.0.158/CLIENT_CHARSET=cp936,TMODE=TERA,CHARSET=ASCII,DATABASE=MM");
    // dSource.setUsername("mmuser");
    // dSource.setPassword("mmuser");
    // extractor.setSchemas("MM");
    // File file = new File("d:\\catalog");
    ////from w w w. j  a v  a  2  s  .  co  m
    // ObjectOutput output = new ObjectOutputStream(new
    // FileOutputStream(file));
    //
    // // ?
    //
    // output.writeObject(c);
    //
    // output.close();
    //
    // System.out.println("?" + file.getAbsolutePath());
    Log4jInit.init();
    // extractor = new TeradataExtractServiceImpl();
    dSource.setDriverClassName("com.ncr.teradata.TeraDriver");
    dSource.setUrl("jdbc:teradata://172.16.171.24/CLIENT_CHARSET=cp936,TMODE=TERA,CHARSET=ASCII,DATABASE=MM");
    // dSource.setUrl("jdbc:teradata://172.19.166.203/CLIENT_CHARSET=cp936,TMODE=TERA,CHARSET=ASCII,DATABASE=MM");
    dSource.setUsername("mmuser");
    dSource.setPassword("mmuser");
    ((DBExtractBaseServiceImpl) extractor).setSchemas("edwbview");
    // ((DBExtractBaseServiceImpl) extractor).setSchemas("mm2");
    // ((DBExtractBaseServiceImpl) extractor).setSchemas("MM");
    JdbcTemplate jdbcTemplate = new JdbcTemplate(dSource);

    ((DBExtractBaseServiceImpl) extractor).setJdbcTemplate(jdbcTemplate);
    extractor.getCatalog();

}

From source file:com.fmguler.ven.LiquibaseUtil.java

/**
 * @return DataSource for the test database
 *///w  ww.j a v  a2  s.co  m
public static DataSource getDataSource() {
    DriverManagerDataSource ds = new DriverManagerDataSource();
    ds.setDriverClassName("org.postgresql.Driver");
    ds.setUsername("postgres");
    ds.setPassword("qwerty");
    ds.setUrl("jdbc:postgresql://127.0.0.1:5432/ven-test");
    return ds;
}

From source file:at.christophwurst.orm.test.IntegrationTest.java

@BeforeClass
public static void setUpClass() {
    Operation operation = DbOperations.PREPARE_DB;
    DriverManagerDataSource dataSource = new DriverManagerDataSource();
    dataSource.setDriverClassName("org.apache.derby.jdbc.ClientDriver");
    dataSource.setUrl("jdbc:derby://localhost/WorkLogDb;create=true");
    dataSource.setUsername("user");
    dataSource.setPassword("test");
    dbSetup = new DbSetup(new DataSourceDestination(dataSource), operation);
}

From source file:com.sms.server.database.SettingsDatabase.java

public static DataSource getDataSource() {
    DriverManagerDataSource ds = new DriverManagerDataSource();
    ds.setDriverClassName("org.h2.jdbcx.JdbcDataSource");
    ds.setUrl("jdbc:h2:" + SettingsService.getHomeDirectory() + "/db/settings");

    return ds;//from w  w  w  .  ja v  a  2  s  .  c  om
}

From source file:com.sms.server.database.JobDatabase.java

public static DataSource getDataSource() {
    DriverManagerDataSource ds = new DriverManagerDataSource();
    ds.setDriverClassName("org.h2.jdbcx.JdbcDataSource");
    ds.setUrl("jdbc:h2:" + SettingsService.getHomeDirectory() + "/db/job");

    return ds;/*from  ww  w . ja va  2  s  .  co m*/
}

From source file:com.sms.server.database.MediaDatabase.java

public static DataSource getDataSource() {
    DriverManagerDataSource ds = new DriverManagerDataSource();
    ds.setDriverClassName("org.h2.jdbcx.JdbcDataSource");
    ds.setUrl("jdbc:h2:" + SettingsService.getHomeDirectory() + "/db/media");

    return ds;/*from ww  w  . jav  a2s  .  co m*/
}

From source file:com.sms.server.database.UserDatabase.java

public static DataSource getDataSource() {
    DriverManagerDataSource ds = new DriverManagerDataSource();
    ds.setDriverClassName("org.h2.jdbcx.JdbcDataSource");
    ds.setUrl("jdbc:h2:" + SettingsService.getHomeDirectory() + "/db/user");

    return ds;/*from  w  w  w . j a v a 2s  .  c  o  m*/
}

From source file:com.google.api.ads.adwords.awalerting.util.JdbcUtil.java

/**
 * Create a JdbcTemplate according to the parameters.
 *
 * @param dbConfig the Json configuration for database connection
 * @param driverKey the key for JDBC driver class name
 * @param urlKey the key for JDBC url/*from   www  .jav a  2 s .  c o m*/
 * @param usernameKey the key for JDBC username
 * @param passwordKey the key JDBC password
 * @return a JdbcTemplate with the given parameters
 */
public static JdbcTemplate createJdbcTemplate(JsonObject dbConfig, String driverKey, String urlKey,
        String usernameKey, String passwordKey) {
    // Read the config values.
    String driver = DEFAULT_DB_DRIVER;
    if (dbConfig.has(driverKey)) {
        driver = dbConfig.get(driverKey).getAsString();
    }

    Preconditions.checkArgument(dbConfig.has(urlKey), "Missing compulsory property: %s", urlKey);
    String url = dbConfig.get(urlKey).getAsString();

    String username = null;
    if (dbConfig.has(usernameKey)) {
        username = dbConfig.get(usernameKey).getAsString();
    }

    String password = null;
    if (dbConfig.has(passwordKey)) {
        password = dbConfig.get(passwordKey).getAsString();
    }

    // Create the data source.
    DriverManagerDataSource dataSource = new DriverManagerDataSource();
    dataSource.setDriverClassName(driver);
    dataSource.setUrl(url);
    dataSource.setUsername(username);
    dataSource.setPassword(password);

    // Create the JdbcTemplate with the data srouce.
    return new JdbcTemplate(dataSource);
}

From source file:com.scooter1556.sms.server.utilities.DatabaseUtils.java

public static DataSource getDataSource(String db, int version) throws DatabaseException {
    if (SettingsService.getInstance().getDataDirectory() == null) {
        throw new DatabaseException("Data directory does not exist or is not writable!");
    }//w w w. ja v a  2  s. c  om

    DriverManagerDataSource dataSource = new DriverManagerDataSource();
    dataSource.setDriverClassName("org.h2.jdbcx.JdbcDataSource");
    dataSource.setUrl("jdbc:h2:" + SettingsService.getInstance().getDataDirectory() + "/db/" + db.toLowerCase()
            + "." + version + ";"
            + "MV_STORE=FALSE;MVCC=FALSE;FILE_LOCK=FS;IGNORECASE=TRUE;DATABASE_TO_UPPER=FALSE;");

    return dataSource;
}

From source file:org.tonguetied.test.common.PersistenceTestBase.java

/**
 * Create and initialize the database connection.
 * // w  w w . j a v  a 2s .c  om
 * @param properties
 */
protected static void initializeDataSource(Properties properties) {
    DriverManagerDataSource dataSource = new DriverManagerDataSource();
    dataSource.setUrl(properties.getProperty(KEY_JDBC_URL));
    dataSource.setDriverClassName(properties.getProperty(KEY_JDBC_DRIVER));
    dataSource.setUsername(properties.getProperty(KEY_JDBC_USER_NAME));
    dataSource.setPassword(properties.getProperty(KEY_JDBC_PASSWORD));
    //        final DatasourceConnectionProvider provider = new DatasourceConnectionProvider();
    //        provider.configure(properties);
    template = new SimpleJdbcTemplate(dataSource);
}