本文整理了Java中org.intermine.sql.Database
类的一些代码示例,展示了Database
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Database
类的具体详情如下:
包路径:org.intermine.sql.Database
类名称:Database
[英]Class that represents a physical SQL database
[中]类,该类表示物理SQL数据库
代码示例来源:origin: org.intermine/intermine-objectstore
/**
* Returns a Connection. Please put them back.
*
* Whenever you receive a connection from the object-store, you MUST
* release its resources by calling releaseConnection.
*
* Failure to do so KILLS THE OBJECT STORE!
*
* @return a java.sql.Connection
* @throws SQLException if there is a problem with that
*/
public Connection getConnection() throws SQLException {
Connection retval = db.getConnection();
if (!retval.getAutoCommit()) {
retval.setAutoCommit(true);
}
return retval;
}
代码示例来源:origin: intermine/intermine
public void testURL() throws Exception {
Database db = new Database(props);
assertEquals("jdbc:postgresql://dbserver.mydomain.org/test", db.getURL());
}
代码示例来源:origin: org.intermine/intermine-objectstore
dsProps = PropertiesUtil.stripStart("datasource", dsProps);
removeProperty(dsProps, "class");
removeProperty(dsProps, "encoding");
removeProperty(dsProps, "schema");
renameProperty(dsProps, "dataSourceName", "poolName");
renameProperty(dsProps, "maxConnections", "maximumPoolSize");
renameProperty(dsProps, "user", "dataSource.user");
renameProperty(dsProps, "password", "dataSource.password");
renameProperty(dsProps, "port", "dataSource.portNumber");
renameProperty(dsProps, "databaseName", "dataSource.databaseName");
renameProperty(dsProps, "serverName", "dataSource.serverName");
+ HIKARI_CLASSNAME
+ " in default.intermine.properties or minename.properties.");
configure(props);
LOG.info("Creating new Database " + getURL() + "(" + toString() + ") and parallelism "
+ parallel);
} catch (Exception e) {
代码示例来源:origin: org.intermine/intermine-objectstore
/**
* {@inheritDoc}
*/
@Override
public void finalize() throws Throwable {
super.finalize();
if (datasource instanceof com.zaxxer.hikari.HikariDataSource) {
LOG.info("Finalise - Closing datasource for Database " + getURL() + "(" + toString()
+ ") with ClassLoader " + getClass().getClassLoader());
((com.zaxxer.hikari.HikariDataSource) datasource).close();
} else if (datasource instanceof org.postgresql.ds.PGPoolingDataSource) {
LOG.info("Finalise - Closing datasource for Database " + getURL() + "(" + toString()
+ ") with ClassLoader " + getClass().getClassLoader());
((org.postgresql.ds.PGPoolingDataSource) datasource).close();
} else if (datasource instanceof org.postgresql.jdbc2.optional.PoolingDataSource) {
LOG.info("Finalise - Closing datasource for Database " + getURL() + "(" + toString()
+ ") with ClassLoader " + getClass().getClassLoader());
((org.postgresql.jdbc2.optional.PoolingDataSource) datasource).close();
} else {
LOG.warn("Finalise - Could not close datasource for Database " + getURL() + "("
+ toString() + ") with ClassLoader " + getClass().getClassLoader() + " - "
+ datasource.getClass().toString());
}
}
代码示例来源:origin: intermine/intermine
c = database.getConnection();
c.setAutoCommit(true);
DatabaseUtil.removeAllTables(c);
sql.setTargetDatabase(database.getPlatform().toLowerCase()); // "postgresql"
InputStream schemaFileInputStream = getClass().getClassLoader()
.getResourceAsStream(schemaFile);
isql.setDriver(database.getDriver()); // "org.postgresql.Driver"
isql.setUrl(database.getURL()); // "jdbc:postgresql://localhost/test"
isql.setUserid(database.getUser()); // "mark"
isql.setPassword(database.getPassword()); // ""
isql.setAutocommit(true);
TorqueSQLExec.OnError ea = new TorqueSQLExec.OnError();
c = database.getConnection();
c.setAutoCommit(true);
c.createStatement().execute("CREATE SEQUENCE " + SERIAL_SEQUENCE_NAME);
c = database.getConnection();
c.setAutoCommit(true);
c.createStatement().execute("CREATE SEQUENCE "
c = database.getConnection();
c.setAutoCommit(true);
c.createStatement().execute("ALTER TABLE " + CLOB_TABLE_NAME + " ALTER COLUMN "
c = null;
try {
代码示例来源:origin: org.intermine/bio-core
OrganismRepository or = OrganismRepository.getOrganismRepository();
try {
LOG.info("Querying FlyBase DB: " + db.getName());
for (String clsName : clsCol) {
conn = db.getConnection();
String query = "select c.cvterm_id"
+ " from cvterm c, cv"
代码示例来源:origin: intermine/intermine
public void testConfigure() throws Exception {
Database db = new Database();
db.configure(props);
assertTrue(db.getDataSource() != null);
assertTrue(db.getDataSource() instanceof PGPoolingDataSource);
assertEquals("PostgreSQL", db.getPlatform());
assertEquals("dbserver.mydomain.org", ((PGPoolingDataSource) db.getDataSource()).getServerName());
assertEquals("test", ((PGPoolingDataSource) db.getDataSource()).getDatabaseName());
assertEquals(10, ((PGPoolingDataSource) db.getDataSource()).getMaxConnections());
}
代码示例来源:origin: org.intermine/intermine-objectstore
/**
* Called by the ShutdownHook on shutdown.
*/
public synchronized void shutdown() {
LOG.info("Shutting down open ObjectStoreInterMineImpl with sequence = " + sequenceNumber
+ " and Database " + getDatabase().getURL());
try {
close();
} catch (ObjectStoreException e) {
LOG.warn("Exception caught while shutting down ObjectStoreInterMineImpl: "
+ e);
}
}
代码示例来源:origin: intermine/intermine
} catch (SQLException e) {
throw new ObjectStoreException("Could not obtain connection to database "
+ db.getURL() + "(user=" + db.getUser()
+ ")", e);
代码示例来源:origin: intermine/intermine
public void testPassword() throws Exception {
Database db = new Database(props);
assertEquals("secret", db.getPassword());
}
代码示例来源:origin: intermine/intermine
public void testUser() throws Exception {
Database db = new Database(props);
assertEquals("auser", db.getUser());
}
代码示例来源:origin: intermine/intermine
public void testInvalidMethod() throws Exception {
Properties invalidProps = new Properties();
invalidProps.put("datasource.class", "org.postgresql.ds.PGPoolingDataSource");
invalidProps.put("datasource.someRubbish", "blahblahblah");
Database db = new Database(invalidProps);
}
代码示例来源:origin: intermine/intermine
/**
* Run an IQL query in the objectstore and print the first results to the console.
* @param os the objectstore
* @param iql and IQL query string
*/
private static void runIqlQuery(ObjectStoreInterMineImpl os, String iql) {
System.out .println("Running query in database " + os.getDatabase().getName()
+ " - " + iql);
System.out .println("See intermine.log for query execution details.");
Query q = parseIqlQuery(os.getModel(), iql);
Results results = os.execute(q);
Iterator<?> resIter = results.iterator();
int count = 0;
while (resIter.hasNext() && count < MAX_ROWS) {
ResultsRow<?> rr = (ResultsRow<?>) resIter.next();
System.out .println(count + " - " + rr);
count += 1;
}
if (resIter.hasNext()) {
System.out .println("Only fetching first " + MAX_ROWS + " rows.");
}
}
代码示例来源:origin: intermine/intermine
public void testVersionIsAtLeast() throws Exception {
Database db = new Database(props);
db.version = "9.3";
assertTrue(db.isVersionAtLeast("9.2"));
assertTrue(db.isVersionAtLeast("9.1.7"));
assertTrue(db.isVersionAtLeast("8"));
assertTrue(db.isVersionAtLeast("9.3"));
assertTrue(db.isVersionAtLeast("9.3.0"));
assertFalse(db.isVersionAtLeast("10"));
assertFalse(db.isVersionAtLeast("9.4"));
assertFalse(db.isVersionAtLeast("9.3.1"));
db.version = "9.2.1";
assertTrue(db.isVersionAtLeast("9.2"));
assertTrue(db.isVersionAtLeast("9.2.0"));
assertTrue(db.isVersionAtLeast("9.2.1.0"));
assertFalse(db.isVersionAtLeast("9.2.1.1"));
assertFalse(db.isVersionAtLeast("9.2.2"));
db.version = "9.4beta3";
assertTrue(db.isVersionAtLeast("9.2"));
assertTrue(db.isVersionAtLeast("9.4.0"));
assertFalse(db.isVersionAtLeast("9.5"));
}
代码示例来源:origin: intermine/intermine
configure(subProps);
代码示例来源:origin: org.intermine/intermine-objectstore
.getName());
SchemaType torqueType = SchemaType.getEnum(torqueTypeName);
Platform torquePlatform = PlatformFactory.getPlatformFor(state.getDb().getPlatform()
.toLowerCase());
Domain torqueDomain = torquePlatform.getDomainForSchemaType(torqueType);
代码示例来源:origin: org.intermine/intermine-objectstore
c = database.getConnection();
c.setAutoCommit(true);
DatabaseUtil.removeAllTables(c);
sql.setTargetDatabase(database.getPlatform().toLowerCase()); // "postgresql"
InputStream schemaFileInputStream = getClass().getClassLoader()
.getResourceAsStream(schemaFile);
isql.setDriver(database.getDriver()); // "org.postgresql.Driver"
isql.setUrl(database.getURL()); // "jdbc:postgresql://localhost/test"
isql.setUserid(database.getUser()); // "mark"
isql.setPassword(database.getPassword()); // ""
isql.setAutocommit(true);
TorqueSQLExec.OnError ea = new TorqueSQLExec.OnError();
c = database.getConnection();
c.setAutoCommit(true);
c.createStatement().execute("CREATE SEQUENCE " + SERIAL_SEQUENCE_NAME);
c = database.getConnection();
c.setAutoCommit(true);
c.createStatement().execute("CREATE SEQUENCE "
c = database.getConnection();
c.setAutoCommit(true);
c.createStatement().execute("ALTER TABLE " + CLOB_TABLE_NAME + " ALTER COLUMN "
c = null;
try {
代码示例来源:origin: intermine/intermine
/**
* {@inheritDoc}
*/
@Override
public void finalize() throws Throwable {
super.finalize();
if (datasource instanceof com.zaxxer.hikari.HikariDataSource) {
LOG.info("Finalise - Closing datasource for Database " + getURL() + "(" + toString()
+ ") with ClassLoader " + getClass().getClassLoader());
((com.zaxxer.hikari.HikariDataSource) datasource).close();
} else if (datasource instanceof org.postgresql.ds.PGPoolingDataSource) {
LOG.info("Finalise - Closing datasource for Database " + getURL() + "(" + toString()
+ ") with ClassLoader " + getClass().getClassLoader());
((org.postgresql.ds.PGPoolingDataSource) datasource).close();
} else if (datasource instanceof org.postgresql.jdbc2.optional.PoolingDataSource) {
LOG.info("Finalise - Closing datasource for Database " + getURL() + "(" + toString()
+ ") with ClassLoader " + getClass().getClassLoader());
((org.postgresql.jdbc2.optional.PoolingDataSource) datasource).close();
} else {
LOG.warn("Finalise - Could not close datasource for Database " + getURL() + "("
+ toString() + ") with ClassLoader " + getClass().getClassLoader() + " - "
+ datasource.getClass().toString());
}
}
代码示例来源:origin: org.intermine/intermine-objectstore
/**
* Finalise this object.
*/
protected synchronized void doFinalise() {
LOG.error("Garbage collecting ObjectStoreInterMineImpl with sequence = " + sequenceNumber
+ " and Database " + getDatabase().getURL());
try {
close();
} catch (ObjectStoreException e) {
LOG.error("Exception while garbage-collecting ObjectStoreInterMineImpl: "
+ e);
}
}
代码示例来源:origin: org.intermine/intermine-objectstore
} catch (SQLException e) {
throw new ObjectStoreException("Could not obtain connection to database "
+ db.getURL() + "(user=" + db.getUser()
+ ")", e);
内容来源于网络,如有侵权,请联系作者删除!