e.printStackTrace();
}
NetworkServerControl serverControl = null;
boolean started = false;
try {
serverControl = new
NetworkServerControl(InetAddress.getByName("0.0.0.0"),
NETWORKSERVER_PORT);
serverControl.start(new PrintWriter(System.out,true));
for (int i = 1; i < 50; i++)
{
Thread.sleep(1000);
if (isServerStarted(serverControl))
{
started = true;
break;
}
}
} catch (Exception e)
{
e.printStackTrace();
}
if(started)
dbg("NetworkServer started");
else
{
System.out.println("FAIL Network Server did not start");
return;
}
String hostName = TestUtil.getHostName();
String jdbcUrlPrefix = TestUtil.getJdbcUrlPrefix(hostName, NETWORKSERVER_PORT);
String url = jdbcUrlPrefix + databaseFileName;
Connection connection = null;
try {
// Just connect, do something and close the connection
connection = DriverManager.getConnection(url, "user", "password");
Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery("Select tablename from sys.systables");
while (rs.next())
{
rs.getString(1);
}
rs.close();
dbg("Connected to database " + databaseFileName);
// Leave the connection open before shutdown to make
// sure the thread closes down.
// connection.close();
System.out.println("getting ready to shutdown");
serverControl.shutdown();
Thread.sleep(5000);
} catch (Exception e) {
System.out.print("FAIL: Unexpected exception" + e.getMessage());
e.printStackTrace();