In my projects, I use the PServerConnection(CVSRoot )
constructor. Then I
set the password and username. Then I call verify(). Once
I've done that,
I pass the Object to my methods that need to use the
connection. You don't
use the connection to perform any actions directly, you use
a Client
instance. So follow my example of creating the connection,
then pass the
connection to your Client constructor. I'll try to sketch
it out below with
some code. This is from actual code, so don't worry about
some of the
methods that are called (like getUsername() and
getEncryptedPassword()).
PServerConnection p = new PServerConnection(_cvsRoot);
p.setEncodedPassword(getEncryptedPassword());
if (getUsername() != null)
{
p.setUserName(getUsername());
}
p.verify();
Client c = new Client(p, _adminHandler);
// Create your Command instance
// Execute your command (i.e. c.executeCommand(......)
Obviously you would want to put the Connection setup stuff
in its own method
(like connect()) and call that from the Client constructor
or wherever you
see fit.
-David
-----Original Message-----
From: news [mailto:news sea.gmane.org] On Behalf Of Vic Rowan
Sent: Wednesday, March 01, 2006 9:20 AM
To: dev javacvs.netbeans.org
Subject: [javacvs-dev] Unable to open connection using
PServerConnection
class
Hi...
I am using the PSserverConnection class
(org.netbeans.lib.cvsclient.connection.PServerConnection) to
connect to the
CVS, but I am getting a Null Pointer Exception when I try to
open a
connection using the open method.
As per the API if there is a problem it throws either an
AuthenticationException or CommandAbortedException, but
instead its throwing
a Null Pointer Exception and I cant figure out what I am
doing wrong.
I am really having too much trouble using this API. I dont
think there is
even an API reference publicly available to start with, but
now that I have
it, courtesy somebody who took the trouble of emailing it to
me, now I dont
think the API does what it says.
Any help would be appreciated. Below is the code I am using
to connect to
the CVS.
cheers,
Vic.
PServerConnection c = null;
try {
c = new PServerConnection();
c.setUserName("username");
c.setEncodedPassword("AAd!b=?!");
c.setHostName("ServerName");
c.setRepository("/jdev/cvs/");
if(c != null)
c.open(); // -->Exception occurs here
else
System.out.println("Connection object
NULL!");
}catch (Exception ex) {
ex.printStackTrace();
System.out.println(ex.getMessage());
}
------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribe javacvs.netbeans.org
For additional commands, e-mail: dev-help javacvs.netbeans.org
------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribe javacvs.netbeans.org
For additional commands, e-mail: dev-help javacvs.netbeans.org
|