473,695 Members | 2,627 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

java.sql.SQLExc eption: No suitable driver when connecting to a DB2 database using driver COM.ibm.db2.jdb c.DB2XADataSour ce

Hi,

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

java.sql.SQLExc eption: No suitable driver
at java.sql.Driver Manager.getConn ection(Unknown Source)
at java.sql.Driver Manager.getConn ection(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:sampl e";
String driver = "COM.ibm.db2.jd bc.DB2XADataSou rce";
String dbuser = "db2user";
String dbpswd = "password";

Connection con = null;
if (url != null)
{
Class.forName(d river).newInsta nce();
if (dbuser == null || dbuser.length() == 0)
con = DriverManager.g etConnection(ur l);
else
con = DriverManager.g etConnection(ur l, 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 27055
The Type 2 driver is:

COM.ibm.db2.jdb c.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.jdb c.DB2XADataSour ce. I have also included 'db2java.zip' in
the classpath. However I am getting the exception

java.sql.SQLExc eption: No suitable driver
at java.sql.Driver Manager.getConn ection(Unknown Source)
at java.sql.Driver Manager.getConn ection(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:sampl e";
String driver = "COM.ibm.db2.jd bc.DB2XADataSou rce";
String dbuser = "db2user";
String dbpswd = "password";

Connection con = null;
if (url != null)
{
Class.forName(d river).newInsta nce();
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.g etConnection(ur l);
else
con = DriverManager.g etConnection(ur l, 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.Drive r)Class.forName (driver).newIns tance();
(simply get an instance of the driver)
System.out.prin tln(" Does this driver accept my URL? " + d.acceptsURL(ur l) );

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
22134
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 application server can talk to the database. I've determined the failure occurs when the the following statement is executed: cstmt.execute(); (due to the failure of println statements placed afterwards). I get the following error after trying to...
2
9237
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 problems doing this. I wanted to implemented a generic "Helper" class like this: /** * Helper
8
2571
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 DB2 Personal Edition so I am trying to connect to the database SQLPROCS on this same machine. I've checked the manual and am imitating the examples as well as I can but the examples are geared to remote machines, not the local one, so I strongly...
2
6955
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 attending interviews. If you own a company best way to judge if the candidate is worth of it. http://www.questpond.com/InterviewRatingSheet.zip
1
4185
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 'getName'. I'm basically taking a variable coming to my servlet through a JSP page and using it as my search criteria. I know the stored proc will execute through query analyzer, I can execute a regular prepared statement through my servlet, so i...
2
3977
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: D:\original\CaseStudy-2-5\CaseStudy\Day02\exercise>asant database Buildfile: build.xml env-user: prop-user: set-user:
2
2616
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 another screen. All of this has to be done with java servlets. I think there's something I don't see and it's wrong. My problem is that anything I enter in the search bar appears as a result in the results page, even if there's not such a name in...
0
8639
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8582
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9120
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8832
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6496
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5841
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4348
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3016
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2279
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.