本文整理匯總了Java中org.springframework.jdbc.datasource.SimpleDriverDataSource.setPassword方法的典型用法代碼示例。如果您正苦於以下問題:Java SimpleDriverDataSource.setPassword方法的具體用法?Java SimpleDriverDataSource.setPassword怎麽用?Java SimpleDriverDataSource.setPassword使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.jdbc.datasource.SimpleDriverDataSource
的用法示例。
在下文中一共展示了SimpleDriverDataSource.setPassword方法的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);
}
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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: 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);
}
示例10: 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;
}
示例11: 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;
}
示例12: 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;
}
示例13: 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;
}
示例14: 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);
}
}
示例15: getDataSource
import org.springframework.jdbc.datasource.SimpleDriverDataSource; //導入方法依賴的package包/類
public DataSource getDataSource() throws FastLdrException {
try {
Class<? extends Driver> driver = (Class<? extends Driver>) Class.forName(driverClassName);
SimpleDriverDataSource dataSource = new SimpleDriverDataSource();
dataSource.setDriverClass(driver);
dataSource.setUrl(url);
dataSource.setUsername(username);
dataSource.setPassword(password);
return dataSource;
} catch (ClassNotFoundException e) {
throw new FastLdrException(e);
}
}