本文整理汇总了Java中org.h2.tools.Server.createWebServer方法的典型用法代码示例。如果您正苦于以下问题:Java Server.createWebServer方法的具体用法?Java Server.createWebServer怎么用?Java Server.createWebServer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.h2.tools.Server
的用法示例。
在下文中一共展示了Server.createWebServer方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testWrongParameters
import org.h2.tools.Server; //导入方法依赖的package包/类
private static void testWrongParameters() {
new AssertThrows(ErrorCode.FEATURE_NOT_SUPPORTED_1) {
@Override
public void test() throws SQLException {
Server.createPgServer("-pgPort 8182");
}};
new AssertThrows(ErrorCode.FEATURE_NOT_SUPPORTED_1) {
@Override
public void test() throws SQLException {
Server.createTcpServer("-tcpPort 8182");
}};
new AssertThrows(ErrorCode.FEATURE_NOT_SUPPORTED_1) {
@Override
public void test() throws SQLException {
Server.createWebServer("-webPort=8182");
}};
}
示例2: testAlreadyRunning
import org.h2.tools.Server; //导入方法依赖的package包/类
private void testAlreadyRunning() throws Exception {
Server server = Server.createWebServer(
"-webPort", "8182", "-properties", "null");
server.start();
assertTrue(server.getStatus().contains("server running"));
Server server2 = Server.createWebServer(
"-webPort", "8182", "-properties", "null");
assertEquals("Not started", server2.getStatus());
try {
server2.start();
fail();
} catch (Exception e) {
assertTrue(e.toString().contains("port may be in use"));
assertTrue(server2.getStatus().contains(
"could not be started"));
}
server.stop();
}
示例3: createServer
import org.h2.tools.Server; //导入方法依赖的package包/类
@Override
protected Server createServer(final String [] serverParams) throws DbServerServiceException {
try {
return Server.createWebServer(serverParams);
} catch (final SQLException e) {
LOGGER.log(Level.SEVERE, "Failed to create H2 Web Server!", e);
throw new DbServerServiceException(e);
}
}
示例4: InvoicePortImpl
import org.h2.tools.Server; //导入方法依赖的package包/类
public InvoicePortImpl() throws Exception {
// Start the H2 database in MIXED mode - this means we can allow
// access via the web console (HTTP)
// and use a (faster) embedded connection for the service's
// backend.
// See http://www.h2database.com/html/features.html#connection_modes
Server server = Server.createWebServer("-web", "-webAllowOthers",
"-webPort", "9081");
server.start();
// Alternatively use a TCP server connection to allow connections from
// other JDBC clients
// e.g. Squirrel - connection string will then be like
//jdbc:h2:tcp://localhost:9082/./invoicev3-testdb
//Server server2 = Server.createTcpServer("-tcpPort", "9082");
//server2.start();
System.out
.println("You can access the database remotely now, using the URL:");
System.out.println("http://localhost:9081/" + DB_FILE_LOCATION
+ " (user: '', password: '')");
Class.forName("org.h2.Driver");
dbConnection = DriverManager.getConnection("jdbc:h2:"
+ DB_FILE_LOCATION);
Statement sqlStatment = dbConnection.createStatement();
sqlStatment
.execute("create table if not exists invoices(id identity primary key, invoiceNo varchar(255),"
+ " customerRef varchar(255), amount varchar(255), dueDate date, lastUpated timestamp default NOW())");
sqlStatment.close();
System.out.println("invoices table created...");
}
示例5: contextInitialized
import org.h2.tools.Server; //导入方法依赖的package包/类
public void contextInitialized(ServletContextEvent servletContextEvent) {
try {
this.server
= Server.createWebServer(
"-webPort", PORT,
"-baseDir", ".",
"-webAllowOthers"
);
server.start();
} catch (SQLException e) {
// TODO 自動生成された catch ブロック
e.printStackTrace();
}
}
示例6: startDBManager
import org.h2.tools.Server; //导入方法依赖的package包/类
@Bean(initMethod = "start", destroyMethod = "stop")
public Server startDBManager() throws SQLException {
return Server.createWebServer();
}
示例7: main
import org.h2.tools.Server; //导入方法依赖的package包/类
public static void main(final String[] args) throws Exception {
logger.info("Starting materializer ...");
// Create H2 web server for inspections and configure persistence
Server webServer = Server.createWebServer();
webServer.start();
EntityManagerFactory entityManagerFactory =
Persistence.createEntityManagerFactory("default");
// Configure Jackson with support for Kotlin
ObjectMapper objectMapper = new ObjectMapper().registerModule(new KotlinModule());
JsonConverter.setObjectMapper(objectMapper);
// Configure sourcerer and EventStore connection
EventStore eventStore = EventStoreBuilder
.newBuilder()
.userCredentials("admin", "changeit")
.singleNodeAddress("localhost", 1113)
.failOnNoServerResponseEnabled()
.build();
EventStoreEsjcEventRepositoryFactory repositoryFactory =
new EventStoreEsjcEventRepositoryFactory(
eventStore,
objectMapper,
"sourcerer_todo");
EventRepository<TodoItemEvent> todoEventRepository =
repositoryFactory.getEventRepository(TodoItemEvent.class);
EventSubscriptionFactory<TodoItemEvent> todoSubscriptionFactory =
new DefaultEventSubscriptionFactory<>(todoEventRepository);
// Create and start materializer subscription for TODO item details view
TodoItemDetailsMaterializer detailsSubscriptionHandler
= new TodoItemDetailsMaterializer(entityManagerFactory);
EventSubscription detailsSubscription
= todoSubscriptionFactory.fromSubscriptionHandler(detailsSubscriptionHandler);
detailsSubscription.setPositionSource(detailsSubscriptionHandler);
detailsSubscription.start();
// Create and start materializer subscription for worklists
TodoWorklistMaterializer worklistSubscriptionHandler
= new TodoWorklistMaterializer(entityManagerFactory);
EventSubscription worklistSubscription
= todoSubscriptionFactory.fromSubscriptionHandler(worklistSubscriptionHandler);
worklistSubscription.setPositionSource(worklistSubscriptionHandler);
worklistSubscription.start();
logger.info("Materializer running");
}
示例8: createWebServer
import org.h2.tools.Server; //导入方法依赖的package包/类
@Bean(name = "h2WebServer", initMethod = "start", destroyMethod = "stop")
Server createWebServer() throws SQLException {
return Server.createWebServer("-web", "-webAllowOthers", "-webPort", "8082");
}
示例9: h2WebServer
import org.h2.tools.Server; //导入方法依赖的package包/类
@Bean(initMethod = "start", destroyMethod = "stop")
public Server h2WebServer() throws SQLException {
return Server.createWebServer("-web", "-webAllowOthers", "-webPort", "8082");
}
示例10: startDBManager
import org.h2.tools.Server; //导入方法依赖的package包/类
@Bean(initMethod = "start", destroyMethod = "stop")
public Server startDBManager() throws SQLException {
return Server.createWebServer();
}
示例11: LogImport
import org.h2.tools.Server; //导入方法依赖的package包/类
/**
*
* @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();
}
}