本文整理汇总了Java中org.hsqldb.Server类的典型用法代码示例。如果您正苦于以下问题:Java Server类的具体用法?Java Server怎么用?Java Server使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Server类属于org.hsqldb包,在下文中一共展示了Server类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: contextInitialized
import org.hsqldb.Server; //导入依赖的package包/类
/**
* 处理context初始化事件.
*
* @param sce
* ServletContextEvent
*/
public void contextInitialized(ServletContextEvent sce) {
if (!enabled) {
logger.info("skip hsqldb server");
return;
}
try {
String databasePath = path + "/" + databaseName;
url = "jdbc:hsqldb:hsql://localhost:" + port + "/" + databaseName;
Server server = new Server();
server.setDatabaseName(0, databaseName);
server.setDatabasePath(0, databasePath);
server.setPort(port);
server.setSilent(true);
server.start();
Thread.sleep(WAIT_TIME);
} catch (InterruptedException ex) {
logger.error(ex.getMessage(), ex);
}
}
示例2: init
import org.hsqldb.Server; //导入依赖的package包/类
@PostConstruct
public void init() {
if (!enabled) {
logger.info("skip hsqldb server");
return;
}
try {
String databasePath = path + "/" + databaseName;
url = "jdbc:hsqldb:hsql://localhost:" + port + "/" + databaseName;
Server server = new Server();
server.setDatabaseName(0, databaseName);
server.setDatabasePath(0, databasePath);
server.setPort(port);
server.setSilent(true);
server.start();
Thread.sleep(WAIT_TIME);
} catch (InterruptedException ex) {
logger.error(ex.getMessage(), ex);
}
}
示例3: setUp
import org.hsqldb.Server; //导入依赖的package包/类
protected void setUp() {
if (isNetwork) {
serverProps = "database.0=mem:test";
url = "jdbc:hsqldb:hsql://localhost";
server = new Server();
server.putPropertiesFromString(serverProps);
server.setLogWriter(null);
server.setErrWriter(null);
server.start();
} else {
url = "jdbc:hsqldb:file:test";
}
try {
Class.forName("org.hsqldb.jdbcDriver");
} catch (Exception e) {
e.printStackTrace();
System.out.println(this + ".setUp() error: " + e.getMessage());
}
}
示例4: setUp
import org.hsqldb.Server; //导入依赖的package包/类
protected void setUp() {
server = new Server();
server.putPropertiesFromString(serverProps);
server.setLogWriter(null);
server.setErrWriter(null);
server.start();
try {
Class.forName("org.hsqldb.jdbcDriver");
} catch (Exception e) {
e.printStackTrace();
System.out.println(this + ".setUp() error: " + e.getMessage());
}
}
示例5: setUp
import org.hsqldb.Server; //导入依赖的package包/类
protected void setUp() {
if (isNetwork) {
if (url == null) {
url = "jdbc:hsqldb:hsql://localhost/test";
}
server = new Server();
server.setDatabaseName(0, "test");
server.setDatabasePath(0, "mem:test;sql.enforce_strict_size=true");
server.setLogWriter(null);
server.setErrWriter(null);
server.start();
} else {
if (url == null) {
url = "jdbc:hsqldb:file:test;sql.enforce_strict_size=true";
}
}
}
示例6: databaseServer
import org.hsqldb.Server; //导入依赖的package包/类
@Bean(destroyMethod = "stop")
public Server databaseServer() throws SQLException, IOException {
DriverManager.registerDriver(new org.hsqldb.jdbcDriver());
int hsqldbPort = SocketUtils.findAvailableTcpPort(10000);
System.setProperty("db.server.port", Integer.toString(hsqldbPort));
logger.info("Database is using port: " + Integer.toString(hsqldbPort));
HsqlProperties configProps = new HsqlProperties();
configProps.setProperty("server.port", hsqldbPort);
configProps.setProperty("server.database.0", "file:target/db/test");
configProps.setProperty("server.dbname.0", "test");
Server server = new org.hsqldb.Server();
server.setLogWriter(null);
server.setErrWriter(null);
server.setRestartOnShutdown(false);
server.setNoSystemExit(true);
server.setProperties(configProps);
server.start();
return server;
}
示例7: getServer
import org.hsqldb.Server; //导入依赖的package包/类
public static Server getServer()
{
if (server == null)
{
server = new org.hsqldb.Server();
server.setNoSystemExit(true);
server.setRestartOnShutdown(false);
server.setTls(false);
// Locate the database scripts...
File libDir = InstalledFileLocator.getDefault().locate("database", null, false);
server.setDatabasePath(0, libDir.getPath() + File.separator + "test");
server.setDatabaseName(0, "");
server.setTls(false);
}
return server;
}
示例8: Db
import org.hsqldb.Server; //导入依赖的package包/类
/**
* Constructor to specify the directory of the database.
*
* @param dbDir
* the directory of the database
*/
public Db(final File dbDir) {
tmpFolder = dbDir;
hSqlDb = new Server();
dbs = new HashMap<String, File>();
// disable any logging
hSqlDb.setLogWriter(null);
hSqlDb.setErrWriter(null);
hSqlDb.setTrace(false);
hSqlDb.setSilent(true);
// define the address
hSqlDb.setAddress("localhost");
hSqlDb.setPort(6666);
}
示例9: apply
import org.hsqldb.Server; //导入依赖的package包/类
@Override
public Statement apply(final Statement base, final Description description) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
final int port = NetworkUtil.getNextAvailablePort();
final Server server = new Server();
server.setAddress("localhost");
server.setPort(port);
server.setDatabaseName(0, "adb");
server.setDatabasePath(0, Files.mkdirs(new File("target/HerokuDatabasePropertiesProviderResourceTest")).getAbsolutePath());
server.start();
System.setProperty("hsqldb", Integer.toString(port));
try {
base.evaluate();
} finally {
server.stop();
}
}
};
}
示例10: HSQLDBServer
import org.hsqldb.Server; //导入依赖的package包/类
public HSQLDBServer() {
try
{
hsqlServer = new Server();
hsqlServer.setLogWriter(null);
hsqlServer.setSilent(true);
hsqlServer.setDatabaseName(0, DB_NAME);
hsqlServer.setDatabasePath(0, DB_PATH);
hsqlServer.start();
}
catch(Exception e)
{
logger.error("Failed to startup HSQLDB!", e);
}
}
示例11: afterPropertiesSet
import org.hsqldb.Server; //导入依赖的package包/类
public void afterPropertiesSet() throws Exception {
HsqlProperties configProps = new HsqlProperties(serverProperties);
/*if (configProps == null) {
logger.warn("we failed at getting an HSQL Server with serverProperties, trying to get one without");
configProps = new HsqlProperties();
if (configProps == null)
logger.error("we failed at getting an HSQL Server, period. Crash and burn from here on.");
}*/
ServerConfiguration.translateDefaultDatabaseProperty(configProps);
// finished setting up properties - set some important behaviors as
// well;
server = new org.hsqldb.Server();
server.setRestartOnShutdown(false);
server.setNoSystemExit(true);
server.setProperties(configProps);
logger.info("HSQL Server Startup sequence initiated");
server.start();
String portMsg = "port " + server.getPort();
logger.info("HSQL Server listening on " + portMsg);
}
示例12: setUp
import org.hsqldb.Server; //导入依赖的package包/类
protected void setUp() {
user = "sa";
password = "";
stmt = null;
conn1 = null;
conn2 = null;
server = new Server();
// server = new WebServer();
server.putPropertiesFromString(serverProps);
server.setLogWriter(null);
server.start();
try {
jdbcDataSource dataSource = new jdbcDataSource();
dataSource.setDatabase(url);
conn1 = dataSource.getConnection(user, password);
conn2 = dataSource.getConnection(user, password);
stmt = conn1.createStatement();
} catch (Exception e) {
//e.printStackTrace();
System.out.println(this + ".setUp() error: " + e.getMessage());
}
}
示例13: setUp
import org.hsqldb.Server; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
reactor = new NioReactor();
crusher = TcpCrusherBuilder.builder()
.withReactor(reactor)
.withBindAddress("127.0.0.1", CRUSHER_PORT)
.withConnectAddress("127.0.0.1", DB_PORT)
.buildAndOpen();
hsqlServer = new Server();
hsqlServer.setAddress("127.0.0.1");
hsqlServer.setPort(DB_PORT);
hsqlServer.setDaemon(true);
hsqlServer.setErrWriter(new PrintWriter(System.err));
hsqlServer.setLogWriter(new PrintWriter(System.out));
hsqlServer.setNoSystemExit(true);
hsqlServer.setDatabasePath(0, "mem:testdb");
hsqlServer.setDatabaseName(0, "testdb");
hsqlServer.start();
Class.forName("org.hsqldb.jdbc.JDBCDriver");
BoneCPConfig config = new BoneCPConfig();
config.setJdbcUrl(String.format("jdbc:hsqldb:hsql://127.0.0.1:%d/testdb", CRUSHER_PORT));
config.setUsername("sa");
config.setPassword("");
config.setInitSQL(SQL_CHECK);
config.setConnectionTestStatement(SQL_CHECK);
config.setAcquireIncrement(1);
config.setAcquireRetryAttempts(1);
config.setAcquireRetryDelayInMs(1000);
config.setConnectionTimeoutInMs(1000);
config.setQueryExecuteTimeLimitInMs(1000);
config.setDefaultAutoCommit(false);
config.setDefaultReadOnly(true);
config.setDefaultTransactionIsolation("NONE");
config.setPartitionCount(1);
config.setMinConnectionsPerPartition(1);
config.setMaxConnectionsPerPartition(1);
config.setLazyInit(true);
config.setDetectUnclosedStatements(true);
connectionPool = new BoneCP(config);
}
示例14: startHsqldbServer
import org.hsqldb.Server; //导入依赖的package包/类
private void startHsqldbServer() {
log.info("Starting HSQLDB server");
server = new Server();
server.setDatabasePath(0,
System.getProperty("test.build.data", "/tmp") + "/goratest");
server.setDatabaseName(0, "goratest");
server.setDaemon(true);
server.setPort(Integer.parseInt(HSQLDB_PORT));
server.start();
}
示例15: startHsqldbServer
import org.hsqldb.Server; //导入依赖的package包/类
private void startHsqldbServer() {
server = new Server();
server.setDatabasePath(0,
System.getProperty("test.build.data",".") + "/URLAccess");
server.setDatabaseName(0, "URLAccess");
server.start();
}