當前位置: 首頁>>代碼示例>>Java>>正文


Java SimpleDriverDataSource.setUrl方法代碼示例

本文整理匯總了Java中org.springframework.jdbc.datasource.SimpleDriverDataSource.setUrl方法的典型用法代碼示例。如果您正苦於以下問題:Java SimpleDriverDataSource.setUrl方法的具體用法?Java SimpleDriverDataSource.setUrl怎麽用?Java SimpleDriverDataSource.setUrl使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.jdbc.datasource.SimpleDriverDataSource的用法示例。


在下文中一共展示了SimpleDriverDataSource.setUrl方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: sqlInsertComment

import org.springframework.jdbc.datasource.SimpleDriverDataSource; //導入方法依賴的package包/類
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);
    }
}
 
開發者ID:khasang-incubator,項目名稱:JavaWeb20160124-Team1,代碼行數:20,代碼來源:InsertComment.java

示例2: sqlInsert

import org.springframework.jdbc.datasource.SimpleDriverDataSource; //導入方法依賴的package包/類
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);
        }
    }
 
開發者ID:khasang,項目名稱:JavaWeb20160124-Team2,代碼行數:26,代碼來源:CreateDataTable.java

示例3: sqlInsert

import org.springframework.jdbc.datasource.SimpleDriverDataSource; //導入方法依賴的package包/類
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);
    }
}
 
開發者ID:khasang,項目名稱:JavaWeb20160124-Team2,代碼行數:22,代碼來源:InsertDataTable.java

示例4: buildSimpleDataSource

import org.springframework.jdbc.datasource.SimpleDriverDataSource; //導入方法依賴的package包/類
@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;
}
 
開發者ID:netxilia,項目名稱:netxilia,代碼行數:17,代碼來源:DataSourceConfigurationServiceImpl.java

示例5: createDataSource

import org.springframework.jdbc.datasource.SimpleDriverDataSource; //導入方法依賴的package包/類
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;
}
 
開發者ID:nus-ncl,項目名稱:services-in-one,代碼行數:9,代碼來源:FlywayTest.java

示例6: createDataSource

import org.springframework.jdbc.datasource.SimpleDriverDataSource; //導入方法依賴的package包/類
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;
}
 
開發者ID:Itema-as,項目名稱:dawn-marketplace-server,代碼行數:9,代碼來源:DatabaseConfiguration.java

示例7: dataSourceB

import org.springframework.jdbc.datasource.SimpleDriverDataSource; //導入方法依賴的package包/類
@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;
}
 
開發者ID:alexwoolford,項目名稱:mybatis-spring-multiple-mysql-reproducible-example,代碼行數:10,代碼來源:DataConfigDatabaseB.java

示例8: dataSourceA

import org.springframework.jdbc.datasource.SimpleDriverDataSource; //導入方法依賴的package包/類
@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;
}
 
開發者ID:alexwoolford,項目名稱:mybatis-spring-multiple-mysql-reproducible-example,代碼行數:11,代碼來源:DataConfigDatabaseA.java

示例9: dataSource

import org.springframework.jdbc.datasource.SimpleDriverDataSource; //導入方法依賴的package包/類
@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;
}
 
開發者ID:flowable,項目名稱:flowable-engine,代碼行數:12,代碼來源:DatabaseConfiguration.java

示例10: initConnection

import org.springframework.jdbc.datasource.SimpleDriverDataSource; //導入方法依賴的package包/類
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);
}
 
開發者ID:khasang,項目名稱:JavaWeb20160124-Team2,代碼行數:9,代碼來源:SelectDataFromTable.java

示例11: dataSource

import org.springframework.jdbc.datasource.SimpleDriverDataSource; //導入方法依賴的package包/類
/**
 * 定義數據源
 * @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;
}
 
開發者ID:shawn-gogh,項目名稱:myjavacode,代碼行數:15,代碼來源:InitProcessEngineBySpringAnnotation.java

示例12: connectJdbcOnWithUrlAndDriverAndUsernameAndPassword

import org.springframework.jdbc.datasource.SimpleDriverDataSource; //導入方法依賴的package包/類
/**
 * 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;
}
 
開發者ID:andreptb,項目名稱:fitnesse-jdbc-slim,代碼行數:19,代碼來源:JdbcFixture.java

示例13: createDataSource

import org.springframework.jdbc.datasource.SimpleDriverDataSource; //導入方法依賴的package包/類
private SimpleDriverDataSource createDataSource() {
    SimpleDriverDataSource simpleDriverDataSource = new SimpleDriverDataSource();
    simpleDriverDataSource.setDriverClass(org.h2.Driver.class);
    simpleDriverDataSource.setUrl("jdbc:h2:./target/database/example;AUTO_RECONNECT=TRUE");
    simpleDriverDataSource.setUsername("");
    simpleDriverDataSource.setPassword("");
    return simpleDriverDataSource;
}
 
開發者ID:jansoren,項目名稱:maven-archetype-eventsourcing,代碼行數:9,代碼來源:DataSourceInitializer.java

示例14: dataSource_plain

import org.springframework.jdbc.datasource.SimpleDriverDataSource; //導入方法依賴的package包/類
@Bean
public DataSource dataSource_plain() {
    
    SimpleDriverDataSource ds =
            new SimpleDriverDataSource();
    
    ds.setDriverClass(null);
    ds.setUrl("jdbc:oracle:thin:@<server>[:<1521>]:<database_name>");
    ds.setUsername("");
    ds.setPassword("");
    
    return ds;
}
 
開發者ID:huherto,項目名稱:springyRecords,代碼行數:14,代碼來源:Application.java

示例15: getDataSource

import org.springframework.jdbc.datasource.SimpleDriverDataSource; //導入方法依賴的package包/類
public DataSource getDataSource() throws FastLdrException {
	String url = createUrl();
	try {
		Class<? extends Driver> driver = (Class<? extends Driver>) Class.forName("oracle.jdbc.OracleDriver");
		SimpleDriverDataSource dataSource = new SimpleDriverDataSource();
		dataSource.setDriverClass(driver);
		dataSource.setUrl(url);
		UserID userID = cmdArguments.getUserID();
		dataSource.setUsername(userID.getUser());
		dataSource.setPassword(userID.getPassword());
		return dataSource;
	} catch (ClassNotFoundException e) {
		throw new FastLdrException(e);
	}
}
 
開發者ID:AgileWorksOrg,項目名稱:fastldr,代碼行數:16,代碼來源:OracleDataSource.java


注:本文中的org.springframework.jdbc.datasource.SimpleDriverDataSource.setUrl方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。