本文整理汇总了Java中org.hsqldb.jdbc.JDBCDataSource.getConnection方法的典型用法代码示例。如果您正苦于以下问题:Java JDBCDataSource.getConnection方法的具体用法?Java JDBCDataSource.getConnection怎么用?Java JDBCDataSource.getConnection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.hsqldb.jdbc.JDBCDataSource
的用法示例。
在下文中一共展示了JDBCDataSource.getConnection方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resetCredentialsCommand
import org.hsqldb.jdbc.JDBCDataSource; //导入方法依赖的package包/类
/**
* Reset admin credentials to username/password: admin/admin
*
* @throws SQLException
*/
private static void resetCredentialsCommand() throws SQLException {
System.out.println("*** RESET ADMIN CREDENTIALS TO admin / admin ***");
JDBCDataSource dataSource = new JDBCDataSource();
dataSource.setUrl("jdbc:hsqldb:hsql://localhost:" + System.getProperty("dbport") + "/data");
dataSource.setUser("sa");
dataSource.setPassword("");
Connection connection = dataSource.getConnection();
// admin ~
// $2a$10$UHdpe.t2Xr3npu1AcDygO.FkiK5Ki4SmUU8oW.gD8liApMG4yDqw6
PreparedStatement preparedStatement = connection
.prepareStatement("update monit_configuration set admin_username = 'admin', admin_password = '$2a$10$UHdpe.t2Xr3npu1AcDygO.FkiK5Ki4SmUU8oW.gD8liApMG4yDqw6'");
preparedStatement.executeUpdate();
preparedStatement.close();
connection.close();
}
示例2: setup
import org.hsqldb.jdbc.JDBCDataSource; //导入方法依赖的package包/类
@BeforeEach
void setup() throws SQLException {
registry = new SimpleMeterRegistry();
ds = new JDBCDataSource();
ds.setURL("jdbc:hsqldb:mem:test");
try(Connection conn = ds.getConnection()) {
conn.prepareStatement("CREATE TABLE foo (id int)").execute();
conn.prepareStatement("INSERT INTO foo VALUES (1)").executeUpdate();
}
}
示例3: setUp
import org.hsqldb.jdbc.JDBCDataSource; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() throws Exception {
Class.forName("org.hsqldb.jdbcDriver");
JDBCDataSource dataSource = new JDBCDataSource();
dataSource.setUrl("jdbc:hsqldb:mem:db4");
dataSource.setUser("sa");
dataSource.setPassword("");
try (Connection conn = dataSource.getConnection()) {
try (Reader reader = Resources.getResourceAsReader("org/mybatis/scripting/freemarker/create-db.sql")) {
ScriptRunner runner = new ScriptRunner(conn);
runner.setLogWriter(null);
runner.setErrorLogWriter(null);
runner.runScript(reader);
conn.commit();
}
}
TransactionFactory transactionFactory = new JdbcTransactionFactory();
Environment environment = new Environment("development", transactionFactory, dataSource);
// You can call configuration.setDefaultScriptingLanguage(FreeMarkerLanguageDriver.class)
// after this to use FreeMarker driver by default.
Configuration configuration = new Configuration(environment);
configuration.addMapper(CustomizedDataContextMapper.class);
sqlSessionFactory = new SqlSessionFactoryBuilder().build(configuration);
}
示例4: setUp
import org.hsqldb.jdbc.JDBCDataSource; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() throws Exception {
Class.forName("org.hsqldb.jdbcDriver");
JDBCDataSource dataSource = new JDBCDataSource();
dataSource.setUrl("jdbc:hsqldb:mem:db3");
dataSource.setUser("sa");
dataSource.setPassword("");
try (Connection conn = dataSource.getConnection()) {
try (Reader reader = Resources.getResourceAsReader("org/mybatis/scripting/freemarker/create-db.sql")) {
ScriptRunner runner = new ScriptRunner(conn);
runner.setLogWriter(null);
runner.setErrorLogWriter(null);
runner.runScript(reader);
conn.commit();
}
}
TransactionFactory transactionFactory = new JdbcTransactionFactory();
Environment environment = new Environment("development", transactionFactory, dataSource);
// You can call configuration.setDefaultScriptingLanguage(FreeMarkerLanguageDriver.class)
// after this to use FreeMarker driver by default.
Configuration configuration = new Configuration(environment);
configuration.addMapper(PreparedParamsMapper.class);
sqlSessionFactory = new SqlSessionFactoryBuilder().build(configuration);
}
示例5: setUp
import org.hsqldb.jdbc.JDBCDataSource; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() throws Exception {
Class.forName("org.hsqldb.jdbcDriver");
JDBCDataSource dataSource = new JDBCDataSource();
dataSource.setUrl("jdbc:hsqldb:mem:db1");
dataSource.setUser("sa");
dataSource.setPassword("");
try (Connection conn = dataSource.getConnection()) {
try (Reader reader = Resources.getResourceAsReader("org/mybatis/scripting/freemarker/create-db.sql")) {
ScriptRunner runner = new ScriptRunner(conn);
runner.setLogWriter(null);
runner.setErrorLogWriter(null);
runner.runScript(reader);
conn.commit();
}
}
TransactionFactory transactionFactory = new JdbcTransactionFactory();
Environment environment = new Environment("development", transactionFactory, dataSource);
// You can call configuration.setDefaultScriptingLanguage(FreeMarkerLanguageDriver.class)
// after this to use FreeMarker driver by default.
Configuration configuration = new Configuration(environment);
configuration.addMapper(NameMapper.class);
sqlSessionFactory = new SqlSessionFactoryBuilder().build(configuration);
}
示例6: bootstrapInMemoryDatabase
import org.hsqldb.jdbc.JDBCDataSource; //导入方法依赖的package包/类
/** Create in-memory database table so that mapper methods might operate on something */
private JDBCDataSource bootstrapInMemoryDatabase() throws SQLException {
JDBCDataSource dataSource = new JDBCDataSource();
dataSource.setUrl( "jdbc:hsqldb:mem:guice-integration-test" );
dataSource.setUser( "sa" );
dataSource.setPassword( "" );
try ( Connection connection = dataSource.getConnection() ) {
connection.prepareStatement( "create table test (key varchar(20), value varchar(20))" ).execute();
}
return dataSource;
}
示例7: bootstrapInMemoryDatabase
import org.hsqldb.jdbc.JDBCDataSource; //导入方法依赖的package包/类
/** Create in-memory database table so that mapper methods might operate on something */
private JDBCDataSource bootstrapInMemoryDatabase() throws SQLException {
JDBCDataSource dataSource = new JDBCDataSource();
dataSource.setUrl( "jdbc:hsqldb:mem:purejava-integration-test" );
dataSource.setUser( "sa" );
dataSource.setPassword( "" );
try ( Connection connection = dataSource.getConnection() ) {
connection.prepareStatement( "create table test (key varchar(20), value varchar(20))" ).execute();
}
return dataSource;
}