Java Code Examples for org.h2.tools.Server#start()

The following examples show how to use org.h2.tools.Server#start() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestConfig.java    From we-cmdb with Apache License 2.0 5 votes vote down vote up
@Bean(name = "h2server", destroyMethod = "stop")
public Server getH2Server() {
    Server h2Server;
    try {
        h2Server = Server.createWebServer("-web", "-webAllowOthers", "-webPort", "8082");
        h2Server.start();
        return h2Server;
    } catch (SQLException e) {
        logger.info("Fail to start H2 server.", e);
    }
    return null;
}
 
Example 2
Source File: MainDb.java    From e with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws SQLException {

        String[] arg = { "-tcp", "-tcpAllowOthers" };
        Server server = Server.createTcpServer(arg);
        server.start();

		System.out.println("JVM running for");
    }
 
Example 3
Source File: MicroServiceConsole.java    From e with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws SQLException {
    Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {

        @Override
        public void run() {
            killProcess();
        }
    }));

    String[] arg = { "-tcp", "-tcpAllowOthers" };
    Server server = Server.createTcpServer(arg);
    server.start();

    init();
}
 
Example 4
Source File: MainFrame.java    From e with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws SQLException {

        String[] arg = { "-tcp", "-tcpAllowOthers" };
        Server server = Server.createTcpServer(arg);
        server.start();
        new MainFrame().setVisible(true);

    }
 
Example 5
Source File: H2Test.java    From x-pipe with Apache License 2.0 4 votes vote down vote up
protected void startH2Server() throws SQLException {

        Server tcpServer = Server.createTcpServer("-tcpPort", String.valueOf(h2Port), "-tcpAllowOthers");
        tcpServer.start();
    }
 
Example 6
Source File: LogImport.java    From chipster with MIT License 4 votes vote down vote up
/**
		 * 
		 * @throws SQLException 
		 * @throws MicroarrayException 
		 * @throws JMSException
		 * @throws IOException if creation of working directory fails.
		 * @throws MicroarrayException
		 * @throws JMSException 
		 * @throws IllegalConfigurationException 
		 * @throws IOException 
		 * @throws ClassNotFoundException 
		 * @throws SQLException 
		 */
		public LogImport() throws SQLException {
			
			
			// initialize database connection
//			String dbDriver = MicroarrayConfiguration.getValue("manager", "jdbcDriver");
//			String dbUrl = MicroarrayConfiguration.getValue("manager", "databaseUrl");
//			boolean startWebConsole = "true".equals(MicroarrayConfiguration.getValue("manager", "startWebConsole"));
//			String dbUsername = MicroarrayConfiguration.getValue("manager", "databaseUsername");
//		    String dbPassword = MicroarrayConfiguration.getValue("manager", "databasePassword");
//		    int webConsolePort = Integer.parseInt(MicroarrayConfiguration.getValue("manager", "webConsolePort"));

//			Server tcpServer;
//			tcpServer = Server.createTcpServer();
//			tcpServer.start();
			
			String dbDriver = "org.h2.Driver";
			String dbUrl = "jdbc:h2:~/database/chipster-manager";
			boolean startWebConsole = true;
			String dbUsername = "chipster";
		    String dbPassword = "";
		    int webConsolePort = 8082;

		    
			DriverManagerDataSource dataSource = new DriverManagerDataSource();
			dataSource.setDriverClassName(dbDriver);
			dataSource.setUrl(dbUrl);
			dataSource.setUsername(dbUsername);
			dataSource.setPassword(dbPassword);
			
	        this.jdbcTemplate = new JdbcTemplate(dataSource);
		    this.insertJobTemplate = new SimpleJdbcInsert(dataSource).withTableName("jobs");

		    // create tables if they do not exist
		    jdbcTemplate.execute(CREATE_JOBS_TABLE);
			
			// start web console
			Server server;
			if (startWebConsole) {
				server = Server.createWebServer(new String[] {"-webAllowOthers",  "-webPort", String.valueOf(webConsolePort)});
				server.start();
			}
		}