当前位置: 首页>>代码示例>>Java>>正文


Java SimpleDriverDataSource.setUsername方法代码示例

本文整理汇总了Java中org.springframework.jdbc.datasource.SimpleDriverDataSource.setUsername方法的典型用法代码示例。如果您正苦于以下问题:Java SimpleDriverDataSource.setUsername方法的具体用法?Java SimpleDriverDataSource.setUsername怎么用?Java SimpleDriverDataSource.setUsername使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.jdbc.datasource.SimpleDriverDataSource的用法示例。


在下文中一共展示了SimpleDriverDataSource.setUsername方法的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.setUsername方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。