I have a j2ee application deployed on WAS. I use following code to connect to db2 database and it throws "No Suitable Driver found" exception. I have created a shared lib on WAS and have included db2jcc4.jar in the shared lib. Added a reference to it in my application.
DriverManager.getConnection("jdbc:db2://host:port/dbname", "user", "password");
Do I need to do anything else? Any other jar I need to put in the shared lib? or any other way of putting the jar in classpath?
Appreciate your help
SystemAdmin 110000D4XK1731 Posts
Re: No suitable driver2011-05-28T05:34:09ZThis is the accepted answer. This is the accepted answer.HI suma...
I am sathya working as filenet developer.
Below is the sample code to connect DB2,
Connection conn = DriverManager.getConnection("jdbc:db2://demo1:50000/OBJST1", "db2admin", "database1");
if (conn == null)
System.out.println(" Connection success ");
DriverManager.getConnection("jdbc:db2://<host name>:<DB2 port number>/<data base name>", "<user name>", "<password>");
jar files in classpath:
i thought that , above are the enough precautions to get the connection from DB2, i hope that it is very help full to you.
SumaGS 120000QT942 Posts
Re: No suitable driver2011-05-28T14:16:43ZThis is the accepted answer. This is the accepted answer.
- SystemAdmin 110000D4XK
Thanks for the response.
I always tried with the following code.
Connection conn = DriverManager.getConnection("url", "db2admin", "database1");
I did not load the driver explicitly. It worked fine for weblogic + db2, weblogic + oracle, WAS + oracle.
I see "No suitable driver" error only for WAS + DB2 combination.
But when I load the Driver explicitly, I was able to get the connection. Wondering why explicit loading is required only for WAS + DB2 combination.