use of org.h2.jdbcx.JdbcConnectionPool in project ignite by apache.
the class DbH2ServerStartup method main.
/**
* Start H2 database TCP server.
*
* @param args Command line arguments, none required.
* @throws IgniteException If start H2 database TCP server failed.
*/
public static void main(String[] args) throws IgniteException {
try {
// Start H2 database TCP server in order to access sample in-memory database from other processes.
Server.createTcpServer("-tcpDaemon").start();
populateDatabase();
// Try to connect to database TCP server.
JdbcConnectionPool dataSrc = JdbcConnectionPool.create("jdbc:h2:tcp://localhost/mem:ExampleDb", "sa", "");
// Create Person table in database.
RunScript.execute(dataSrc.getConnection(), new StringReader(CREATE_PERSON_TABLE));
// Populates Person table with sample data in database.
RunScript.execute(dataSrc.getConnection(), new StringReader(POPULATE_PERSON_TABLE));
} catch (SQLException e) {
throw new IgniteException("Failed to start database TCP server", e);
}
try {
do {
System.out.println("Type 'q' and press 'Enter' to stop H2 TCP server...");
} while ('q' != System.in.read());
} catch (IOException ignored) {
// No-op.
}
}
use of org.h2.jdbcx.JdbcConnectionPool in project ignite by apache.
the class DbH2ServerStartup method populateDatabase.
/**
* Populate sample database.
*
* @throws SQLException if
*/
public static void populateDatabase() throws SQLException {
// Try to connect to database TCP server.
JdbcConnectionPool dataSrc = JdbcConnectionPool.create("jdbc:h2:tcp://localhost/mem:ExampleDb", "sa", "");
// Create Person table in database.
RunScript.execute(dataSrc.getConnection(), new StringReader(CREATE_PERSON_TABLE));
// Populates Person table with sample data in database.
RunScript.execute(dataSrc.getConnection(), new StringReader(POPULATE_PERSON_TABLE));
}
Aggregations