Forum Controls
Spotlight Features

The Rich Engineering Heritage Behind Dependency Injection

Andrew McVeigh takes us on a tour of the rich heritage behind dependency injection, what it represents, and tells us why its here to stay.

Java, the OLPC, and community responsibility

The "One Laptop Per Child" project has a great device ready to ship, but there's no Java on there. Let's think about working together to put Java on OLPC!
Replies: 0 - Pages: 1  
Threads: [ Previous | Next ]
  Click to reply to this thread Reply

IConnectionProfile.createConnection(factor,u,p) ignores u & p

At 8:40 AM on Apr 9, 2008, Gregory Smith Javalobby Newcomers wrote:

My experiement indicates that IConnectionProfile.createConnection(f,u,p) ignores the u, p and always grabs them from the base properties (at least via the Oracle and Derby providers).

Am I missing something obvious?

Example:

If the setBaseProperties() call is commented out, changing the username/password has no effect.

Properties prop = connectionProfile.getBaseProperties();
prop.setProperty( PROP_USERNAME, username==null?"":username);
prop.setProperty( PROP_PASSWORD, password==null?"":password);
connectionProfile.setBaseProperties(prop);

String factoryId = connectionProfile.getProvider().getConnectionFactory("java.sql.Connection").getId();
con = connectionProfile.createConnection(factoryId,(username==null?"":username), (password==null?"":password));

//
// con will be non null even if a corresponding java.sql.Connection was not created.
//
Object rawConnection = con.getRawConnection();
Throwable e = con.getConnectException();

con.close();

if( rawConnection != null && e==null) { return; } // Connection OK

throw new Exception( e==null?"Unspecified connection error":e.getMessage());

thread.rss_message