本文整理汇总了Java中org.h2.tools.Server.createTcpServer方法的典型用法代码示例。如果您正苦于以下问题:Java Server.createTcpServer方法的具体用法?Java Server.createTcpServer怎么用?Java Server.createTcpServer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.h2.tools.Server
的用法示例。
在下文中一共展示了Server.createTcpServer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
示例2: 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));
}
示例3: 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();
}
示例4: beforeTest
import org.h2.tools.Server; //导入方法依赖的package包/类
/**
* This method is called before a complete set of tests is run. It deletes
* old database files in the test directory and trace files. It also starts
* a TCP server if the test uses remote connections.
*/
public void beforeTest() throws SQLException {
Driver.load();
FileUtils.deleteRecursive(TestBase.BASE_TEST_DIR, true);
DeleteDbFiles.execute(TestBase.BASE_TEST_DIR, null, true);
FileUtils.deleteRecursive("trace.db", false);
if (networked) {
String[] args = ssl ? new String[] { "-tcpSSL", "-tcpPort", "9192" }
: new String[] { "-tcpPort", "9192" };
server = Server.createTcpServer(args);
try {
server.start();
} catch (SQLException e) {
System.out.println("FAIL: can not start server (may already be running)");
server = null;
}
}
}
示例5: classSetUp
import org.h2.tools.Server; //导入方法依赖的package包/类
/**
* テスト開始前の準備. データベースサーバーを起動する.
* @throws Exception
*/
@BeforeClass
public static void classSetUp() throws Exception {
try {
DB_SERVER =
Server.createTcpServer(new String[]{ "-baseDir", "./data", "-tcpPort", "9092" });
DB_SERVER.start();
} catch (Exception e) {
if (e.getCause() instanceof BindException) {
// 既に起動済かもしれないので無視
e.getCause().printStackTrace();
} else {
throw e;
}
}
}
示例6: startServer
import org.h2.tools.Server; //导入方法依赖的package包/类
public static void startServer()
{
if (initialized.get())
return;
initialized.set(true);
String workPath = ServerConfigHelper.getWorkPath();
String host = ServerConfigHelper.getConfig(ITEMS.BINDIP);
String port = ServerConfigHelper.getProperty("config.db.port");
ManagementRegionHelper.setValue(MGM_KEYS.config_db_host, host);
ManagementRegionHelper.setValue(MGM_KEYS.config_db_port, port);
try
{
String[] params = new String[]{"-tcpPort",port,"-tcp","-tcpAllowOthers","-baseDir",workPath+"/h2_home"};
server = Server.createTcpServer(params);
server.start();
//jdbc:h2:tcp://localhost:8081/testaaa/qqq1
String urlConn = "jdbc:h2:tcp://" + host + ":" + port + "/gemlite_manager;USER=sa";
ServerConfigHelper.setProperty("config.db.url", urlConn);
}
catch (Exception e)
{
LogUtil.getCoreLog().warn(e);
initialized.set(false);
}
}
示例7: main
import org.h2.tools.Server; //导入方法依赖的package包/类
public static void main(String[] args)
{
System.setProperty("H2_HOME","d:/tmp/h2db/");
String[] params = new String[]{"-tcpPort","8081","-tcp","-tcpAllowOthers","-baseDir","d:/tmp/h2"};
Server h2serve =new Server();
try
{
Server s = Server.createTcpServer(params);
s.start();
System.out.println(s);
Connection conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:8081/gemlite_manager2;USER=gemlite");
System.out.println(conn);
conn.close();
Thread.sleep(Long.MAX_VALUE);
}
catch (SQLException | InterruptedException e)
{
e.printStackTrace();
}
}
示例8: startServer
import org.h2.tools.Server; //导入方法依赖的package包/类
@Execute(phase = Phase.PROCESS_TEST_CLASSES)
public void startServer() throws IOException, SQLException,
ClassNotFoundException {
server = Server.createTcpServer();
server.start();
LOGGER.info("Database started");
Class.forName("org.h2.Driver");
Connection conn = DriverManager.getConnection(
"jdbc:h2:tcp://localhost/~/test", "sa", "");
List<String> sqls = FileUtils.readLines(new File(
"src/test/resources/create_test_database.sql"));
for (Iterator<String> iterator = sqls.iterator(); iterator.hasNext();) {
String sql = iterator.next();
LOGGER.info(sql);
conn.prepareStatement(sql).executeUpdate();
}
conn.close();
}
示例9: init
import org.h2.tools.Server; //导入方法依赖的package包/类
/**
* If running H2 in local mode, starts the server.
*
* @return this (for chaining)
* @throws Exception Unspecified exception
*/
public H2DataSource init() throws Exception {
if (dbMode == DBMode.LOCAL) {
String port = getPort();
if (port.isEmpty()) {
server = Server.createTcpServer();
} else {
server = Server.createTcpServer("-tcpPort", port);
}
server.start();
}
return this;
}
示例10: createServer
import org.h2.tools.Server; //导入方法依赖的package包/类
@Override
protected Server createServer(final String [] serverParams) throws DbServerServiceException {
try {
return Server.createTcpServer(serverParams);
} catch (final SQLException e) {
LOGGER.log(Level.SEVERE, "Failed to create H2 TCP Server!", e);
throw new DbServerServiceException(e);
}
}
示例11: main
import org.h2.tools.Server; //导入方法依赖的package包/类
public static void main(String[] args) throws SQLException {
String[] arg = { "-tcp", "-tcpAllowOthers" };
Server server = Server.createTcpServer(arg);
server.start();
new MainFrame().setVisible(true);
}
示例12: testServer
import org.h2.tools.Server; //导入方法依赖的package包/类
private void testServer() throws Exception {
Server server = new Server();
server.setOut(new PrintStream(new ByteArrayOutputStream()));
server.runTool("-web", "-webPort", "8182", "-properties",
"null", "-tcp", "-tcpPort", "9101");
try {
String url = "http://localhost:8182";
WebClient client;
String result;
client = new WebClient();
client.setAcceptLanguage("de-de,de;q=0.5");
result = client.get(url);
client.readSessionId(result);
result = client.get(url, "login.jsp");
assertEquals("text/html", client.getContentType());
assertContains(result, "Einstellung");
client.get(url, "favicon.ico");
assertEquals("image/x-icon", client.getContentType());
client.get(url, "ico_ok.gif");
assertEquals("image/gif", client.getContentType());
client.get(url, "tree.js");
assertEquals("text/javascript", client.getContentType());
client.get(url, "stylesheet.css");
assertEquals("text/css", client.getContentType());
client.get(url, "admin.do");
try {
client.get(url, "adminShutdown.do");
} catch (IOException e) {
// expected
Thread.sleep(1000);
}
} finally {
server.shutdown();
}
// it should be stopped now
server = Server.createTcpServer("-tcpPort", "9101");
server.start();
server.stop();
}
示例13: testReadOnlyInZip
import org.h2.tools.Server; //导入方法依赖的package包/类
private void testReadOnlyInZip() throws SQLException {
if (config.cipher != null) {
return;
}
deleteDb("readonlyInZip");
String dir = getBaseDir();
Connection conn = getConnection("readonlyInZip");
Statement stat = conn.createStatement();
stat.execute("CREATE TABLE TEST(ID INT) AS " +
"SELECT X FROM SYSTEM_RANGE(1, 20)");
conn.close();
Backup.execute(dir + "/readonly.zip", dir, "readonlyInZip", true);
conn = getConnection(
"jdbc:h2:zip:"+dir+"/readonly.zip!/readonlyInZip", getUser(), getPassword());
conn.createStatement().execute("select * from test where id=1");
conn.close();
Server server = Server.createTcpServer("-tcpPort", "9081", "-baseDir", dir);
server.start();
try {
conn = getConnection(
"jdbc:h2:tcp://localhost:9081/zip:readonly.zip!/readonlyInZip",
getUser(), getPassword());
conn.createStatement().execute("select * from test where id=1");
conn.close();
FilePathZip2.register();
conn = getConnection(
"jdbc:h2:tcp://localhost:9081/zip2:readonly.zip!/readonlyInZip",
getUser(), getPassword());
conn.createStatement().execute("select * from test where id=1");
conn.close();
} finally {
server.stop();
}
deleteDb("readonlyInZip");
}
示例14: h2Server
import org.h2.tools.Server; //导入方法依赖的package包/类
/** テスト用途のメモリDBサーバ */
@Bean(initMethod="start", destroyMethod = "stop")
@ConditionalOnProperty(prefix = "extension.test.db", name = "enabled", matchIfMissing = false)
Server h2Server() {
try {
return Server.createTcpServer("-tcpAllowOthers", "-tcpPort", "9092");
} catch (SQLException e) {
throw new IllegalStateException(e);
}
}
示例15: setUp
import org.h2.tools.Server; //导入方法依赖的package包/类
public void setUp() throws Exception {
try {
s = Server.createTcpServer(new String[] { "-baseDir", "./data", "-tcpPort", "9092" });
s.start();
} catch (Exception ignore) {}
}