aspose file tools*
The moose likes JDBC 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
Bookmark "Database Connection Fails" Watch "Database Connection Fails" New topic
Author

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:
com.ibm.ivj.eab.dab.DAException:
NO_SUITABLE_DRIVER Unable to load DAMessages
ResourceBundle.COM.ibm.db2.jdbc.app.DB2Driver
I've verified that the username and password are correct and that the following packages are imported:
import java.sql.*;
import com.ibm.ivj.eab.dab.*;
import COM.ibm.db2.jdbc.app.*;
I'd appreciate any ideas on why the connection fails. Thanks.
_______________________________________________
private com.ibm.ivj.eab.dab.DatastoreJDBC getCRDatastore() {
return crDatastore;
}
public void connectCurrentDatastore() throws com.ibm.ivj.eab.dab.DAException {
getCRDatastore().setDriver("COM.ibm.db2.jdbc.app.DB2Driver");
String serverURL = new String("jdbc b2:tsoca");
getCRDatastore().setURL(serverURL);
java.util.Properties userInfo = new java.util.Properties();
String username = new String("myUsername");
pw = "myPW";
userInfo.put("user", username.toString());
userInfo.put("password", pw);
getCRDatastore().setProperties(userInfo);
try {
getCRDatastore().connect(); // <=== ERROR
} catch (com.ibm.ivj.eab.dab.DAException x) {
try {
if (x.getSQLException().getSQLState().equals("08004"))
:
< code continues >
Murali Nanchala
Ranch Hand

Joined: Mar 14, 2001
Posts: 74
Check if COM.ibm.db2.jdbc.app.* 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 COM.ibm.db2.jdbc.app.* 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.
 
 
subject: Database Connection Fails