473,413 Members | 1,854 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

java.sql.SQLException: No suitable driver when connecting to a DB2 database using driver COM.ibm.db2.jdbc.DB2XADataSource

Hi,

I want to get connection to a DB2 database using the driver
COM.ibm.db2.jdbc.DB2XADataSource. I have also included 'db2java.zip' in
the classpath. However I am getting the exception

java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at Conn.main(Conn.java:44)

The code that I am using (with try/catch removed) is as follows:
String url = "jdbc:db2:sample";
String driver = "COM.ibm.db2.jdbc.DB2XADataSource";
String dbuser = "db2user";
String dbpswd = "password";

Connection con = null;
if (url != null)
{
Class.forName(driver).newInstance();
if (dbuser == null || dbuser.length() == 0)
con = DriverManager.getConnection(url);
else
con = DriverManager.getConnection(url, dbuser, dbpswd);
}

I guess the url also is correct. Could anyone please let me know what
the problem is.

Thanks in advance,
Rakesh.

Nov 12 '05 #1
3 27027
The Type 2 driver is:

COM.ibm.db2.jdbc.app.DB2Driver

Dario

Nov 12 '05 #2


Rakesh wrote:
Hi,

I want to get connection to a DB2 database using the driver
COM.ibm.db2.jdbc.DB2XADataSource. I have also included 'db2java.zip' in
the classpath. However I am getting the exception

java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at Conn.main(Conn.java:44)

The code that I am using (with try/catch removed) is as follows:
String url = "jdbc:db2:sample";
String driver = "COM.ibm.db2.jdbc.DB2XADataSource";
String dbuser = "db2user";
String dbpswd = "password";

Connection con = null;
if (url != null)
{
Class.forName(driver).newInstance();
Hi. The above line succeeded. This means the driver you mentioned
was found in the class path, and loaded.
if (dbuser == null || dbuser.length() == 0)
con = DriverManager.getConnection(url);
else
con = DriverManager.getConnection(url, dbuser, dbpswd);
}

I guess the url also is correct. Could anyone please let me know what
the problem is.
The exception you get means the URL is likely *not* correct. The driver manager
went through every driver registered with it (and if the driver you cited
is written correctly, it will have registered itself with the driver manager
while it was loaded above). No driver knew how to produce a connection
with your input.
Try this code:

java.sql.Driver d = (java.sql.Driver)Class.forName(driver).newInstance ();
(simply get an instance of the driver)
System.out.println(" Does this driver accept my URL? " + d.acceptsURL(url) );

Once you've solved the URL problem, if your application is
running in a multithreaded environment, I would strongly
advise that you avoid direct DriverManager calls, including
getConnection() because they are all class-synchronized, and
this can serialize all JDBC in the whole JVM.

Joe Weinstein at BEA Systems

Thanks in advance,
Rakesh.


Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: dinesh prasad | last post by:
I'm trying to use a servlet to process a form, then send that data to an SQL server stored procedure. I'm using the WebLogic 8 App. server. I am able to retrieve database information, so I know my...
2
by: Kent Lewandowski | last post by:
hi all, Recently I wrote some stored procedures using java jdbc code (admittedly my first stab) and then tried to implement the same within java packages (for code reuse). I encountered...
8
by: Rhino | last post by:
I'm trying to use the JDBC Universal driver to get a Type 4 connection in a Java client program running under DB2 V8.2.1 but I keep getting a "connection refused: connect" message. I'm running...
2
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of...
1
by: jynxxxed | last post by:
I've been reviewing some of the threads here and applying some of the advice and still getting the same error. 15:50:26,935 INFO java.sql.SQLException: Could not find stored procedure...
2
by: astolpho | last post by:
I am using a slightly outdated reference book on J2EE programming. It gives 2 methods of creating a database used in its casestudies. The first is an ANT script that gives the following output: ...
2
by: dmstn | last post by:
Hey! I've got a little problem. I have to make a web site for a university essay. I curently have to create a search engine. Users can enter a hotel name in a search bar and results have to appear in...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.