Search in sources :

Example 61 with Trace

use of org.h2.message.Trace in project h2database by h2database.

the class TestValueMemory method test.

@Override
public void test() throws SQLException {
    testCompare();
    for (int i = 0; i < Value.TYPE_COUNT; i++) {
        if (i == 23) {
            // experiment
            continue;
        }
        Value v = create(i);
        String s = "type: " + v.getType() + " calculated: " + v.getMemory() + " real: " + MemoryFootprint.getObjectSize(v) + " " + v.getClass().getName() + ": " + v.toString();
        trace(s);
    }
    for (int i = 0; i < Value.TYPE_COUNT; i++) {
        if (i == 23) {
            // experiment
            continue;
        }
        Value v = create(i);
        if (v == ValueNull.INSTANCE && i == Value.GEOMETRY) {
            // jts not in the classpath, OK
            continue;
        }
        assertEquals(i, v.getType());
        testType(i);
    }
}
Also used : Value(org.h2.value.Value) ValueString(org.h2.value.ValueString) MemoryFootprint(org.h2.test.utils.MemoryFootprint)

Example 62 with Trace

use of org.h2.message.Trace in project main by JohnPeng739.

the class H2ServerFactory method initPgServer.

/**
 * 初始化PG服务器
 */
private void initPgServer() {
    boolean enable = env.getProperty("h2.pg.enable", Boolean.class, false);
    if (enable) {
        int port = env.getProperty("h2.pg.port", Integer.class, 5435);
        String baseDir = env.getProperty("h2.pg.baseDir", String.class, "~/h2db");
        boolean daemon = env.getProperty("h2.pg.daemon", Boolean.class, true);
        boolean trace = env.getProperty("h2.pg.trace", Boolean.class, true);
        List<String> args = new ArrayList<>();
        args.add("-pgPort");
        args.add(String.valueOf(port));
        args.add("-baseDir");
        args.add(baseDir);
        if (daemon) {
            args.add("-pgDaemon");
        }
        if (trace) {
            args.add("-trace");
        }
        try {
            Server server = Server.createPgServer(args.toArray(new String[0]));
            server.start();
            if (logger.isDebugEnabled()) {
                logger.debug(String.format("Start H2 pg Server success, conf: %s.", StringUtils.merge(args, " ")));
            }
            this.pgServer = server;
        } catch (SQLException ex) {
            if (logger.isErrorEnabled()) {
                logger.error(String.format("Create H2 pg server fail, conf: %s.", StringUtils.merge(args, " ")));
            }
        }
    }
}
Also used : Server(org.h2.tools.Server) SQLException(java.sql.SQLException) ArrayList(java.util.ArrayList)

Example 63 with Trace

use of org.h2.message.Trace in project main by JohnPeng739.

the class H2ServerFactory method initTcpServer.

/**
 * 初始化TCP服务器
 */
private void initTcpServer() {
    boolean enable = env.getProperty("h2.tcp.enable", Boolean.class, false);
    if (enable) {
        int port = env.getProperty("h2.tcp.port", Integer.class, 9092);
        String baseDir = env.getProperty("h2.tcp.baseDir", String.class, "~/h2db");
        boolean daemon = env.getProperty("h2.tcp.daemon", Boolean.class, true);
        boolean trace = env.getProperty("h2.tcp.trace", Boolean.class, true);
        List<String> args = new ArrayList<>();
        args.add("-tcpPort");
        args.add(String.valueOf(port));
        // args.add(baseDir);
        if (daemon) {
            args.add("-tcpDaemon");
        }
        if (trace) {
            args.add("-trace");
        }
        try {
            Server server = Server.createTcpServer(args.toArray(new String[0]));
            server.start();
            if (logger.isDebugEnabled()) {
                logger.debug(String.format("Start H2 TCP Server success, conf: %s.", StringUtils.merge(args, " ")));
            }
            this.tcpServer = server;
        } catch (SQLException ex) {
            if (logger.isErrorEnabled()) {
                logger.error(String.format("Create H2 TCP server fail, conf: %s.", StringUtils.merge(args, " ")));
            }
        }
    }
}
Also used : Server(org.h2.tools.Server) SQLException(java.sql.SQLException) ArrayList(java.util.ArrayList)

Aggregations

SQLException (java.sql.SQLException)16 DbException (org.h2.message.DbException)14 Connection (java.sql.Connection)11 ResultSet (java.sql.ResultSet)10 PreparedStatement (java.sql.PreparedStatement)9 Statement (java.sql.Statement)8 IOException (java.io.IOException)7 Savepoint (java.sql.Savepoint)7 Random (java.util.Random)7 ArrayList (java.util.ArrayList)5 Properties (java.util.Properties)5 TraceSystem (org.h2.message.TraceSystem)5 Server (org.h2.tools.Server)5 ValueString (org.h2.value.ValueString)5 SQLClientInfoException (java.sql.SQLClientInfoException)4 SysProperties (org.h2.engine.SysProperties)4 JdbcConnection (org.h2.jdbc.JdbcConnection)4 SortedProperties (org.h2.util.SortedProperties)4 Value (org.h2.value.Value)4 Socket (java.net.Socket)3