HSQLdb server creation problem
I have rattled my brain on this now for a few days. i have searched hi and low, and cant find an example on creating a server for the Data base HSQLdb,
there is the code that i am using, the problem is it always returns as the discriptor "shutdown" and i dont know what i am doing wrong,
thus NO client can connect to it,
publicvoid setUp ()
{
try
{
Class.forName ("org.hsqldb.jdbcDriver");
// Connection c = DriverManager.getConnection (urlr, user, password);
}
catch (Exception e)
{
e.printStackTrace ();
}
String db_name ="mydb";
String serverProps;
String url ="jdbc:hsqldb:file:mydb";
String user="sa";
String password ="";
System.out.println ("network mode");
server =new Server ();
server.setRestartOnShutdown (true);
server.setDatabaseName (0, db_name);
server.setDatabasePath (0, url);
server.setLogWriter (null);
server.setErrWriter (null);
server.start ();
//server.setPort (5000);
//server.start();
System.out.println (server.getStateDescriptor ());
System.out.println (server.getAddress ());
String urlr ="jdbc:hsqldb:hsql://localhost:mydb";
try
{
Class.forName ("org.hsqldb.jdbcDriver");
Connection c = DriverManager.getConnection (urlr, user, password);
}
catch (Exception e)
{
e.printStackTrace ();
}
}
can any one please help me out? with a link to a code on setting up a server? or any thing, i just find lots of code to make the clients (that i can do) but his server thing is just not working.
Thanks
David
[2594 byte] By [
Nibura] at [2007-11-27 11:57:47]

# 2
java -classpath hsqldb.jar org.hsqldb.Server
Once again i tried the demo code for server creation, and well it works,
there must be somthing wrong with the way that I am calling the server? or not starting to correctly,
also i would really not like to use the "test" data base, and i would like some other stuff to happen before and after you shut down the server, that is why i need to create it using my own code?
any ideas? I am using netbeans, windows, but that should make a difference because it compiles and finds the lib's,.,,
Nibura at 2007-7-29 19:15:57 >

# 4
multiple clients,
also i would like the abilty to like shutdown the server, and then the clients cant access it..
The problem is i have an example code froma downloaded applicaton, and they seem to be using the same code as me, the only difference is i am launching mine from netbeans, OR the .jar file, and theirs had all the .class files with a .bat script.
Thanks.
can any one else try this code and see if they also get the same "shutdown"
import java.sql.Connection;
import java.sql.DriverManager;
import org.hsqldb.*;
/**
*/
public class MyServer
{
int port = 5000;
String db_name = "mydb";
String serverProps;
String url = "jdbc:hsqldb:file:/lib/database/mydb";
String user= "sa";
String password = "";
Connection c = null;
Server server;
public MyServer() {
setUp();
}
protected void setUp() {
try {
Class.forName("org.hsqldb.jdbcDriver");
} catch (Exception e) {
e.printStackTrace();
System.out.println(this + ".setUp() error: " + e.getMessage());
}
server = new Server();
//server.setDatabaseName(0, db_name);
// server.setDatabasePath(0, url);
server.setLogWriter(null);
server.setErrWriter(null);
// server.setPort(port);
server.start();
System.out.println (server.getStateDescriptor ());
}
public static void main(String[] args) {
new MyServer();
}
}
null
Message was edited by:
Nibur
Nibura at 2007-7-29 19:15:57 >
