You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by bu...@apache.org on 2003/07/10 01:15:33 UTC

DO NOT REPLY [Bug 21453] New: - NullPointerException in DBCP when used for client-server applications

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=21453>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=21453

NullPointerException  in DBCP when used for client-server applications

           Summary: NullPointerException  in DBCP when used for client-
                    server applications
           Product: Commons
           Version: Nightly Builds
          Platform: PC
               URL: http://http://
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Major
          Priority: Other
         Component: Dbcp
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: vanitas@xentel.com


Nullpointerexception with the below JNDI settings for client-server app
My Server java file:

private static String connectURI = "jdbc:sapdb://LOCALHOST/mydb";
private static String username = "myusername";
private static String password = "mypassword";

Properties env = new Properties();
env.put(Context.SECURITY_AUTHENTICATION,"simple");
env.put(Context.REFERRAL,"follow");
env.put(Context.SECURITY_PRINCIPAL, "cn=myname");
env.put(Context.SECURITY_CREDENTIALS,"mypassword");
env.put("com.sun.jndi.ldap.connect.pool", "true");
env.put("databaseName", "mydb");
env.put("user", username);
env.put("password", password);
env.put("url", connectURI);
env.put("driver", "com.sap.dbtech.jdbc.DriverSapDB");
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, "ldap://localhost:389/");
Context ctx = new InitialContext(env);

DriverAdapterCPDS cpds = new DriverAdapterCPDS();
cpds.setUrl(connectURI);
cpds.setUser(username);
cpds.setPassword(password);
cpds.setMaxActive(6);
cpds.setDriver("com.sap.dbtech.jdbc.DriverSapDB");
String dsbindString = "cn=cpd,ou=JavaObjects,dc=mycompany,dc=com";
ctx.rebind(dsbindString, cpds);

Jdbc2PoolDataSource tds = new Jdbc2PoolDataSource();
tds.setJndiEnvironment
(ctx.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
tds.setJndiEnvironment(ctx.PROVIDER_URL, "ldap://localhost:389/");
tds.setDefaultMaxActive(3);
tds.setDataSourceName(dsbindString);
String pooldsbindString 
= "cn=SapdbDSApacheJdbc,ou=JavaObjects,dc=mycompany,dc=com";
ctx.rebind(pooldsbindString,tds);


My Client java file:

private static String connectURI = "jdbc:sapdb://LOCALHOST/mydb";
private static String username = "myusername";
private static String password = "mypassword";

String pooldsbindString 
= "cn=SapdbDSApacheJdbc,ou=JavaObjects,dc=mycompany,dc=com";
Properties env2 = new Properties();
env2.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env2.put(Context.PROVIDER_URL, "ldap://localhost:389/");
env2.put(Context.SECURITY_AUTHENTICATION,"simple");
env2.put(Context.REFERRAL,"follow");
env2.put(Context.SECURITY_PRINCIPAL, "cn=myname");
env2.put(Context.SECURITY_CREDENTIALS,"mypassword");
env2.put("com.sun.jndi.ldap.connect.pool", "true");
env2.put("databaseName", "mydb");
env2.put("user", username);
env2.put("password", password);
env2.put("url", connectURI);
env2.put("driver", "com.sap.dbtech.jdbc.DriverSapDB");
DirContext ctx2 = new InitialDirContext(env2);
Jdbc2PoolDataSource ref = (Jdbc2PoolDataSource)ctx2.lookup(pooldsbindString);

Connection cn = (Connection)ref.getConnection(username,password);
Statement stmt = cn.createStatement();

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org