本文整理汇总了Java中org.apache.derby.jdbc.EmbeddedDataSource.getConnection方法的典型用法代码示例。如果您正苦于以下问题:Java EmbeddedDataSource.getConnection方法的具体用法?Java EmbeddedDataSource.getConnection怎么用?Java EmbeddedDataSource.getConnection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.derby.jdbc.EmbeddedDataSource
的用法示例。
在下文中一共展示了EmbeddedDataSource.getConnection方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import org.apache.derby.jdbc.EmbeddedDataSource; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
dataSource = new EmbeddedDataSource();
dataSource.setDatabaseName(dbName);
dataSource.setCreateDatabase("create");
conn = dataSource.getConnection();
TestDb.dropTables(conn);
TestDb.buildCoffeeTable(conn);
}
示例2: stopDerby
import org.apache.derby.jdbc.EmbeddedDataSource; //导入方法依赖的package包/类
private void stopDerby() {
LOG.info("STOPPING [email protected]!!!!");
final EmbeddedDataSource ds = dataSource;
try {
ds.setShutdownDatabase("shutdown");
ds.getConnection();
} catch (Exception ignored) {
}
}
示例3: messageSent
import org.apache.derby.jdbc.EmbeddedDataSource; //导入方法依赖的package包/类
@Override
protected void messageSent() throws Exception {
if (++inflightMessageCount == failureCount) {
LOG.info("STOPPING [email protected]!!!!");
final EmbeddedDataSource ds = sharedDs;
ds.setShutdownDatabase("shutdown");
try {
ds.getConnection();
} catch (Exception ignored) {
}
LOG.info("DB [email protected]!!!!");
Thread dbRestartThread = new Thread("db-re-start-thread") {
@Override
public void run() {
LOG.info("Sleeping for 10 seconds before allowing db restart");
try {
restartDBLatch.await(10, TimeUnit.SECONDS);
} catch (InterruptedException e) {
e.printStackTrace();
}
ds.setShutdownDatabase("false");
LOG.info("DB [email protected]!!!!");
}
};
dbRestartThread.start();
}
}
示例4: createConnection
import org.apache.derby.jdbc.EmbeddedDataSource; //导入方法依赖的package包/类
public static Connection createConnection() throws SQLException {
MjdbcUtils.loadDriver("org.apache.derby.jdbc.EmbeddedDataSource");
EmbeddedDataSource ds = new org.apache.derby.jdbc.EmbeddedDataSource();
ds.setCreateDatabase("create");
ds.setDatabaseName("memory:testDb");
Connection conn = ds.getConnection();
return conn;
}