本文整理汇总了Java中org.hsqldb.DatabaseManager类的典型用法代码示例。如果您正苦于以下问题:Java DatabaseManager类的具体用法?Java DatabaseManager怎么用?Java DatabaseManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DatabaseManager类属于org.hsqldb包,在下文中一共展示了DatabaseManager类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: cancelStatement
import org.hsqldb.DatabaseManager; //导入依赖的package包/类
private Result cancelStatement(Result resultIn) {
try {
dbID = resultIn.getDatabaseId();
long sessionId = resultIn.getSessionId();
session = DatabaseManager.getSession(dbID, sessionId);
if (!server.isSilent()) {
server.printWithThread(mThread
+ ":Trying to cancel statement "
+ " to DB (" + dbID + ')');
}
return session.cancel(resultIn);
} catch (HsqlException e) {
session = null;
return Result.updateZeroResult;
} catch (Throwable t) {
session = null;
return Result.updateZeroResult;
}
}
示例2: start
import org.hsqldb.DatabaseManager; //导入依赖的package包/类
public void start() {
if (writeDelay > 0) {
timerTask = DatabaseManager.getTimer().schedulePeriodicallyAfter(0,
writeDelay, this, false);
}
}
示例3: start
import org.hsqldb.DatabaseManager; //导入依赖的package包/类
public void start() {
int period = writeDelay == 0 ? 1000
: writeDelay;
timerTask = DatabaseManager.getTimer().schedulePeriodicallyAfter(0,
period, this, false);
}
示例4: stop
import org.hsqldb.DatabaseManager; //导入依赖的package包/类
@Override
public void stop() throws ServiceException {
if (server == null)
return;
try {
server.stop();
} finally {
server = null;
DatabaseManager.closeDatabases(Database.CLOSEMODE_COMPACT);
}
}
示例5: openDatabases
import org.hsqldb.DatabaseManager; //导入依赖的package包/类
/**
* Opens this server's database instances. This method returns true If
* at least one database goes online, otherwise it returns false.
*
* If opening any of the databases is attempted and an exception is
* thrown, the server error is set to this exception.
*/
final boolean openDatabases() {
printWithThread("openDatabases() entered");
boolean success = false;
setDBInfoArrays();
for (int i = 0; i < dbAlias.length; i++) {
if (dbAlias[i] == null) {
continue;
}
printWithThread("Opening database: [" + dbType[i] + dbPath[i]
+ "]");
StopWatch sw = new StopWatch();
int id;
try {
id = DatabaseManager.getDatabase(dbType[i], dbPath[i], this,
dbProps[i]);
dbID[i] = id;
success = true;
} catch (HsqlException e) {
printError("Database [index=" + i + ", db=" + dbType[i]
+ dbPath[i] + ", alias=" + dbAlias[i]
+ "] did not open: " + e.toString());
setServerError(e);
dbAlias[i] = null;
dbPath[i] = null;
dbType[i] = null;
dbProps[i] = null;
continue;
}
sw.stop();
String msg = "Database [index=" + i + ", id=" + id + ", db="
+ dbType[i] + dbPath[i] + ", alias=" + dbAlias[i]
+ "] opened successfully";
print(sw.elapsedTimeToMessage(msg));
}
printWithThread("openDatabases() exiting");
if (isRemoteOpen) {
success = true;
}
if (!success && getServerError() == null) {
// database alias / path list is empty or without full info for any DB
setServerError(Error.error(ErrorCode.SERVER_NO_DATABASE));
}
return success;
}
示例6: JDBCConnection
import org.hsqldb.DatabaseManager; //导入依赖的package包/类
/**
* Constructs a new external <code>Connection</code> to an HSQLDB
* <code>Database</code>. <p>
*
* This constructor is called on behalf of the
* <code>java.sql.DriverManager</code> when getting a
* <code>Connection</code> for use in normal (external)
* client code. <p>
*
* Internal client code, that being code located in HSQLDB SQL
* functions and stored procedures, receives an INTERNAL
* connection constructed by the {@link
* #JDBCConnection(org.hsqldb.SessionInterface)
* JDBCConnection(SessionInterface)} constructor. <p>
*
* @param props A <code>Properties</code> object containing the connection
* properties
* @exception SQLException when the user/password combination is
* invalid, the connection url is invalid, or the
* <code>Database</code> is unavailable. <p>
*
* The <code>Database</code> may be unavailable for a number
* of reasons, including network problems or the fact that it
* may already be in use by another process.
*/
public JDBCConnection(HsqlProperties props) throws SQLException {
String user = props.getProperty("user");
String password = props.getProperty("password");
String connType = props.getProperty("connection_type");
String host = props.getProperty("host");
int port = props.getIntegerProperty("port", 0);
String path = props.getProperty("path");
String database = props.getProperty("database");
boolean isTLS = (connType == DatabaseURL.S_HSQLS
|| connType == DatabaseURL.S_HTTPS);
if (user == null) {
user = "SA";
}
if (password == null) {
password = "";
}
Calendar cal = Calendar.getInstance();
int zoneSeconds = HsqlDateTime.getZoneSeconds(cal);
try {
if (DatabaseURL.isInProcessDatabaseType(connType)) {
/**
* @todo fredt - this should be the only static reference to a core class in
* the jdbc package - we may make it dynamic
*/
sessionProxy = DatabaseManager.newSession(connType, database,
user, password, props, zoneSeconds);
} else { // alias: type not yet implemented
throw Util.invalidArgument(connType);
}
connProperties = props;
} catch (HsqlException e) {
throw Util.sqlException(e);
}
}
示例7: openDatabases
import org.hsqldb.DatabaseManager; //导入依赖的package包/类
/**
* Opens this server's database instances. This method returns true If
* at least one database goes online, otherwise it returns false.
*
* If openning any of the databases is attempted and an exception is
* thrown, the server error is set to this exception.
*/
final boolean openDatabases() {
printWithThread("openDatabases() entered");
boolean success = false;
setDBInfoArrays();
for (int i = 0; i < dbAlias.length; i++) {
if (dbAlias[i] == null) {
continue;
}
printWithThread("Opening database: [" + dbType[i] + dbPath[i]
+ "]");
StopWatch sw = new StopWatch();
int id;
try {
id = DatabaseManager.getDatabase(dbType[i], dbPath[i], this,
dbProps[i]);
dbID[i] = id;
success = true;
} catch (HsqlException e) {
printError("Database [index=" + i + ", db=" + dbType[i]
+ dbPath[i] + ", alias=" + dbAlias[i]
+ "] did not open: " + e.toString());
setServerError(e);
dbAlias[i] = null;
dbPath[i] = null;
dbType[i] = null;
dbProps[i] = null;
continue;
}
sw.stop();
String msg = "Database [index=" + i + ", id=" + id + ", db="
+ dbType[i] + dbPath[i] + ", alias=" + dbAlias[i]
+ "] opened sucessfully";
print(sw.elapsedTimeToMessage(msg));
}
printWithThread("openDatabases() exiting");
if (isRemoteOpen) {
success = true;
}
if (!success && getServerError() == null) {
// database alias / path list is empty or without full info for any DB
setServerError(Error.error(ErrorCode.SERVER_NO_DATABASE));
}
return success;
}
示例8: jdbcConnection
import org.hsqldb.DatabaseManager; //导入依赖的package包/类
/**
* Constructs a new external <code>Connection</code> to an HSQLDB
* <code>Database</code>. <p>
*
* This constructor is called on behalf of the
* <code>java.sql.DriverManager</code> when getting a
* <code>Connection</code> for use in normal (external)
* client code. <p>
*
* Internal client code, that being code located in HSQLDB SQL
* functions and stored procedures, receives an INTERNAL
* connection constructed by the {@link #jdbcConnection(Session)
* jdbcConnection(Session)} constructor. <p>
*
* @param props A <code>Properties</code> object containing the connection
* properties
* @exception SQLException when the user/password combination is
* invalid, the connection url is invalid, or the
* <code>Database</code> is unavailable. <p>
*
* The <code>Database</code> may be unavailable for a number
* of reasons, including network problems or the fact that it
* may already be in use by another process.
*/
public jdbcConnection(HsqlProperties props) throws SQLException {
String user = props.getProperty("user");
String password = props.getProperty("password");
boolean ifExists = props.isPropertyTrue("ifexists");
String connType = props.getProperty("connection_type");
String host = props.getProperty("host");
int port = props.getIntegerProperty("port", 0);
String path = props.getProperty("path");
String database = props.getProperty("database");
boolean isTLS = (connType == DatabaseManager.S_HSQLS
|| connType == DatabaseManager.S_HTTPS);
if (user == null) {
user = "SA";
}
if (password == null) {
password = "";
}
user = user.toUpperCase();
password = password.toUpperCase();
try {
if (connType == DatabaseManager.S_FILE
|| connType == DatabaseManager.S_MEM
|| connType == DatabaseManager.S_RES) {
// [email protected] 1.7.2 patch properties on the JDBC URL
/** @todo fredt - this should be the only static reference to a core class in
* the jdbc package - we may make it dynamic */
sessionProxy = DatabaseManager.newSession(connType, database,
user, password, ifExists, props);
} else if (connType == DatabaseManager.S_HSQL
|| connType == DatabaseManager.S_HSQLS) {
sessionProxy = new HSQLClientConnection(host, port, path,
database, isTLS, user, password);
isNetConn = true;
} else if (connType == DatabaseManager.S_HTTP
|| connType == DatabaseManager.S_HTTPS) {
sessionProxy = new HTTPClientConnection(host, port, path,
database, isTLS, user, password);
isNetConn = true;
} else { // alias: type not yet implemented
throw jdbcUtil.sqlException(Trace.INVALID_JDBC_ARGUMENT);
}
connProperties = props;
} catch (HsqlException e) {
throw jdbcUtil.sqlException(e);
}
}
示例9: jdbcConnection
import org.hsqldb.DatabaseManager; //导入依赖的package包/类
/**
* Constructs a new external <code>Connection</code> to an HSQLDB
* <code>Database</code>. <p>
*
* This constructor is called on behalf of the
* <code>java.sql.DriverManager</code> when getting a
* <code>Connection</code> for use in normal (external)
* client code. <p>
*
* Internal client code, that being code located in HSQLDB SQL
* functions and stored procedures, receives an INTERNAL
* connection constructed by the {@link #jdbcConnection(Session)
* jdbcConnection(Session)} constructor. <p>
*
* @param props A <code>Properties</code> object containing the connection
* properties
* @exception SQLException when the user/password combination is
* invalid, the connection url is invalid, or the
* <code>Database</code> is unavailable. <p>
*
* The <code>Database</code> may be unavailable for a number
* of reasons, including network problems or the fact that it
* may already be in use by another process.
*/
public jdbcConnection(HsqlProperties props) throws SQLException {
String user = props.getProperty("user");
String password = props.getProperty("password");
String connType = props.getProperty("connection_type");
String host = props.getProperty("host");
int port = props.getIntegerProperty("port", 0);
String path = props.getProperty("path");
String database = props.getProperty("database");
boolean isTLS = (connType == DatabaseURL.S_HSQLS
|| connType == DatabaseURL.S_HTTPS);
if (user == null) {
user = "SA";
}
if (password == null) {
password = "";
}
user = user.toUpperCase(Locale.ENGLISH);
password = password.toUpperCase(Locale.ENGLISH);
try {
if (DatabaseURL.isInProcessDatabaseType(connType)) {
/** @todo fredt - this should be the only static reference to a core class in
* the jdbc package - we may make it dynamic */
sessionProxy = DatabaseManager.newSession(connType, database,
user, password, props);
} else if (connType == DatabaseURL.S_HSQL
|| connType == DatabaseURL.S_HSQLS) {
sessionProxy = new HSQLClientConnection(host, port, path,
database, isTLS, user, password);
isNetConn = true;
} else if (connType == DatabaseURL.S_HTTP
|| connType == DatabaseURL.S_HTTPS) {
sessionProxy = new HTTPClientConnection(host, port, path,
database, isTLS, user, password);
isNetConn = true;
} else { // alias: type not yet implemented
throw Util.sqlException(Trace.INVALID_JDBC_ARGUMENT);
}
connProperties = props;
} catch (HsqlException e) {
throw Util.sqlException(e);
}
}
示例10: close
import org.hsqldb.DatabaseManager; //导入依赖的package包/类
/**
* Closes the HSQL database, initiating a shutdown.
*/
@Override
public void close() {
DatabaseManager.closeDatabases(Database.CLOSEMODE_NORMAL);
}
示例11: shutdownWithCatalogs
import org.hsqldb.DatabaseManager; //导入依赖的package包/类
/**
* Shuts down this server and all the database served by this server. As a
* consequence, any other server that is serving a subset of the databases
* will be shutdown, unless the server was started with server.remote_open
* property.
*
* The shutdownMode must be one of:
*
* <ul>
* <li>org.hsqldb.Database.CLOSEMODE_IMMEDIATELY
* <li>org.hsqldb.Database.CLOSEMODE_NORMAL
* <li>org.hsqldb.Database.CLOSEMODE_COMPACT
* <li>org.hsqldb.Database.CLOSEMODE_SCRIPT
* </ul>
* @param shutdownMode a value between 0-4, usually 0 or 1.
*/
public void shutdownWithCatalogs(int shutdownMode) {
// If an unchecked exception is thrown, isShuttingDown will be left true,
// which is good from a security standpoint.
isShuttingDown = true;
// make handleConnection() reject new connection attempts
DatabaseManager.shutdownDatabases(this, shutdownMode);
shutdown(false);
isShuttingDown = false;
}
示例12: shutdownCatalogs
import org.hsqldb.DatabaseManager; //导入依赖的package包/类
/**
* Shuts down all the database served by this server. As a consequence,
* this server and any other server that is serving a subset of the
* databases will be shutdown, unless the server was started with
* server.remote_open property.
*
* The shutdownMode must be one of:
*
* <ul>
* <li>org.hsqldb.Database.CLOSEMODE_IMMEDIATELY
* <li>org.hsqldb.Database.CLOSEMODE_NORMAL
* <li>org.hsqldb.Database.CLOSEMODE_COMPACT
* <li>org.hsqldb.Database.CLOSEMODE_SCRIPT
* </ul>
* @param shutdownMode a value between 0-4, usually 0 or 1.
*/
public void shutdownCatalogs(int shutdownMode) {
DatabaseManager.shutdownDatabases(this, shutdownMode);
}