本文整理汇总了Java中org.apache.derby.drda.NetworkServerControl.start方法的典型用法代码示例。如果您正苦于以下问题:Java NetworkServerControl.start方法的具体用法?Java NetworkServerControl.start怎么用?Java NetworkServerControl.start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.derby.drda.NetworkServerControl
的用法示例。
在下文中一共展示了NetworkServerControl.start方法的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: 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))");
}
}
}
示例3: 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));
}
}
示例4: 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);
}
}
示例5: 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);
}
示例6: 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
}
示例7: 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))");
}
}
}
示例8: start
import org.apache.derby.drda.NetworkServerControl; //导入方法依赖的package包/类
@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);
}
示例9: start
import org.apache.derby.drda.NetworkServerControl; //导入方法依赖的package包/类
/**
* Method will start derby server
*
* @throws Exception exception
*/
public void start() throws Exception {
if (!isServerRunning()) {
networkServerControl = new NetworkServerControl();
networkServerControl.start(null);
isServerStarted = true;
log.info("Derby Database Server started");
}
}
示例10: setupDefaultTestCluster
import org.apache.derby.drda.NetworkServerControl; //导入方法依赖的package包/类
@BeforeClass
public static void setupDefaultTestCluster() throws Exception {
System.setProperty("derby.drda.startNetworkServer", "true");
server = new NetworkServerControl(InetAddress.getByName("localhost"),
20000,
"admin",
"admin");
java.io.PrintWriter consoleWriter = new java.io.PrintWriter(System.out, true);
server.start(consoleWriter);
BasicDataSource source = new BasicDataSource();
source.setUrl("jdbc:derby://localhost:20000/memory:testDB;create=true");
source.setDriverClassName("org.apache.derby.jdbc.ClientDriver");
final String insertValues1 = "INSERT INTO person VALUES (1, 'Smith', null, '{number:\"123 Main\"}','mtrx', "
+ "'xy', 333.333, 444.444, 555.00, TIME('15:09:02'), DATE('1994-02-23'), TIMESTAMP('1962-09-23 03:23:34.234'),"
+ " 666.66, 1, -1, false)";
final String insertValues2 = "INSERT INTO person (PersonId) VALUES (null)";
try (Connection c = source.getConnection()) {
c.createStatement().execute("CREATE TABLE person\n" +
"(\n" +
"PersonID int,\n" +
"LastName varchar(255),\n" +
"FirstName varchar(255),\n" +
"Address varchar(255),\n" +
"City varchar(255),\n" +
"Code char(2),\n" +
"dbl double,\n" +
"flt float,\n" +
"rel real,\n" +
"tm time,\n" +
"dt date,\n" +
"tms timestamp,\n" +
"num numeric(10,2), \n" +
"sm smallint,\n" +
"bi bigint,\n" +
"bool boolean\n" +
")");
c.createStatement().execute(insertValues1);
c.createStatement().execute(insertValues2);
c.createStatement().execute(insertValues1);
}
BaseTestQuery.setupDefaultTestCluster();
}
示例11: 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();
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;
// Use two different methods to detect when server is started:
// 1) Check the server stdout for the "started" string
// 2) wait up to 15 seconds for the derby server to start based on a ping
// on faster machines and networks, this may return very quick, but on slower
// 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);
readTableName = JdbcTestHelper.getTableName("UT_READ");
JdbcTestHelper.createDataTable(dataSource, readTableName);
addInitialData(dataSource, readTableName);
}
示例12: afterPropertiesSet
import org.apache.derby.drda.NetworkServerControl; //导入方法依赖的package包/类
@Override
public void afterPropertiesSet() throws Exception {
server = new NetworkServerControl();
server.start (null);
}
示例13: derbyServer
import org.apache.derby.drda.NetworkServerControl; //导入方法依赖的package包/类
@Bean(destroyMethod = "shutdown")
public NetworkServerControl derbyServer() throws Exception {
NetworkServerControl nsc = new NetworkServerControl(InetAddress.getByName("localhost"), 1527);
nsc.start(new PrintWriter(java.lang.System.out, true));
return nsc;
}
开发者ID:mpostelnicu,项目名称:wicket-spring-jpa-bootstrap-boilerplate,代码行数:7,代码来源:DatabaseConfiguration.java
示例14: run
import org.apache.derby.drda.NetworkServerControl; //导入方法依赖的package包/类
/**
* @param s
*/
public void run(String... s) {
String dir = "../data";
if (s.length == 1) {
dir = s[0];
}
String driver = "org.apache.derby.jdbc.ClientDriver";
System.setProperty("derby.system.home", dir);
String dbName = "easyjweb";
String connectionURL = "";
File f = new File(dir);
boolean b = false;
if (f.exists()) {
b = true;
connectionURL = "jdbc:derby://localhost:1527/" + dbName
+ ";user=easyjf;pwd=easyjf;create=false;";
} else {
b = false;
connectionURL = "jdbc:derby://localhost:1527/" + dbName
+ ";user=easyjf;pwd=easyjf;create=true;";
}
try {
NetworkServerControl derbyServer = new NetworkServerControl();
PrintWriter pw = new PrintWriter(System.out);
derbyServer.start(pw);
Class.forName(driver);
Connection conn = DriverManager.getConnection(connectionURL);// 本地连接数据库
Statement st = conn.createStatement();
if (!b) {
st
.execute("create table easyjweb (version varchar(30) not null)");
st.executeUpdate("insert into easyjweb values ('"+Globals.VERSION+"')");
}
ResultSet rs = st.executeQuery("select * from easyjweb");// 读取刚插入的数据
while (rs.next()) {
rs.getString(1);
// System.out.println("当前EasyJWeb 版本 " +
// version);
}
System.out.println(I18n.getLocaleMessage("ext.Successful.launch.of.the.database.server"));
System.out.println(I18n.getLocaleMessage("ext.Press.Ctrl+C.button.or.the.Enter.key.stop.service"));
BufferedReader in = new BufferedReader(new InputStreamReader(
System.in));
in.readLine();
} catch (Exception ex) {
ex.printStackTrace();
}
}
示例15: setUp
import org.apache.derby.drda.NetworkServerControl; //导入方法依赖的package包/类
protected void setUp() throws Exception {
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
}