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


Java Server.createTcpServer方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:Evolveum,项目名称:midpoint,代码行数:17,代码来源:SqlRepositoryFactory.java

示例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));
}
 
开发者ID:jboss-integration,项目名称:fuse-bxms-integ,代码行数:18,代码来源:CamelSqlTest.java

示例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();
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:19,代码来源:Database.java

示例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;
        }
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:23,代码来源:TestAll.java

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

示例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);
  }
}
 
开发者ID:iisi-nj,项目名称:GemFireLite,代码行数:27,代码来源:EmbedServer.java

示例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();
  }
}
 
开发者ID:iisi-nj,项目名称:GemFireLite,代码行数:21,代码来源:StartH2.java

示例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();
}
 
开发者ID:javabuild,项目名称:builder-parent,代码行数:19,代码来源:DatabaseStarter.java

示例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;
}
 
开发者ID:carewebframework,项目名称:carewebframework-core,代码行数:22,代码来源:H2DataSource.java

示例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);
    }
}
 
开发者ID:cerner,项目名称:jwala,代码行数:10,代码来源:H2TcpServerServiceImpl.java

示例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);

    }
 
开发者ID:fuhoujun,项目名称:e,代码行数:9,代码来源:MainFrame.java

示例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();
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:40,代码来源:TestWeb.java

示例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");
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:36,代码来源:TestReadOnly.java

示例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);
    }
}
 
开发者ID:jkazama,项目名称:sample-boot-micro,代码行数:11,代码来源:MicroRegistry.java

示例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) {}
}
 
开发者ID:otsecbsol,项目名称:linkbinder,代码行数:8,代码来源:H2DatabaseServerTester.java


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