Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DriverManager.getConnection never returns

Status
Not open for further replies.

jem122974

Programmer
Nov 1, 2001
114
US
I have the following method to connect to our DB2 database. If the username and password passed in are valid then it works fine, but if they are not it gets stuck on the second getConnection. What am I missing?

Code:
	private Connection setupDB2Connection(String username, String password) throws SQLException {
        if (connDB2!=null) {
            if(!connDB2.isClosed()) {
                connDB2.close();
                connDB2 = null;
            }
        }

		DriverManager.registerDriver(new com.ibm.as400.access.AS400JDBCDriver());
	
		if (username == null || password == null) {
			connDB2 = DriverManager.getConnection("jdbc:as400://EJDEV;prompt=true");
		}
		else {	
	        connDB2 = DriverManager.getConnection("jdbc:as400://EJDEV;", username, password);
		}
        
        return connDB2;
	}
 
Does your db support not passing user & passwords ?

What does "prompt=true" mean ? To me, that is like saying "read the user & password from stdin" or something - so the driver is probably waiting on a readLine() from the IO stream, but because you never give in the next line, it will just hang. Just guessing ... you need to consult your driver's documentation.

--------------------------------------------------
Free Database Connection Pooling Software
 
The prompt=true cause a little window to pop up for them to log in with. My app should never get there because they key their username and password on a JSP screen.

After a little more testing I have found that this works fine under Tomcat on the AS400. It is just getting stuck under the Websphere Application Server Express 5.1 running in the WDSc.
 
The solution to this problem was adding prompt=false to my second url. It was trying to connect with the username and password provided and when that didn't work it was putting a window up to prompt the user. The problem was this window was coming up under the browser window, so I never saw it. Once I added the prompt=false it tried once and then through the expected exception.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top