db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cgloyd <cgl...@tamzen.com>
Subject New to Derby: Modifying Single User App to Server/Client
Date Mon, 23 Nov 2009 18:12:54 GMT

I'm attempting to modify a Java desktop application (with embedded Derby)
into a server/client configuration and I'm having trouble getting the client
to connect to the server.  I've been trying to follow the examples in
SimpleNetworkServerSample.java and SimpleNetworkClientSample.java but since
I'm new to both networking and Derby, I'm not sure I'm doing it correctly. 
For testing, I created an executable for the server and am running the
client from Eclipse 3.4.  I'm using Derby 10.5.3.

When I start the server, it appears to be working correctly.
======================
Server Code:
	try {    		
	    NetworkServerControl server = new NetworkServerControl
(InetAddress.getByName("localhost"),1527); 
	    server.start(null);
    	} catch (Exception e){
    		
    	}

========================
Client Code:

Properties props = System.getProperties();
props.put("derby.system.home", "C:/Apache/");
props.put("user", "user");    	 
props.put("password", "pw");

try {
	Class.forName("org.apache.derby.jdbc.ClientDriver").newInstance();
        	Connection conn =
DriverManager.getConnection("jdbc:derby://localhost:1527/MyDatabase",props);
} catch(SQLException ex) {
            System.out.println("\n ------- SQL Exception");
             while (ex != null) {
                System.out.println("Message: " + ex.getMessage()+ex);
                System.out.println("Error Code: " + ex.getErrorCode());
                ex = ex.getNextException();
                System.out.println("");
            }
}


When I try to connect, I get the error below.  This is just a sampling of
the error (the actual error is very long):

------- SQL Exception
Message: A connection could not be established because the database name
'MyDatabase;java.runtime.name=Java(TM) SE Runtime
Environment;sun.boot.library.path=C:\Program
Files\Java\jre1.6.0_05\bin;java.vm.version=10.0-b19;java.vm.vendor=Sun
Microsystems
Inc.;java.vendor.url=http://java.sun.com/;path.separator=;;java.vm.name=Java
HotSpot(TM) Client
VM;file.encoding.pkg=sun.io;user.country=US;sun.java.launcher=SUN_STANDARD;sun.os.patch.level=Service
Pack 3;java.vm.specification.name=Java Virtual Machine Specification;
...  
is larger than the maximum length allowed by the network protocol.
Error Code: 40000
=========================

I did a test case where I didn't start the server, ran the client code and
got a "server not found" error.


Thanks in advance,

Carol
-- 
View this message in context: http://old.nabble.com/New-to-Derby%3A-Modifying-Single-User-App-to-Server-Client-tp26483214p26483214.html
Sent from the Apache Derby Users mailing list archive at Nabble.com.


Mime
View raw message