use of org.h2.message.Trace in project h2database by h2database.
the class WebServer method listen.
@Override
public void listen() {
this.listenerThread = Thread.currentThread();
try {
while (serverSocket != null) {
Socket s = serverSocket.accept();
WebThread c = new WebThread(s, this);
running.add(c);
c.start();
}
} catch (Exception e) {
trace(e.toString());
}
}
use of org.h2.message.Trace in project h2database by h2database.
the class JdbcConnection method setSavepoint.
/**
* Creates a new named savepoint.
*
* @param name the savepoint name
* @return the new savepoint
*/
@Override
public Savepoint setSavepoint(String name) throws SQLException {
try {
int id = getNextId(TraceObject.SAVEPOINT);
if (isDebugEnabled()) {
debugCodeAssign("Savepoint", TraceObject.SAVEPOINT, id, "setSavepoint(" + quote(name) + ")");
}
checkClosed();
CommandInterface set = prepareCommand("SAVEPOINT " + JdbcSavepoint.getName(name, 0), Integer.MAX_VALUE);
set.executeUpdate(false);
return new JdbcSavepoint(this, 0, name, trace, id);
} catch (Exception e) {
throw logAndConvert(e);
}
}
use of org.h2.message.Trace in project h2database by h2database.
the class JdbcConnection method getMetaData.
/**
* Gets the database meta data for this database.
*
* @return the database meta data
* @throws SQLException if the connection is closed
*/
@Override
public DatabaseMetaData getMetaData() throws SQLException {
try {
int id = getNextId(TraceObject.DATABASE_META_DATA);
if (isDebugEnabled()) {
debugCodeAssign("DatabaseMetaData", TraceObject.DATABASE_META_DATA, id, "getMetaData()");
}
checkClosed();
return new JdbcDatabaseMetaData(this, trace, id);
} catch (Exception e) {
throw logAndConvert(e);
}
}
use of org.h2.message.Trace in project h2database by h2database.
the class Server method createTcpServer.
/**
* Create a new TCP server, but does not start it yet. Example:
*
* <pre>
* Server server = Server.createTcpServer(
* "-tcpPort", "9123", "-tcpAllowOthers").start();
* </pre>
* Supported options are:
* -tcpPort, -tcpSSL, -tcpPassword, -tcpAllowOthers, -tcpDaemon,
* -trace, -ifExists, -baseDir, -key.
* See the main method for details.
* <p>
* If no port is specified, the default port is used if possible,
* and if this port is already used, a random port is used.
* Use getPort() or getURL() after starting to retrieve the port.
* </p>
*
* @param args the argument list
* @return the server
*/
public static Server createTcpServer(String... args) throws SQLException {
TcpServer service = new TcpServer();
Server server = new Server(service, args);
service.setShutdownHandler(server);
return server;
}
use of org.h2.message.Trace in project h2database by h2database.
the class Server method runTool.
@Override
public void runTool(String... args) throws SQLException {
boolean tcpStart = false, pgStart = false, webStart = false;
boolean browserStart = false;
boolean tcpShutdown = false, tcpShutdownForce = false;
String tcpPassword = "";
String tcpShutdownServer = "";
boolean startDefaultServers = true;
for (int i = 0; args != null && i < args.length; i++) {
String arg = args[i];
if (arg == null) {
} else if ("-?".equals(arg) || "-help".equals(arg)) {
showUsage();
return;
} else if (arg.startsWith("-web")) {
if ("-web".equals(arg)) {
startDefaultServers = false;
webStart = true;
} else if ("-webAllowOthers".equals(arg)) {
// no parameters
} else if ("-webDaemon".equals(arg)) {
// no parameters
} else if ("-webSSL".equals(arg)) {
// no parameters
} else if ("-webPort".equals(arg)) {
i++;
} else {
showUsageAndThrowUnsupportedOption(arg);
}
} else if ("-browser".equals(arg)) {
startDefaultServers = false;
browserStart = true;
} else if (arg.startsWith("-tcp")) {
if ("-tcp".equals(arg)) {
startDefaultServers = false;
tcpStart = true;
} else if ("-tcpAllowOthers".equals(arg)) {
// no parameters
} else if ("-tcpDaemon".equals(arg)) {
// no parameters
} else if ("-tcpSSL".equals(arg)) {
// no parameters
} else if ("-tcpPort".equals(arg)) {
i++;
} else if ("-tcpPassword".equals(arg)) {
tcpPassword = args[++i];
} else if ("-tcpShutdown".equals(arg)) {
startDefaultServers = false;
tcpShutdown = true;
tcpShutdownServer = args[++i];
} else if ("-tcpShutdownForce".equals(arg)) {
tcpShutdownForce = true;
} else {
showUsageAndThrowUnsupportedOption(arg);
}
} else if (arg.startsWith("-pg")) {
if ("-pg".equals(arg)) {
startDefaultServers = false;
pgStart = true;
} else if ("-pgAllowOthers".equals(arg)) {
// no parameters
} else if ("-pgDaemon".equals(arg)) {
// no parameters
} else if ("-pgPort".equals(arg)) {
i++;
} else {
showUsageAndThrowUnsupportedOption(arg);
}
} else if ("-properties".equals(arg)) {
i++;
} else if ("-trace".equals(arg)) {
// no parameters
} else if ("-ifExists".equals(arg)) {
// no parameters
} else if ("-baseDir".equals(arg)) {
i++;
} else if ("-key".equals(arg)) {
i += 2;
} else {
showUsageAndThrowUnsupportedOption(arg);
}
}
verifyArgs(args);
if (startDefaultServers) {
tcpStart = true;
pgStart = true;
webStart = true;
browserStart = true;
}
// TODO server: maybe use one single properties file?
if (tcpShutdown) {
out.println("Shutting down TCP Server at " + tcpShutdownServer);
shutdownTcpServer(tcpShutdownServer, tcpPassword, tcpShutdownForce, false);
}
try {
if (tcpStart) {
tcp = createTcpServer(args);
tcp.start();
out.println(tcp.getStatus());
tcp.setShutdownHandler(this);
}
if (pgStart) {
pg = createPgServer(args);
pg.start();
out.println(pg.getStatus());
}
if (webStart) {
web = createWebServer(args);
web.setShutdownHandler(this);
SQLException result = null;
try {
web.start();
} catch (Exception e) {
result = DbException.toSQLException(e);
}
out.println(web.getStatus());
// are wondering why nothing happens
if (browserStart) {
try {
openBrowser(web.getURL());
} catch (Exception e) {
out.println(e.getMessage());
}
}
if (result != null) {
throw result;
}
} else if (browserStart) {
out.println("The browser can only start if a web server is started (-web)");
}
} catch (SQLException e) {
stopAll();
throw e;
}
}
Aggregations