当前位置: 首页>>代码示例>>Java>>正文


Java DatabaseManager类代码示例

本文整理汇总了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;
        }
    }
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:27,代码来源:ServerConnection.java

示例2: start

import org.hsqldb.DatabaseManager; //导入依赖的package包/类
public void start() {

        if (writeDelay > 0) {
            timerTask = DatabaseManager.getTimer().schedulePeriodicallyAfter(0,
                    writeDelay, this, false);
        }
    }
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:8,代码来源:ScriptWriterBase.java

示例3: start

import org.hsqldb.DatabaseManager; //导入依赖的package包/类
public void start() {

        int period = writeDelay == 0 ? 1000
                                     : writeDelay;

        timerTask = DatabaseManager.getTimer().schedulePeriodicallyAfter(0,
                period, this, false);
    }
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:9,代码来源:ScriptWriterBase.java

示例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);
    }
}
 
开发者ID:apache,项目名称:tomee,代码行数:12,代码来源:HsqlService.java

示例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;
}
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:69,代码来源:Server.java

示例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);
    }
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:66,代码来源:JDBCConnection.java

示例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;
}
 
开发者ID:Julien35,项目名称:dev-courses,代码行数:69,代码来源:Server.java

示例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);
        }
    }
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:79,代码来源:jdbcConnection.java

示例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);
        }
    }
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:74,代码来源:jdbcConnection.java

示例10: close

import org.hsqldb.DatabaseManager; //导入依赖的package包/类
/**
 * Closes the HSQL database, initiating a shutdown.
 */
@Override
public void close() {
  DatabaseManager.closeDatabases(Database.CLOSEMODE_NORMAL);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:8,代码来源:HSQLDbDialect.java

示例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;
}
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:29,代码来源:Server.java

示例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);
}
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:20,代码来源:Server.java


注:本文中的org.hsqldb.DatabaseManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。