本文整理汇总了Java中org.h2.tools.Server类的典型用法代码示例。如果您正苦于以下问题:Java Server类的具体用法?Java Server怎么用?Java Server使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Server类属于org.h2.tools包,在下文中一共展示了Server类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import org.h2.tools.Server; //导入依赖的package包/类
public static void init() throws SQLException {
Bus.register(new OrderCamunda());
// Configure Camunda engine (in this case using in memory H2)
StandaloneInMemProcessEngineConfiguration conf = new StandaloneInMemProcessEngineConfiguration();
conf.setJobExecutorActivate(true);
conf.setHistoryLevel(HistoryLevel.HISTORY_LEVEL_FULL);
conf.setJdbcUsername("sa");
conf.setJdbcPassword("sa");
camunda = conf.buildProcessEngine();
// and start H2 database server to allow inspection from the outside
Server.createTcpServer(new String[] { "-tcpPort", "8092", "-tcpAllowOthers" }).start();
// Define flow
BpmnModelInstance flow = extendedFlowOfActivities();
// Deploy finished flow to Camunda
camunda.getRepositoryService().createDeployment() //
.addModelInstance("order.bpmn", flow) //
.deploy();
// Only for demo: write flow to file, so we can open it in modeler
Bpmn.writeModelToFile(new File("order.bpmn"), flow);
}
示例2: startServer
import org.h2.tools.Server; //导入依赖的package包/类
private void startServer() throws RepositoryServiceFactoryException {
SqlRepositoryConfiguration config = getSqlConfiguration();
checkPort(config.getPort());
try {
String[] serverArguments = createArguments(config);
if (LOGGER.isTraceEnabled()) {
String stringArgs = StringUtils.join(serverArguments, " ");
LOGGER.trace("Starting H2 server with arguments: {}", stringArgs);
}
server = Server.createTcpServer(serverArguments);
server.start();
} catch (Exception ex) {
throw new RepositoryServiceFactoryException(ex.getMessage(), ex);
}
}
示例3: setup
import org.h2.tools.Server; //导入依赖的package包/类
@Before
public void setup() {
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName(DATASOURCE_DRIVER_CLASS_NAME);
dataSource.setUrl(DATASOURCE_URL);
dataSource.setUsername(DATASOURCE_USER_NAME);
dataSource.setPassword(DATASOURCE_USER_PASSWORD);
this.dataSource = dataSource;
try {
this.server = Server.createTcpServer("-tcp", "-tcpAllowOthers", "-tcpPort", String.valueOf(randomPort))
.start();
}
catch (SQLException e) {
throw new IllegalStateException(e);
}
}
示例4: setup
import org.h2.tools.Server; //导入依赖的package包/类
/** Prepares Db and data source, which must be added to Camel registry. */
@BeforeClass
public static void setup() throws Exception {
DeleteDbFiles.execute("~", "jbpm-db-test", true);
h2Server = Server.createTcpServer(new String[0]);
h2Server.start();
setupDb();
DataSource ds = setupDataSource();
SimpleRegistry simpleRegistry = new SimpleRegistry();
simpleRegistry.put("myDs", ds);
handler = new CamelHandler(new SQLURIMapper(), new RequestPayloadMapper("payload"), new ResponsePayloadMapper("queryResult"), new DefaultCamelContext(simpleRegistry));
}
示例5: startDbServer
import org.h2.tools.Server; //导入依赖的package包/类
/**
* Starts the H2 database engine if the database mode is set to 'server'
*/
private void startDbServer() {
final String mode = Config.getInstance().getProperty(Config.AlpineKey.DATABASE_MODE);
final int port = Config.getInstance().getPropertyAsInt(Config.AlpineKey.DATABASE_PORT);
if (StringUtils.isEmpty(mode) || !("server".equals(mode) || "embedded".equals(mode))) {
LOGGER.error("Database mode not specified. Expected values are 'server' or 'embedded'");
}
if (dbServer != null || "embedded".equals(mode)) {
return;
}
final String[] args = new String[] {
"-tcp",
"-tcpPort", String.valueOf(port),
"-tcpAllowOthers",
};
try {
LOGGER.info("Attempting to start database service");
dbServer = Server.createTcpServer(args).start();
LOGGER.info("Database service started");
} catch (SQLException e) {
LOGGER.error("Unable to start database service: " + e.getMessage());
stopDbServer();
}
}
示例6: main
import org.h2.tools.Server; //导入依赖的package包/类
public static void main(String... args) throws Exception {
SpringApplication.run(Application.class, args);
// do default setup of platform (everything is only applied if not yet there)
ProcessEngine engine = BpmPlatform.getDefaultProcessEngine();
// start a Saga right away
engine.getRuntimeService().startProcessInstanceByKey(
"trip",
Variables.putValue("someVariableToPass", "someValue"));
// and add default users to Camunda to be ready-to-go
UserGenerator.createDefaultUsers(engine);
LicenseHelper.setLicense(engine);
// Start H2 server to be able to connect to database from the outside
Server.createTcpServer(new String[] { "-tcpPort", "8092", "-tcpAllowOthers" }).start();
}
示例7: main
import org.h2.tools.Server; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
Server.createWebServer("-web", "-webAllowOthers", "-webPort", "8082").start();
Thread.sleep(1000);
final ConnectionPool pool = new QueueConnectionPool("jdbc:h2:~/test", "sa", "", "org.h2.Driver", 1);
Runnable r = () -> {
while (true) {
try {
doConnect(pool);
Thread.sleep(rnd.nextInt(1000));
} catch (Exception e) {
e.printStackTrace();
}
}
};
for (int i = 0; i < 10; i++) {
new Thread(r).start();
}
}
示例8: startServer
import org.h2.tools.Server; //导入依赖的package包/类
private void startServer(String key) {
try {
server = Server.createTcpServer(
"-tcpPort", Integer.toString(autoServerPort),
"-tcpAllowOthers",
"-tcpDaemon",
"-key", key, databaseName);
server.start();
} catch (SQLException e) {
throw DbException.convert(e);
}
String localAddress = NetUtils.getLocalAddress();
String address = localAddress + ":" + server.getPort();
lock.setProperty("server", address);
String hostName = NetUtils.getHostName(localAddress);
lock.setProperty("hostName", hostName);
lock.save();
}
示例9: testWrongUrl
import org.h2.tools.Server; //导入依赖的package包/类
private void testWrongUrl() throws Exception {
deleteDb("autoReconnect");
Server tcp = Server.createTcpServer().start();
try {
conn = getConnection("jdbc:h2:" + getBaseDir() +
"/autoReconnect;AUTO_SERVER=TRUE");
assertThrows(ErrorCode.DATABASE_ALREADY_OPEN_1, this).
getConnection("jdbc:h2:" + getBaseDir() +
"/autoReconnect;OPEN_NEW=TRUE");
assertThrows(ErrorCode.DATABASE_ALREADY_OPEN_1, this).
getConnection("jdbc:h2:" + getBaseDir() +
"/autoReconnect;OPEN_NEW=TRUE");
conn.close();
conn = getConnection("jdbc:h2:tcp://localhost/" + getBaseDir() +
"/autoReconnect");
assertThrows(ErrorCode.DATABASE_ALREADY_OPEN_1, this).
getConnection("jdbc:h2:" + getBaseDir() +
"/autoReconnect;AUTO_SERVER=TRUE;OPEN_NEW=TRUE");
conn.close();
} finally {
tcp.stop();
}
}
示例10: testLowerCaseIdentifiers
import org.h2.tools.Server; //导入依赖的package包/类
private void testLowerCaseIdentifiers() throws SQLException {
if (!getPgJdbcDriver()) {
return;
}
deleteDb("test");
Connection conn = getConnection(
"test;DATABASE_TO_UPPER=false", "sa", "sa");
Statement stat = conn.createStatement();
stat.execute("create table test(id int, name varchar(255))");
Server server = Server.createPgServer(
"-baseDir", getBaseDir(), "-pgPort", "5535", "-pgDaemon");
server.start();
try {
Connection conn2;
conn2 = DriverManager.getConnection(
"jdbc:postgresql://localhost:5535/test", "sa", "sa");
stat = conn2.createStatement();
stat.execute("select * from test");
conn2.close();
} finally {
server.stop();
}
conn.close();
deleteDb("test");
}
示例11: testPgAdapter
import org.h2.tools.Server; //导入依赖的package包/类
private void testPgAdapter() throws SQLException {
deleteDb("test");
Server server = Server.createPgServer(
"-baseDir", getBaseDir(), "-pgPort", "5535", "-pgDaemon");
assertEquals(5535, server.getPort());
assertEquals("Not started", server.getStatus());
server.start();
assertStartsWith(server.getStatus(), "PG server running at pg://");
try {
if (getPgJdbcDriver()) {
testPgClient();
}
} finally {
server.stop();
}
}
示例12: testKeyAlias
import org.h2.tools.Server; //导入依赖的package包/类
private void testKeyAlias() throws SQLException {
if (!getPgJdbcDriver()) {
return;
}
Server server = Server.createPgServer(
"-pgPort", "5535", "-pgDaemon", "-key", "test", "mem:test");
server.start();
try {
Connection conn = DriverManager.getConnection(
"jdbc:postgresql://localhost:5535/test", "sa", "sa");
Statement stat = conn.createStatement();
// confirm that we've got the in memory implementation
// by creating a table and checking flags
stat.execute("create table test(id int primary key, name varchar)");
ResultSet rs = stat.executeQuery(
"select storage_type from information_schema.tables " +
"where table_name = 'TEST'");
assertTrue(rs.next());
assertEquals("MEMORY", rs.getString(1));
conn.close();
} finally {
server.stop();
}
}
示例13: testOldClientNewServer
import org.h2.tools.Server; //导入依赖的package包/类
private void testOldClientNewServer() throws Exception {
Server server = org.h2.tools.Server.createTcpServer("-tcpPort", "9001");
server.start();
assertThrows(ErrorCode.DRIVER_VERSION_ERROR_2, driver).connect(
"jdbc:h2:tcp://localhost:9001/mem:test", null);
server.stop();
Class<?> serverClass = cl.loadClass("org.h2.tools.Server");
Method m;
m = serverClass.getMethod("createTcpServer", String[].class);
Object serverOld = m.invoke(null, new Object[] { new String[] {
"-tcpPort", "9001" } });
m = serverOld.getClass().getMethod("start");
m.invoke(serverOld);
Connection conn;
conn = org.h2.Driver.load().connect("jdbc:h2:mem:", null);
Statement stat = conn.createStatement();
ResultSet rs = stat.executeQuery("call 1");
rs.next();
assertEquals(1, rs.getInt(1));
conn.close();
m = serverOld.getClass().getMethod("stop");
m.invoke(serverOld);
}
示例14: test
import org.h2.tools.Server; //导入依赖的package包/类
private void test(String dir) throws Exception {
Server server = FtpServer.createFtpServer(
"-ftpDir", dir, "-ftpPort", "8121").start();
FtpServer ftp = (FtpServer) server.getService();
ftp.setEventListener(this);
FtpClient client = FtpClient.open("localhost:8121");
client.login("sa", "sa");
client.makeDirectory("ftp");
client.changeWorkingDirectory("ftp");
assertEquals("CWD", lastEvent.getCommand());
client.makeDirectory("hello");
client.changeWorkingDirectory("hello");
client.changeDirectoryUp();
assertEquals("CDUP", lastEvent.getCommand());
client.nameList("hello");
client.removeDirectory("hello");
client.close();
server.stop();
}
示例15: runServer
import org.h2.tools.Server; //导入依赖的package包/类
private String runServer(int exitCode, String... args) {
ByteArrayOutputStream buff = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(buff);
server = new Server();
server.setOut(ps);
int result = 0;
try {
server.runTool(args);
} catch (SQLException e) {
result = 1;
e.printStackTrace(ps);
}
assertEquals(exitCode, result);
ps.flush();
String s = new String(buff.toByteArray());
return s;
}