`

H2提供的服务器测试

H2 
阅读更多
package com.boonya.h2.tools;
import java.sql.SQLException;
import org.h2.tools.Server;
import com.boonya.h2.jdbc.connection.DBConnection;
/**
 * DBServers.java
 * 功能:H2提供的服务器测试
 * @author boonya
 * @version 1.0 2013-03-11
 */
public class DBServers {
	/**
	 * TCP server
	 */
	@SuppressWarnings("static-access")
	public void visitTcpServer(){
		try {
			Server server=Server.createTcpServer(new String[]{"-tcpPort","7823","-tcpAllowOthers"}).start();
			if(server.isRunning(true)){
				System.out.println("TCP服务器正在运行......");
				server.startWebServer(DBConnection.getConnection());
			}
			server.shutdownTcpServer("tcp://192.168.8.33:9094", "boonya", true, false);//url,password,boolean,boolean
			server.stop();
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
	/**
	 * WEB server
	 */
	@SuppressWarnings("static-access")
	public void visitWebServer(){
		try {
			Server server=Server.createWebServer(new String[]{"-trace"}).start();
			if(server.isRunning(true)){
				System.out.println("WEB服务器正在运行......");
				server.startWebServer(DBConnection.getConnection());
			}
			server.shutdown();
			server.stop();
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
	/**
	 * PG server
	 */
	@SuppressWarnings("static-access")
	public void visitPgServer(){
		try {
			Server server=Server.createPgServer("-tcpAllowOthers").start();
			if(server.isRunning(true)){
				System.out.println("PG服务器正在运行......");
				server.startWebServer(DBConnection.getConnection());
			}
			server.shutdown();
			server.stop();
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}

}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics