You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-user@db.apache.org by cgloyd <cg...@tamzen.com> on 2009/11/23 19:12:54 UTC

New to Derby: Modifying Single User App to Server/Client

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.


Re: New to Derby: Modifying Single User App to Server/Client

Posted by Daniel John Debrunner <dj...@apache.org>.
Bryan Pendleton wrote:
>> Client Code:
>>
>> Properties props = System.getProperties();
> 
> I don't think you need to pass all the system properties
> to DriverManager.getConnection(). Try changing the above line to:
> 
>    Properties props = new java.util.Properties();
> 

Also set derby.system.home on the server side, not the client side.

Dan.

Re: New to Derby: Modifying Single User App to Server/Client

Posted by Bryan Pendleton <bp...@amberpoint.com>.
> Client Code:
> 
> Properties props = System.getProperties();

I don't think you need to pass all the system properties
to DriverManager.getConnection(). Try changing the above line to:

    Properties props = new java.util.Properties();

Does that help?

thanks,

bryan