Search in sources :

Example 1 with NetworkServerControl

use of org.apache.derby.drda.NetworkServerControl in project midpoint by Evolveum.

the class DerbyController method start.

public void start() throws Exception {
    LOGGER.info("Starting Derby embedded network server " + listenHostname + ":" + listentPort + ", database " + dbName);
    listenAddress = InetAddress.getByName(listenHostname);
    jdbcUrl = "jdbc:derby:" + dbName + ";create=true;user=" + username + ";password=" + password;
    server = new NetworkServerControl(listenAddress, listentPort);
    System.setProperty("derby.stream.error.file", "target/derby.log");
    server.start(null);
}
Also used : NetworkServerControl(org.apache.derby.drda.NetworkServerControl)

Example 2 with NetworkServerControl

use of org.apache.derby.drda.NetworkServerControl in project beam by apache.

the class JdbcIOTest method startDatabase.

@BeforeClass
public static void startDatabase() throws Exception {
    ServerSocket socket = new ServerSocket(0);
    port = socket.getLocalPort();
    socket.close();
    LOG.info("Starting Derby database on {}", port);
    System.setProperty("derby.stream.error.file", "target/derby.log");
    derbyServer = new NetworkServerControl(InetAddress.getByName("localhost"), port);
    StringWriter out = new StringWriter();
    derbyServer.start(new PrintWriter(out));
    boolean started = false;
    int count = 0;
    // networks where the DNS lookups are slow, this may take a little time
    while (!started && count < 30) {
        if (out.toString().contains("started")) {
            started = true;
        } else {
            count++;
            Thread.sleep(500);
            try {
                derbyServer.ping();
                started = true;
            } catch (Throwable t) {
            //ignore, still trying to start
            }
        }
    }
    dataSource = new ClientDataSource();
    dataSource.setCreateDatabase("create");
    dataSource.setDatabaseName("target/beam");
    dataSource.setServerName("localhost");
    dataSource.setPortNumber(port);
    JdbcTestDataSet.createReadDataTable(dataSource);
}
Also used : StringWriter(java.io.StringWriter) NetworkServerControl(org.apache.derby.drda.NetworkServerControl) ClientDataSource(org.apache.derby.jdbc.ClientDataSource) ServerSocket(java.net.ServerSocket) PrintWriter(java.io.PrintWriter) BeforeClass(org.junit.BeforeClass)

Example 3 with NetworkServerControl

use of org.apache.derby.drda.NetworkServerControl in project tomee by apache.

the class DerbyNetworkService method start.

@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);
    }
}
Also used : ServiceException(org.apache.openejb.server.ServiceException) NetworkServerControl(org.apache.derby.drda.NetworkServerControl) LoggingPrintWriter(org.apache.openejb.util.LoggingPrintWriter) IOException(java.io.IOException) ServiceException(org.apache.openejb.server.ServiceException)

Example 4 with NetworkServerControl

use of org.apache.derby.drda.NetworkServerControl in project ocvn by devgateway.

the class DatabaseConfiguration method derbyServer.

/**
     * Graciously starts a Derby Database Server when the application starts up
     * 
     * @return
     * @throws Exception
     */
@Bean(destroyMethod = "shutdown")
public NetworkServerControl derbyServer() throws Exception {
    Properties p = System.getProperties();
    p.put("derby.storage.pageCacheSize", "30000");
    p.put("derby.language.maxMemoryPerTable", "20000");
    NetworkServerControl nsc = new NetworkServerControl(InetAddress.getByName("localhost"), derbyPort);
    nsc.start(new PrintWriter(java.lang.System.out, true));
    return nsc;
}
Also used : NetworkServerControl(org.apache.derby.drda.NetworkServerControl) Properties(java.util.Properties) PoolProperties(org.apache.tomcat.jdbc.pool.PoolProperties) PrintWriter(java.io.PrintWriter) Bean(org.springframework.context.annotation.Bean)

Aggregations

NetworkServerControl (org.apache.derby.drda.NetworkServerControl)4 PrintWriter (java.io.PrintWriter)2 IOException (java.io.IOException)1 StringWriter (java.io.StringWriter)1 ServerSocket (java.net.ServerSocket)1 Properties (java.util.Properties)1 ClientDataSource (org.apache.derby.jdbc.ClientDataSource)1 ServiceException (org.apache.openejb.server.ServiceException)1 LoggingPrintWriter (org.apache.openejb.util.LoggingPrintWriter)1 PoolProperties (org.apache.tomcat.jdbc.pool.PoolProperties)1 BeforeClass (org.junit.BeforeClass)1 Bean (org.springframework.context.annotation.Bean)1