org.apache.derby.drda.NetworkServerControl Java Examples
The following examples show how to use
org.apache.derby.drda.NetworkServerControl.
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: DerbyBase.java From MyBox with Apache License 2.0 | 6 votes |
public static boolean shutdownDerbyServer() { try { boolean portUsed = NetworkTools.isPortUsed(port); if (!portUsed) { return true; } NetworkServerControl server = new NetworkServerControl(InetAddress.getByName(host), port, CommonValues.AppDerbyUser, CommonValues.AppDerbyPassword); server.shutdown(); status = DerbyStatus.NotConnected; return true; } catch (Exception e) { logger.debug(e.toString()); return false; } }
Example #2
Source File: DBSynchronizerTestBase.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
public static NetworkServerControl startNetworkServer(final int netPort) throws Exception { getLogWriter().info( "Starting a Derby Network Server on " + InetAddress.getLocalHost().getHostName() + ":" + netPort); NetworkServerControl server = new NetworkServerControl( InetAddress.getLocalHost(), netPort); // send the output to derby logs server.start(SanityManager.GET_DEBUG_STREAM()); // wait for n/w server to initialize completely while (true) { Thread.sleep(500); try { server.ping(); break; } catch (Exception e) { } } server.logConnections(true); return server; }
Example #3
Source File: DBSynchronizerTestBase.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
public static NetworkServerControl startNetworkServer(final int netPort) throws Exception { getLogWriter().info( "Starting a Derby Network Server on " + InetAddress.getLocalHost().getHostName() + ":" + netPort); NetworkServerControl server = new NetworkServerControl( InetAddress.getLocalHost(), netPort); // send the output to derby logs server.start(SanityManager.GET_DEBUG_STREAM()); // wait for n/w server to initialize completely while (true) { Thread.sleep(500); try { server.ping(); break; } catch (Exception e) { } } server.logConnections(true); return server; }
Example #4
Source File: 919148_ReplicationRun_0_t.java From coming with MIT License | 6 votes |
private void ping( NetworkServerControl controller, int iterations ) throws Exception { Exception finalException = null; for ( int i = 0; i < iterations; i++ ) { try { controller.ping(); util.DEBUG("Server came up in less than "+i+" * "+PINGSERVER_SLEEP_TIME_MILLIS+"ms."); return; } catch (Exception e) { finalException = e; } Thread.sleep( PINGSERVER_SLEEP_TIME_MILLIS ); } String msg = "Could not ping in " + iterations + " * " + PINGSERVER_SLEEP_TIME_MILLIS + "ms.: " + finalException.getMessage(); util.DEBUG( msg ); throw finalException; }
Example #5
Source File: JdbcDatasetRuntimeTest.java From components with Apache License 2.0 | 6 votes |
@BeforeClass public static void startDatabase() throws Exception { ServerSocket socket = new ServerSocket(0); port = socket.getLocalPort(); socket.close(); JDBC_URL = "jdbc:derby://localhost:" + port + "/target/tcomp"; System.setProperty("derby.stream.error.file", "target/derby.log"); derbyServer = new NetworkServerControl(InetAddress.getByName("localhost"), port); derbyServer.start(null); dataSource = new ClientDataSource(); dataSource.setCreateDatabase("create"); dataSource.setDatabaseName("target/tcomp"); dataSource.setServerName("localhost"); dataSource.setPortNumber(port); try (Connection connection = dataSource.getConnection()) { try (Statement statement = connection.createStatement()) { statement.executeUpdate("create table " + TABLE_IN + "(id INT, name VARCHAR(500))"); statement.executeUpdate("create table " + TABLE_OUT + "(id INT, name VARCHAR(500))"); } } }
Example #6
Source File: DerbyBase.java From MyBox with Apache License 2.0 | 6 votes |
public static boolean isServerStarted(NetworkServerControl server) { boolean started = false; int count = 10, wait = 300; while (!started && (count > 0)) { try { count--; server.ping(); started = true; } catch (Exception e) { // failed(e); // logger.debug(e.toString()); try { Thread.currentThread().sleep(wait); } catch (Exception ex) { } } } return started; }
Example #7
Source File: JDBCBeamRuntimeTest.java From components with Apache License 2.0 | 5 votes |
@BeforeClass public static void startDatabase() throws Exception { ServerSocket socket = new ServerSocket(0); port = socket.getLocalPort(); socket.close(); LOGGER.info("Starting Derby database on {}", port); JDBC_URL = "jdbc:derby://localhost:" + port + "/target/tcomp"; System.setProperty("derby.stream.error.file", "target/derby.log"); derbyServer = new NetworkServerControl(InetAddress.getByName("localhost"), port); derbyServer.start(null); dataSource = new ClientDataSource(); dataSource.setCreateDatabase("create"); dataSource.setDatabaseName("target/tcomp"); dataSource.setServerName("localhost"); dataSource.setPortNumber(port); try (Connection connection = dataSource.getConnection()) { try (Statement statement = connection.createStatement()) { statement.executeUpdate("create table " + TABLE_IN + "(id INT, name VARCHAR(500))"); statement.executeUpdate("create table " + TABLE_OUT + "(id INT, name VARCHAR(500))"); } } }
Example #8
Source File: DerbyDatabaseTestResource.java From quarkus with Apache License 2.0 | 5 votes |
@Override public Map<String, String> start() { try { NetworkServerControl server = new NetworkServerControl(); server.start(new PrintWriter(System.out)); for (int i = 1; i <= NUMBER_OF_PINGS; i++) { try { System.out.println("[INFO] Attempt " + i + " to see if Derby Network server started"); server.ping(); break; } catch (Exception ex) { if (i == NUMBER_OF_PINGS) { System.out.println("Derby Network server failed to start"); ex.printStackTrace(); throw ex; } try { Thread.sleep(SLEEP_BETWEEN_PINGS); } catch (InterruptedException ignore) { } } } System.out.println("[INFO] Derby database started in TCP server mode"); } catch (Exception e) { throw new RuntimeException(e); } return Collections.emptyMap(); }
Example #9
Source File: DerbyDatabaseTestResource.java From quarkus with Apache License 2.0 | 5 votes |
@Override public void stop() { try { NetworkServerControl server = new NetworkServerControl(); server.shutdown(); System.out.println("[INFO] Derby database was shut down"); } catch (Exception e) { throw new RuntimeException(e); } }
Example #10
Source File: ClientServerDUnit.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
public static void waitForDerbyInitialization(NetworkServerControl server) throws InterruptedException { for (int tries = 1; tries <= 20; tries++) { try { server.ping(); break; } catch (Throwable t) { Thread.sleep(1000); } } }
Example #11
Source File: DBSynchronizerBasicDUnit.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
public void testBasicInsert() throws Exception { Statement derbyStmt = null; Connection derbyConn = null; NetworkServerControl server = null; try { String derbyDbUrl = getDerbyURL(this.netPort); server = startNetworkServer(); createDerbyValidationArtefacts(); derbyConn = DriverManager.getConnection(derbyDbUrl); derbyStmt = derbyConn.createStatement(); getLogWriter().info("Started derby network server"); startClientVMs(1, 0, null); startServerVMs(2, -1, "SG1"); getLogWriter().info("Started the accessor and datastore vms"); clientSQLExecute(1, "create table TESTTABLE (ID int not null primary key , " + "DESCRIPTION varchar(1024) , ADDRESS varchar(1024), ID1 int )" + " AsyncEventListener (WBCL1) "); Runnable createWBCLConfig = createAsyncQueueConfigurationForBasicTests(derbyDbUrl); clientExecute(1, createWBCLConfig); Runnable startWBCL = startAsyncEventListener("WBCL1"); clientExecute(1, startWBCL); getLogWriter().info("Created and started AsyncEventListener WBCL1"); // Do an insert in sql fabric clientSQLExecute(1, "Insert into TESTTABLE values(1,'desc1','Add1',1)"); clientSQLExecute(1, "Insert into TESTTABLE values(2,'desc2','Add2',2)"); // check that queue is empty. serverSQLExecute(1, "call SYS.WAIT_FOR_SENDER_QUEUE_FLUSH('WBCL1', 1, 30)"); validateResults(derbyStmt, "select * from testtable", this.netPort, true); } finally { derbyCleanup(derbyStmt, derbyConn, server); } }
Example #12
Source File: 919148_ReplicationRun_0_t.java From gumtree-spoon-ast-diff with Apache License 2.0 | 5 votes |
private void pingServer( String hostName, int port, int iterations) throws Exception { util.DEBUG("+++ pingServer"); ping( new NetworkServerControl(InetAddress.getByName(hostName),port), iterations); util.DEBUG("--- pingServer"); }
Example #13
Source File: DBSynchronizerBasicDUnit.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
public void testInsertOnNonPKBasedTable() throws Exception { Statement derbyStmt = null; Connection derbyConn = null; NetworkServerControl server = null; try { String derbyDbUrl = getDerbyURL(this.netPort); server = startNetworkServer(); createDerbyValidationArtefacts(); derbyConn = DriverManager.getConnection(derbyDbUrl); derbyStmt = derbyConn.createStatement(); getLogWriter().info("Started derby network server"); startClientVMs(1, 0, null); startServerVMs(2, -1, "SG1"); getLogWriter().info("Started the accessor and datastore vms"); clientSQLExecute(1, "create table TESTTABLE (ID int not null , " + "DESCRIPTION varchar(1024) , ADDRESS varchar(1024), ID1 int )" + " AsyncEventListener (WBCL1) "); Runnable createWBCLConfig = createAsyncQueueConfigurationForBasicTests(derbyDbUrl); clientExecute(1, createWBCLConfig); Runnable startWBCL = startAsyncEventListener("WBCL1"); clientExecute(1, startWBCL); getLogWriter().info("Created and started AsyncEventListener WBCL1"); // Do an insert in sql fabric clientSQLExecute(1, "Insert into TESTTABLE values(1,'desc1','Add1',1)"); clientSQLExecute(1, "Insert into TESTTABLE values(2,'desc2','Add2',2)"); // check that queue is empty. serverSQLExecute(1, "call SYS.WAIT_FOR_SENDER_QUEUE_FLUSH('WBCL1', 1, 30)"); validateResults(derbyStmt, "select * from testtable", this.netPort, true); } finally { derbyCleanup(derbyStmt, derbyConn, server); } }
Example #14
Source File: 919148_ReplicationRun_0_s.java From gumtree-spoon-ast-diff with Apache License 2.0 | 5 votes |
private void pingServer( String hostName, int port, int iterations) throws Exception { util.DEBUG("+++ pingServer"); ping( new NetworkServerControl(InetAddress.getByName(hostName),port), iterations); util.DEBUG("--- pingServer"); }
Example #15
Source File: DBSynchronizerBasicDUnit.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
public void testBatchInsert() throws Exception { Statement derbyStmt = null; Connection derbyConn = null; NetworkServerControl server = null; try { String derbyDbUrl = getDerbyURL(this.netPort); server = startNetworkServer(); createDerbyValidationArtefacts(); derbyConn = DriverManager.getConnection(derbyDbUrl); derbyStmt = derbyConn.createStatement(); getLogWriter().info("Started derby network server"); startClientVMs(1, 0, null); startServerVMs(2, -1, "SG1"); getLogWriter().info("Started the accessor and datastore vms"); clientSQLExecute(1, "create table TESTTABLE (ID int not null primary key , " + "DESCRIPTION varchar(1024) , ADDRESS varchar(1024), ID1 int )" + " AsyncEventListener (WBCL1) "); Runnable createWBCLConfig = createAsyncQueueConfigurationForBasicTests(derbyDbUrl); clientExecute(1, createWBCLConfig); Runnable startWBCL = startAsyncEventListener("WBCL1"); clientExecute(1, startWBCL); getLogWriter().info("Created and started AsyncEventListener WBCL1"); // Do batch insert in sql fabric clientExecute(1, doBatchInsert()); // check that queue is empty. serverSQLExecute(1, "call SYS.WAIT_FOR_SENDER_QUEUE_FLUSH('WBCL1', 1, 30)"); validateResults(derbyStmt, "select * from testtable", this.netPort, true); } finally { derbyCleanup(derbyStmt, derbyConn, server); } }
Example #16
Source File: 919148_ReplicationRun_0_s.java From gumtree-spoon-ast-diff with Apache License 2.0 | 5 votes |
private NetworkServerControl startServer_direct(String serverHost, String interfacesToListenOn, int serverPort, String fullDbDirPath, String securityOption) // FIXME? true/false? throws Exception { // Wotk in progress. Not currently used! Only partly tested! util.DEBUG("startServer_direct " + serverHost + " " + interfacesToListenOn + " " + serverPort + " " + fullDbDirPath); assertTrue("Attempt to start server on non-localhost: " + serverHost, serverHost.equalsIgnoreCase("localhost")); System.setProperty("derby.system.home", fullDbDirPath); System.setProperty("user.dir", fullDbDirPath); NetworkServerControl server = new NetworkServerControl( InetAddress.getByName(interfacesToListenOn), serverPort); server.start(null); pingServer(serverHost, serverPort, 150); Properties sp = server.getCurrentProperties(); sp.setProperty("noSecurityManager", securityOption.equalsIgnoreCase("-noSecurityManager")?"true":"false"); // derby.log for both master and slave ends up in masters system! // Both are run in the same VM! Not a good idea? return server; }
Example #17
Source File: DerbyServer.java From reladomo with Apache License 2.0 | 5 votes |
private void startNetworkServer() throws Exception { getLogger().info("Starting Network Server"); System.setProperty("derby.drda.startNetworkServer", "true"); Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance(); getLogger().info("Network Server Started"); new NetworkServerControl(); }
Example #18
Source File: 919148_ReplicationRun_0_s.java From gumtree-spoon-ast-diff with Apache License 2.0 | 5 votes |
private void ping( NetworkServerControl controller, int iterations ) throws Exception { Exception finalException = null; for ( int i = 0; i < iterations; i++ ) { try { controller.ping(); util.DEBUG("Server came up in less than "+i+" * "+PINGSERVER_SLEEP_TIME_MILLIS+"ms."); return; } catch (Exception e) { finalException = e; } Thread.sleep( PINGSERVER_SLEEP_TIME_MILLIS ); } String msg = "Could not ping in " + iterations + " * " + PINGSERVER_SLEEP_TIME_MILLIS + "ms.: " + finalException.getMessage(); util.DEBUG( msg ); finalException.printStackTrace(); // REMOVE? throw new Exception(msg); }
Example #19
Source File: ClientServerDUnit.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
public static void waitForDerbyInitialization(NetworkServerControl server) throws InterruptedException { for (int tries = 1; tries <= 20; tries++) { try { server.ping(); break; } catch (Throwable t) { Thread.sleep(1000); } } }
Example #20
Source File: DBSynchronizerBasicDUnit.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
public void testBasicInsert() throws Exception { Statement derbyStmt = null; Connection derbyConn = null; NetworkServerControl server = null; try { String derbyDbUrl = getDerbyURL(this.netPort); server = startNetworkServer(); createDerbyValidationArtefacts(); derbyConn = DriverManager.getConnection(derbyDbUrl); derbyStmt = derbyConn.createStatement(); getLogWriter().info("Started derby network server"); startClientVMs(1, 0, null); startServerVMs(2, -1, "SG1"); getLogWriter().info("Started the accessor and datastore vms"); clientSQLExecute(1, "create table TESTTABLE (ID int not null primary key , " + "DESCRIPTION varchar(1024) , ADDRESS varchar(1024), ID1 int )" + " AsyncEventListener (WBCL1) "); Runnable createWBCLConfig = createAsyncQueueConfigurationForBasicTests(derbyDbUrl); clientExecute(1, createWBCLConfig); Runnable startWBCL = startAsyncEventListener("WBCL1"); clientExecute(1, startWBCL); getLogWriter().info("Created and started AsyncEventListener WBCL1"); // Do an insert in sql fabric clientSQLExecute(1, "Insert into TESTTABLE values(1,'desc1','Add1',1)"); clientSQLExecute(1, "Insert into TESTTABLE values(2,'desc2','Add2',2)"); // check that queue is empty. serverSQLExecute(1, "call SYS.WAIT_FOR_SENDER_QUEUE_FLUSH('WBCL1', 1, 30)"); validateResults(derbyStmt, "select * from testtable", this.netPort, true); } finally { derbyCleanup(derbyStmt, derbyConn, server); } }
Example #21
Source File: DBSynchronizerBasicDUnit.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
public void testBatchInsert() throws Exception { Statement derbyStmt = null; Connection derbyConn = null; NetworkServerControl server = null; try { String derbyDbUrl = getDerbyURL(this.netPort); server = startNetworkServer(); createDerbyValidationArtefacts(); derbyConn = DriverManager.getConnection(derbyDbUrl); derbyStmt = derbyConn.createStatement(); getLogWriter().info("Started derby network server"); startClientVMs(1, 0, null); startServerVMs(2, -1, "SG1"); getLogWriter().info("Started the accessor and datastore vms"); clientSQLExecute(1, "create table TESTTABLE (ID int not null primary key , " + "DESCRIPTION varchar(1024) , ADDRESS varchar(1024), ID1 int )" + " AsyncEventListener (WBCL1) "); Runnable createWBCLConfig = createAsyncQueueConfigurationForBasicTests(derbyDbUrl); clientExecute(1, createWBCLConfig); Runnable startWBCL = startAsyncEventListener("WBCL1"); clientExecute(1, startWBCL); getLogWriter().info("Created and started AsyncEventListener WBCL1"); // Do batch insert in sql fabric clientExecute(1, doBatchInsert()); // check that queue is empty. serverSQLExecute(1, "call SYS.WAIT_FOR_SENDER_QUEUE_FLUSH('WBCL1', 1, 30)"); validateResults(derbyStmt, "select * from testtable", this.netPort, true); } finally { derbyCleanup(derbyStmt, derbyConn, server); } }
Example #22
Source File: DBSynchronizerBasicDUnit.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
public void testInsertOnNonPKBasedTable() throws Exception { Statement derbyStmt = null; Connection derbyConn = null; NetworkServerControl server = null; try { String derbyDbUrl = getDerbyURL(this.netPort); server = startNetworkServer(); createDerbyValidationArtefacts(); derbyConn = DriverManager.getConnection(derbyDbUrl); derbyStmt = derbyConn.createStatement(); getLogWriter().info("Started derby network server"); startClientVMs(1, 0, null); startServerVMs(2, -1, "SG1"); getLogWriter().info("Started the accessor and datastore vms"); clientSQLExecute(1, "create table TESTTABLE (ID int not null , " + "DESCRIPTION varchar(1024) , ADDRESS varchar(1024), ID1 int )" + " AsyncEventListener (WBCL1) "); Runnable createWBCLConfig = createAsyncQueueConfigurationForBasicTests(derbyDbUrl); clientExecute(1, createWBCLConfig); Runnable startWBCL = startAsyncEventListener("WBCL1"); clientExecute(1, startWBCL); getLogWriter().info("Created and started AsyncEventListener WBCL1"); // Do an insert in sql fabric clientSQLExecute(1, "Insert into TESTTABLE values(1,'desc1','Add1',1)"); clientSQLExecute(1, "Insert into TESTTABLE values(2,'desc2','Add2',2)"); // check that queue is empty. serverSQLExecute(1, "call SYS.WAIT_FOR_SENDER_QUEUE_FLUSH('WBCL1', 1, 30)"); validateResults(derbyStmt, "select * from testtable", this.netPort, true); } finally { derbyCleanup(derbyStmt, derbyConn, server); } }
Example #23
Source File: DerbyNetworkService.java From tomee with Apache License 2.0 | 5 votes |
@Override public void start() throws ServiceException { if (this.disabled) { return; } try { this.serverControl = new NetworkServerControl(host, port); this.serverControl.start(new LoggingPrintWriter("Derby")); if (verbose) { LOGGER.info("Starting openejb-derbynet with derby " + serverControl.getRuntimeInfo() + " " + serverControl.getSysinfo()); } } catch (Exception e) { throw new ServiceException(e); } }
Example #24
Source File: ServerDatabase.java From nordpos with GNU General Public License v3.0 | 5 votes |
@Override public void start() throws Exception { server = new NetworkServerControl(InetAddress.getByName("localhost"), 1527); System.setProperty("derby.system.home", new File(new File(System.getProperty("user.home")), ".derby-db").getAbsolutePath()); java.io.PrintWriter consoleWriter = new java.io.PrintWriter(System.out, true); server.start(consoleWriter); }
Example #25
Source File: 919148_ReplicationRun_0_s.java From coming with MIT License | 5 votes |
private NetworkServerControl startServer_direct(String serverHost, String interfacesToListenOn, int serverPort, String fullDbDirPath, String securityOption) // FIXME? true/false? throws Exception { // Wotk in progress. Not currently used! Only partly tested! util.DEBUG("startServer_direct " + serverHost + " " + interfacesToListenOn + " " + serverPort + " " + fullDbDirPath); assertTrue("Attempt to start server on non-localhost: " + serverHost, serverHost.equalsIgnoreCase("localhost")); System.setProperty("derby.system.home", fullDbDirPath); System.setProperty("user.dir", fullDbDirPath); NetworkServerControl server = new NetworkServerControl( InetAddress.getByName(interfacesToListenOn), serverPort); server.start(null); pingServer(serverHost, serverPort, 150); Properties sp = server.getCurrentProperties(); sp.setProperty("noSecurityManager", securityOption.equalsIgnoreCase("-noSecurityManager")?"true":"false"); // derby.log for both master and slave ends up in masters system! // Both are run in the same VM! Not a good idea? return server; }
Example #26
Source File: 919148_ReplicationRun_0_s.java From coming with MIT License | 5 votes |
private void pingServer( String hostName, int port, int iterations) throws Exception { util.DEBUG("+++ pingServer"); ping( new NetworkServerControl(InetAddress.getByName(hostName),port), iterations); util.DEBUG("--- pingServer"); }
Example #27
Source File: 919148_ReplicationRun_0_s.java From coming with MIT License | 5 votes |
private void ping( NetworkServerControl controller, int iterations ) throws Exception { Exception finalException = null; for ( int i = 0; i < iterations; i++ ) { try { controller.ping(); util.DEBUG("Server came up in less than "+i+" * "+PINGSERVER_SLEEP_TIME_MILLIS+"ms."); return; } catch (Exception e) { finalException = e; } Thread.sleep( PINGSERVER_SLEEP_TIME_MILLIS ); } String msg = "Could not ping in " + iterations + " * " + PINGSERVER_SLEEP_TIME_MILLIS + "ms.: " + finalException.getMessage(); util.DEBUG( msg ); finalException.printStackTrace(); // REMOVE? throw new Exception(msg); }
Example #28
Source File: 919148_ReplicationRun_0_t.java From coming with MIT License | 5 votes |
private NetworkServerControl startServer_direct(String serverHost, String interfacesToListenOn, int serverPort, String fullDbDirPath, String securityOption) // FIXME? true/false? throws Exception { // Wotk in progress. Not currently used! Only partly tested! util.DEBUG("startServer_direct " + serverHost + " " + interfacesToListenOn + " " + serverPort + " " + fullDbDirPath); assertTrue("Attempt to start server on non-localhost: " + serverHost, serverHost.equalsIgnoreCase("localhost")); System.setProperty("derby.system.home", fullDbDirPath); System.setProperty("user.dir", fullDbDirPath); NetworkServerControl server = new NetworkServerControl( InetAddress.getByName(interfacesToListenOn), serverPort); server.start(null); pingServer(serverHost, serverPort, 150); Properties sp = server.getCurrentProperties(); sp.setProperty("noSecurityManager", securityOption.equalsIgnoreCase("-noSecurityManager")?"true":"false"); // derby.log for both master and slave ends up in masters system! // Both are run in the same VM! Not a good idea? return server; }
Example #29
Source File: 919148_ReplicationRun_0_t.java From coming with MIT License | 5 votes |
private void pingServer( String hostName, int port, int iterations) throws Exception { util.DEBUG("+++ pingServer"); ping( new NetworkServerControl(InetAddress.getByName(hostName),port), iterations); util.DEBUG("--- pingServer"); }
Example #30
Source File: DerbyBase.java From MyBox with Apache License 2.0 | 5 votes |
public static boolean startDerbyServer() { try { boolean portUsed = NetworkTools.isPortUsed(port); int uPort = port; if (portUsed) { if (DerbyBase.isServerStarted(port)) { logger.debug("Derby server is already started in port " + port + "."); return true; } else { uPort = NetworkTools.findFreePort(port); } } NetworkServerControl server = new NetworkServerControl(InetAddress.getByName(host), uPort, CommonValues.AppDerbyUser, CommonValues.AppDerbyPassword); status = DerbyStatus.Starting; server.start(null); // server.setTraceDirectory("d:/tmp"); server.trace(false); if (isServerStarted(server)) { port = uPort; logger.debug("Derby server is listening in port " + port + "."); status = DerbyStatus.Nerwork; return true; } else { status = DerbyStatus.NerworkFailed; return false; } } catch (Exception e) { logger.debug(e.toString()); status = DerbyStatus.NerworkFailed; return false; } }