File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Database Connection Fails Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Database Connection Fails" Watch "Database Connection Fails" New topic

Database Connection Fails

Michael Scott
Ranch Hand

Joined: Jan 20, 2003
Posts: 57
When the code below runs, the connect() method fails with an SQLSTATE of 08004 and the following error occurs:
NO_SUITABLE_DRIVER Unable to load DAMessages
I've verified that the username and password are correct and that the following packages are imported:
import java.sql.*;
I'd appreciate any ideas on why the connection fails. Thanks.
private getCRDatastore() {
return crDatastore;
public void connectCurrentDatastore() throws {
String serverURL = new String("jdbc b2:tsoca");
java.util.Properties userInfo = new java.util.Properties();
String username = new String("myUsername");
pw = "myPW";
userInfo.put("user", username.toString());
userInfo.put("password", pw);
try {
getCRDatastore().connect(); // <=== ERROR
} catch ( x) {
try {
if (x.getSQLException().getSQLState().equals("08004"))
< code continues >
Murali Nanchala
Ranch Hand

Joined: Mar 14, 2001
Posts: 74
Check if* is in your classpath. Since you are essentially doing a type code in using , it will not throw any compiler errors if you are missing the library.
[ May 20, 2003: Message edited by: Murali Nanchala ]

"It is almost always answered in the API" - Murali Nanchala
Michael Scott
Ranch Hand

Joined: Jan 20, 2003
Posts: 57
I'm not sure that I understand your response. I have verified that* is in the classpath but the error still occurs.
Michael Scott
Ranch Hand

Joined: Jan 20, 2003
Posts: 57
I should clarify that I'm trying to run my applet in an IDE called VisualAge. The class of the applet is in the same directory as the DB2 classes. I have one further question though. I've read a number of forum entries suggesting that some JDBC connection problems can be resolved by running the usejdbc2.bat file in the java12 directory after first shutting down all DB2 services. Is it possible that this might resolve the connection problem that I've described? I'm reluctant to run usejdbc2.bat simply because I can now establish a database connection through DB2 and do not want to lose this capability. Any suggestions?
Thanks very much.
I agree. Here's the link:
subject: Database Connection Fails
It's not a secret anymore!