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


Java Server.createPgServer方法代码示例

本文整理汇总了Java中org.h2.tools.Server.createPgServer方法的典型用法代码示例。如果您正苦于以下问题:Java Server.createPgServer方法的具体用法?Java Server.createPgServer怎么用?Java Server.createPgServer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.h2.tools.Server的用法示例。


在下文中一共展示了Server.createPgServer方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

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

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

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

示例4: testWrongParameters

import org.h2.tools.Server; //导入方法依赖的package包/类
private static void testWrongParameters() {
    new AssertThrows(ErrorCode.FEATURE_NOT_SUPPORTED_1) {
        @Override
        public void test() throws SQLException {
            Server.createPgServer("-pgPort 8182");
    }};
    new AssertThrows(ErrorCode.FEATURE_NOT_SUPPORTED_1) {
        @Override
        public void test() throws SQLException {
            Server.createTcpServer("-tcpPort 8182");
    }};
    new AssertThrows(ErrorCode.FEATURE_NOT_SUPPORTED_1) {
        @Override
        public void test() throws SQLException {
            Server.createWebServer("-webPort=8182");
    }};
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:18,代码来源:TestWeb.java

示例5: contextInitialized

import org.h2.tools.Server; //导入方法依赖的package包/类
public void contextInitialized(ServletContextEvent servletContextEvent) {
  try {
    this.server
      = Server.createPgServer(
          "-pgPort", PORT,
          "-baseDir", ".",
          "-pgAllowOthers"
        );
    server.start();
  } catch (SQLException e) {
    // TODO 自動生成された catch ブロック
    e.printStackTrace();
  }
}
 
开发者ID:kaitoy,项目名称:sneo,代码行数:15,代码来源:PgServerStarter.java

示例6: testCancelQuery

import org.h2.tools.Server; //导入方法依赖的package包/类
private void testCancelQuery() throws Exception {
    if (!getPgJdbcDriver()) {
        return;
    }

    Server server = Server.createPgServer(
            "-pgPort", "5535", "-pgDaemon", "-key", "test", "mem:test");
    server.start();

    ExecutorService executor = Executors.newSingleThreadExecutor();
    try {
        Connection conn = DriverManager.getConnection(
                "jdbc:postgresql://localhost:5535/test", "sa", "sa");
        final Statement stat = conn.createStatement();
        stat.execute("create alias sleep for \"java.lang.Thread.sleep\"");

        // create a table with 200 rows (cancel interval is 127)
        stat.execute("create table test(id int)");
        for (int i = 0; i < 200; i++) {
            stat.execute("insert into test (id) values (rand())");
        }

        Future<Boolean> future = executor.submit(new Callable<Boolean>() {
            @Override
            public Boolean call() throws SQLException {
                return stat.execute("select id, sleep(5) from test");
            }
        });

        // give it a little time to start and then cancel it
        Thread.sleep(100);
        stat.cancel();

        try {
            future.get();
            throw new IllegalStateException();
        } catch (ExecutionException e) {
            assertStartsWith(e.getCause().getMessage(),
                    "ERROR: canceling statement due to user request");
        } finally {
            conn.close();
        }
    } finally {
        server.stop();
        executor.shutdown();
    }
    deleteDb("test");
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:49,代码来源:TestPgServer.java

示例7: testBinaryTypes

import org.h2.tools.Server; //导入方法依赖的package包/类
private void testBinaryTypes() 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();

        stat.execute(
                "create table test(x1 varchar, x2 int, " +
                "x3 smallint, x4 bigint, x5 double, x6 float, " +
                "x7 real, x8 boolean, x9 char, x10 bytea)");

        PreparedStatement ps = conn.prepareStatement(
                "insert into test values (?,?,?,?,?,?,?,?,?,?)");
        ps.setString(1, "test");
        ps.setInt(2, 12345678);
        ps.setShort(3, (short) 12345);
        ps.setLong(4, 1234567890123L);
        ps.setDouble(5, 123.456);
        ps.setFloat(6, 123.456f);
        ps.setDouble(7, 123.456);
        ps.setBoolean(8, true);
        ps.setByte(9, (byte) 0xfe);
        ps.setBytes(10, new byte[] { 'a', (byte) 0xfe, '\127' });
        ps.execute();

        ResultSet rs = stat.executeQuery("select * from test");
        assertTrue(rs.next());
        assertEquals("test", rs.getString(1));
        assertEquals(12345678, rs.getInt(2));
        assertEquals((short) 12345, rs.getShort(3));
        assertEquals(1234567890123L, rs.getLong(4));
        assertEquals(123.456, rs.getDouble(5));
        assertEquals(123.456f, rs.getFloat(6));
        assertEquals(123.456, rs.getDouble(7));
        assertEquals(true, rs.getBoolean(8));
        assertEquals((byte) 0xfe, rs.getByte(9));
        assertEquals(new byte[] { 'a', (byte) 0xfe, '\127' },
                rs.getBytes(10));

        conn.close();
    } finally {
        server.stop();
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:52,代码来源:TestPgServer.java


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