本文整理汇总了Java中org.apache.derby.drda.NetworkServerControl类的典型用法代码示例。如果您正苦于以下问题:Java NetworkServerControl类的具体用法?Java NetworkServerControl怎么用?Java NetworkServerControl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NetworkServerControl类属于org.apache.derby.drda包,在下文中一共展示了NetworkServerControl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startNetworkServer
import org.apache.derby.drda.NetworkServerControl; //导入依赖的package包/类
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;
}
示例2: waitForStart
import org.apache.derby.drda.NetworkServerControl; //导入依赖的package包/类
@SuppressWarnings("static-access")
private void waitForStart() throws Exception
{
org.apache.derby.drda.NetworkServerControl server = new NetworkServerControl();
// javaDBClient.log("JavaDB Database Server Waiting for Completion...", true, true, true);
log("JavaDB Database Server Waiting for Completion...");
boolean dbserverok = false;
int counter = 0;
do
{
// try { Thread.currentThread().sleep(100); server.ping(); } catch (Exception e) { myUserInterface.showStatus("Try #" + counter + " " +e.toString(), true, true); }
// try { Thread.currentThread().sleep(100); networkServerControl.ping(); } catch (Exception e) { javaDBClient.log("Try #" + counter + " " +e.toString(), true, true, true); }
try { Thread.currentThread().sleep(100); networkServerControl.ping(); } catch (Exception e) { log("Try #" + counter + " " +e.toString()); }
counter++;
} while ((!dbserverok) && (counter<20));
// javaDBClient.log("JavaDB Database Server Running", true, true, true);
// javaDBClient.log("db_server_started", true, true, true);
log("JavaDB Database Server Running");
}
示例3: startDatabase
import org.apache.derby.drda.NetworkServerControl; //导入依赖的package包/类
@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))");
}
}
}
示例4: startDbServer
import org.apache.derby.drda.NetworkServerControl; //导入依赖的package包/类
/**
* Start the database server. If it was running, stop it first.
*/
public static void startDbServer() {
System.setProperty("derby.drda.startNetworkServer", "true");
stopDbServer();
try {
dbServer = new NetworkServerControl(
InetAddress.getByName("localhost"), 15270, user,
password);
java.io.PrintWriter consoleWriter = new java.io.PrintWriter(
System.out, true);
dbServer.start(consoleWriter);
checkForDatabase();
} catch (Exception e) {
LOGGER.error(ExceptionUtils.getStackTrace(e));
}
}
示例5: isServerStarted
import org.apache.derby.drda.NetworkServerControl; //导入依赖的package包/类
private static boolean isServerStarted(NetworkServerControl server, int ntries)
{
for (int i = 1; i <= ntries; i ++)
{
try {
Thread.sleep(500);
server.ping();
return true;
}
catch (Exception e) {
if (i == ntries)
return false;
}
}
return false;
}
示例6: main
import org.apache.derby.drda.NetworkServerControl; //导入依赖的package包/类
public static void main(String... args) throws Exception {
final NetworkServerControl serverControl = new NetworkServerControl(InetAddress.getByName("0.0.0.0"), 1527);
final PrintWriter pw = new PrintWriter(System.out, true);
new Thread(new Runnable() {
@Override
public void run() {
try {
serverControl.start(pw);
} catch (Exception e) {
LOGGER.error("Exception while running the database server", e);
throw new RuntimeException("Exception while running the database server", e);
}
}
}).start();
}
示例7: startNetworkDBServer
import org.apache.derby.drda.NetworkServerControl; //导入依赖的package包/类
/**
*
*/
@Override
public void startNetworkDBServer() {
try {
debugOut("Start Network DB Server.");
dbServer = new NetworkServerControl(InetAddress.getByName("localhost"), 1528);
dbServer.start(null);
} catch (Exception ex) {
Logger.getLogger(CanRegServerImpl.class.getName()).log(Level.SEVERE, null, ex);
}
}
示例8: waitForDerbyInitialization
import org.apache.derby.drda.NetworkServerControl; //导入依赖的package包/类
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);
}
}
}
示例9: testBasicInsert
import org.apache.derby.drda.NetworkServerControl; //导入依赖的package包/类
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);
}
}
示例10: testBatchInsert
import org.apache.derby.drda.NetworkServerControl; //导入依赖的package包/类
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);
}
}
示例11: testInsertOnNonPKBasedTable
import org.apache.derby.drda.NetworkServerControl; //导入依赖的package包/类
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);
}
}
示例12: startNetworkServer
import org.apache.derby.drda.NetworkServerControl; //导入依赖的package包/类
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();
}
示例13: start
import org.apache.derby.drda.NetworkServerControl; //导入依赖的package包/类
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);
}
示例14: setUp
import org.apache.derby.drda.NetworkServerControl; //导入依赖的package包/类
@Before
public void setUp() throws Exception
{
TimeProvider.clear();
System.setProperty("derby.system.home", "db");
server = new NetworkServerControl(InetAddress.getByName("localhost"),1527, "me", "mine");
server.start(null);
ThreadUtils.sleep(500); // give time for db to startup
}
示例15: startDatabase
import org.apache.derby.drda.NetworkServerControl; //导入依赖的package包/类
@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))");
}
}
}