本文整理汇总了Java中org.hsqldb.jdbc.JDBCDataSource类的典型用法代码示例。如果您正苦于以下问题:Java JDBCDataSource类的具体用法?Java JDBCDataSource怎么用?Java JDBCDataSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JDBCDataSource类属于org.hsqldb.jdbc包,在下文中一共展示了JDBCDataSource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSqlFilterComplex
import org.hsqldb.jdbc.JDBCDataSource; //导入依赖的package包/类
@SuppressWarnings("deprecation")
// @Test
public void testSqlFilterComplex() throws Exception {
HashMap<String, Object> params = new HashMap<String, Object>();
params.put("date_from", new Date("03/08/2003"));
params.put("date_to", new Date("03/31/2010"));
params.put("num_from", new Double(4));
params.put("num_to", new Double(6));
params.put("f", new Integer(3));
params.put("t", new Integer(5));
JDBCDataSource ds = new JDBCDataSource();
ds.setDatabase(LocalTestConstants.TEST_DB_NAME);
ds.setUser(LocalTestConstants.TEST_DB_USER);
ds.setPassword(LocalTestConstants.TEST_DB_PASSWORD);
HashMap<String, String[]> sparams = new HashMap<String, String[]>();
sparams.put("conn", new String[] {"hsqldb"});
testSqlFile("sql_filter_complex", true,
SQL_FILTER_COMPLEX, params, ds, sparams);
}
示例2: 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();
}
示例3: Report
import org.hsqldb.jdbc.JDBCDataSource; //导入依赖的package包/类
public Report(Configuration c) {
reportSQL = c.reportSQL;
reportDirectory = c.reportDirectory;
log.info("Using database directory: " + c.databaseDirectory);
log.info("Using report directory: " + c.reportDirectory);
File currentDir = new File("");
String dbPath = currentDir.getAbsolutePath() + File.separator + c.databaseDirectory + "db";
connectionString = "jdbc:hsqldb:file:" + dbPath;
datasource = new JDBCDataSource();
((JDBCCommonDataSource)datasource).setUrl(connectionString);
try {
hsqldbDriver = (Driver) Class.forName("org.hsqldb.jdbcDriver").newInstance();
DriverManager.registerDriver(hsqldbDriver);
} catch (Exception e) {
log.error("Could not instantiate database driver: " + e.getMessage());
}
write("DROP SCHEMA PUBLIC CASCADE");
write("SET DATABASE DEFAULT RESULT MEMORY ROWS 1000");
write("CREATE CACHED TABLE downloads ( url VARCHAR(4095), http_code INTEGER default 0, content_type VARCHAR(255), response_time INTEGER default 0, downloaded_at DATETIME default NOW, downloaded BOOLEAN)");
write("CREATE CACHED TABLE links ( url_from VARCHAR(4095), url_to VARCHAR(4095))");
}
示例4: 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();
}
}
示例5: setUp
import org.hsqldb.jdbc.JDBCDataSource; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
final JDBCDataSource dataSource = HsqlUtil.setupDataSource();
HsqlUtil.createCustomerTable(dataSource);
final ConnectionManager connectionManager = new ConnectionManager(dataSource);
transactionManager = new TransactionManager(connectionManager);
jdbcService = new JdbcService(connectionManager);
}
示例6: setupDataSource
import org.hsqldb.jdbc.JDBCDataSource; //导入依赖的package包/类
public static JDBCDataSource setupDataSource() throws SQLException {
final JDBCDataSource jdbcDataSource = new JDBCDataSource();
jdbcDataSource.setDatabase("jdbc:hsqldb:mem:db");
Statement statement = jdbcDataSource.getConnection().createStatement();
statement.addBatch("DROP SCHEMA public CASCADE");
statement.executeBatch();
return jdbcDataSource;
}
示例7: setUp
import org.hsqldb.jdbc.JDBCDataSource; //导入依赖的package包/类
@Before
public void setUp() {
JDBCDataSource ds = new JDBCDataSource();
ds.setURL("jdbc:hsqldb:mem:test");
service = DatabaseService.builder(ds).setBackoffStrategy(attempt -> 0).build().start();
}
示例8: 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);
}
示例9: 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);
}
示例10: 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);
}
示例11: InMemoryDb
import org.hsqldb.jdbc.JDBCDataSource; //导入依赖的package包/类
public InMemoryDb() throws SQLException {
jdbcDataSource = new JDBCDataSource();
jdbcDataSource.setUrl("jdbc:hsqldb:mem:test;MODE=PostgreSQL");
jdbcDataSource.setUser("SA");
jdbcDataSource.setPassword("");
migrateDb(jdbcDataSource);
addTestData();
}
示例12: 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;
}
示例13: 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;
}
示例14: getDataSource
import org.hsqldb.jdbc.JDBCDataSource; //导入依赖的package包/类
private static DataSource getDataSource() {
final JDBCDataSource dataSource = new JDBCDataSource();
dataSource.setDatabase("jdbc:hsqldb:mem:persistence");
dataSource.setUser("sa");
dataSource.setPassword("");
return dataSource;
}
示例15: newDataSource
import org.hsqldb.jdbc.JDBCDataSource; //导入依赖的package包/类
protected ProxyDataSource newDataSource() {
JDBCDataSource actualDataSource = new JDBCDataSource();
actualDataSource.setUrl("jdbc:hsqldb:mem:test");
actualDataSource.setUser("sa");
actualDataSource.setPassword("");
ProxyDataSource proxyDataSource = new ProxyDataSource();
proxyDataSource.setDataSource(actualDataSource);
proxyDataSource.setListener(new SLF4JQueryLoggingListener());
return proxyDataSource;
}
开发者ID:vladmihalcea,项目名称:hibernate-master-class,代码行数:11,代码来源:ExternalDataSourceConnectionProviderTest.java