Hi,
I am trying to make a UBD DB2 7.2 connection using the Java
COM.ibm.db2.jdb c.app.DB2Driver via Tomcat 3.2.1 on Solaris (and also
on an AIX system with 3.3.1). I am attempting this either via JSP or
a servlet.
I have a separate java application that I can run from the command
line and as long as the user has the correct env variables:
DB2DIR=/opt/IBMdb2/V7.1
DB2INSTANCE=rep owner
INSTHOME=/home/repowner
Then the connection is fine. I am using the same code to try and make
the connection via tomcat.
try
{
Class.forName(" COM.ibm.db2.jdb c.app.DB2Driver ");
// next line is printed out
System.out.prin tln(new java.util.Date( ).toString() + " DRIVER
FOUND.");
}
catch(ClassNotF oundException e)
{
System.out.prin tln(new java.util.Date( ).toString() + " Error 1:
"+e);
}
String dbType="db2";
// String ip="10.0.0.185" ;
// String port="8790";
String dbName="pprepor t";
String reason="testing db connection";
String userName="repow ner";
String password="ilink 1";
Connection con = null;
String url = "jdbc:db2:"+dbN ame;
boolean dbConnected = false;
try
{
System.out.prin tln(new java.util.Date( ).toString() + " Connecting
to database URL = " + url + " for " + reason);
Enumeration e = DriverManager.g etDrivers();
while (e.hasMoreEleme nts()) {
Driver d = (Driver) e.nextElement() ;
// doesn't print anything here
System.out.prin tln("driver is " + d.toString());
}
System.out.prin tln("a1");
// gets to here and stops!
Driver d = DriverManager.g etDriver(url);
System.out.prin tln("a1.1"+d.to String());
con = DriverManager.g etConnection(ur l, userName, password);
java.sql.Statem ent stmt = con.createState ment();
System.out.prin tln("SETTING SCHEMA TO "+dbName);
try {
stmt.execute("S ET SCHEMA = "+dbName);
System.out.prin tln("SCHEMA SET.");
}
catch (Exception ex) {
System.out.prin tln("Error Setting Schema:"+ex);
}
System.out.prin tln(new java.util.Date( ).toString() + " Database
connection established.XX" );
dbConnected = true;
}
catch(Exception e)
{
System.out.prin tln(new java.util.Date( ).toString() + " Failed to
connect, reason : \n" + e);
}
However via tomcat the driver cannot be loaded by the class loader.
The class is found, but not loaded. The error I receive is
"java.sql.SQLEx ception: No suitable driver"
I have placed the db2java.zip (renamed as db2java.jar) in several
places to try and solve the problem (restarting Tomcat each time) but
to no avail:
/usr/apache/tomcat/common/lib/db2java.jar
..../WEB-INF/classes/db2java.jar
I have read many posts, but I can't understand how the driver will
know the correct env variables even if the class is loaded.
Any help would be much appreciated!!!
Thanks!
Andy. 3 15404
The attempted connection will throw the error you are seeing if the
class has not been loaded first. The most common source of this is if
the driver class you specified is not found in your CLASSPATH. On
issuing the Class.forName() call, the java classloader will search the
CLASSPATH for a class with the given name, and load it into memory. An
exception is not thrown here unless you try to create a newInstance() of
the class.
Thus, you'll need to modify your CLASSPATH to include the location of
the DB2 Java drivers.
Andrew Johnson wrote: Hi,
I am trying to make a UBD DB2 7.2 connection using the Java COM.ibm.db2.jdb c.app.DB2Driver via Tomcat 3.2.1 on Solaris (and also on an AIX system with 3.3.1). I am attempting this either via JSP or a servlet.
I have a separate java application that I can run from the command line and as long as the user has the correct env variables:
DB2DIR=/opt/IBMdb2/V7.1 DB2INSTANCE=rep owner INSTHOME=/home/repowner
Then the connection is fine. I am using the same code to try and make the connection via tomcat.
try { Class.forName(" COM.ibm.db2.jdb c.app.DB2Driver "); // next line is printed out System.out.prin tln(new java.util.Date( ).toString() + " DRIVER FOUND."); } catch(ClassNotF oundException e) { System.out.prin tln(new java.util.Date( ).toString() + " Error 1: "+e); } String dbType="db2"; // String ip="10.0.0.185" ; // String port="8790"; String dbName="pprepor t"; String reason="testing db connection"; String userName="repow ner"; String password="ilink 1"; Connection con = null;
String url = "jdbc:db2:"+dbN ame;
boolean dbConnected = false;
try { System.out.prin tln(new java.util.Date( ).toString() + " Connecting to database URL = " + url + " for " + reason);
Enumeration e = DriverManager.g etDrivers(); while (e.hasMoreEleme nts()) { Driver d = (Driver) e.nextElement() ; // doesn't print anything here System.out.prin tln("driver is " + d.toString()); } System.out.prin tln("a1"); // gets to here and stops! Driver d = DriverManager.g etDriver(url); System.out.prin tln("a1.1"+d.to String());
con = DriverManager.g etConnection(ur l, userName, password);
java.sql.Statem ent stmt = con.createState ment(); System.out.prin tln("SETTING SCHEMA TO "+dbName); try { stmt.execute("S ET SCHEMA = "+dbName); System.out.prin tln("SCHEMA SET."); } catch (Exception ex) { System.out.prin tln("Error Setting Schema:"+ex); }
System.out.prin tln(new java.util.Date( ).toString() + " Database connection established.XX" ); dbConnected = true; } catch(Exception e) { System.out.prin tln(new java.util.Date( ).toString() + " Failed to connect, reason : \n" + e);
}
However via tomcat the driver cannot be loaded by the class loader. The class is found, but not loaded. The error I receive is "java.sql.SQLEx ception: No suitable driver"
I have placed the db2java.zip (renamed as db2java.jar) in several places to try and solve the problem (restarting Tomcat each time) but to no avail:
/usr/apache/tomcat/common/lib/db2java.jar .../WEB-INF/classes/db2java.jar
I have read many posts, but I can't understand how the driver will know the correct env variables even if the class is loaded.
Any help would be much appreciated!!!
Thanks! Andy.
I mean to say "... if the driver class has not been loaded first" in the
first sentence.
Andrew Johnson wrote: Hi,
I am trying to make a UBD DB2 7.2 connection using the Java COM.ibm.db2.jdb c.app.DB2Driver via Tomcat 3.2.1 on Solaris (and also on an AIX system with 3.3.1). I am attempting this either via JSP or a servlet.
I have a separate java application that I can run from the command line and as long as the user has the correct env variables:
DB2DIR=/opt/IBMdb2/V7.1 DB2INSTANCE=rep owner INSTHOME=/home/repowner
Then the connection is fine. I am using the same code to try and make the connection via tomcat.
try { Class.forName(" COM.ibm.db2.jdb c.app.DB2Driver "); // next line is printed out System.out.prin tln(new java.util.Date( ).toString() + " DRIVER FOUND."); } catch(ClassNotF oundException e) { System.out.prin tln(new java.util.Date( ).toString() + " Error 1: "+e); } String dbType="db2"; // String ip="10.0.0.185" ; // String port="8790"; String dbName="pprepor t"; String reason="testing db connection"; String userName="repow ner"; String password="ilink 1"; Connection con = null;
String url = "jdbc:db2:"+dbN ame;
boolean dbConnected = false;
try { System.out.prin tln(new java.util.Date( ).toString() + " Connecting to database URL = " + url + " for " + reason);
Enumeration e = DriverManager.g etDrivers(); while (e.hasMoreEleme nts()) { Driver d = (Driver) e.nextElement() ; // doesn't print anything here System.out.prin tln("driver is " + d.toString()); } System.out.prin tln("a1"); // gets to here and stops! Driver d = DriverManager.g etDriver(url); System.out.prin tln("a1.1"+d.to String());
con = DriverManager.g etConnection(ur l, userName, password);
java.sql.Statem ent stmt = con.createState ment(); System.out.prin tln("SETTING SCHEMA TO "+dbName); try { stmt.execute("S ET SCHEMA = "+dbName); System.out.prin tln("SCHEMA SET."); } catch (Exception ex) { System.out.prin tln("Error Setting Schema:"+ex); }
System.out.prin tln(new java.util.Date( ).toString() + " Database connection established.XX" ); dbConnected = true; } catch(Exception e) { System.out.prin tln(new java.util.Date( ).toString() + " Failed to connect, reason : \n" + e);
}
However via tomcat the driver cannot be loaded by the class loader. The class is found, but not loaded. The error I receive is "java.sql.SQLEx ception: No suitable driver"
I have placed the db2java.zip (renamed as db2java.jar) in several places to try and solve the problem (restarting Tomcat each time) but to no avail:
/usr/apache/tomcat/common/lib/db2java.jar .../WEB-INF/classes/db2java.jar
I have read many posts, but I can't understand how the driver will know the correct env variables even if the class is loaded.
Any help would be much appreciated!!!
Thanks! Andy.
Actually this message means that your database url
String url = "jdbc:db2:"+dbN ame;
does not match all already loaded drivers.
That's all.
In other words your driver COM.ibm.db2.jdb c.app.DB2Driver does not
recognize url
"jdbc:db2:pprep ort"
I don't like IBM for their documentation. It took a year for me to
understand what they want when I tried to connect to DB2 on mainframe. So,
I really don't know what your driver wants. Try documnetation or examples
(if you have them :)))
How do you connect to your database wothout java? DB2 Connect? Local
instance?
Try another ways like this:
"jdbc:inetdb2:1 27.0.0.1:50000? database=pprepo rt",
//"jdbc:db2://127.0.0.1:50000/ppreport",
//"jdbc:db2:127.0 .0.1:50000:ppre port",
//"jdbc:db2:pprep ort",
Alex Kizub.
Andrew Johnson wrote: Hi,
I am trying to make a UBD DB2 7.2 connection using the Java COM.ibm.db2.jdb c.app.DB2Driver via Tomcat 3.2.1 on Solaris (and also on an AIX system with 3.3.1). I am attempting this either via JSP or a servlet.
I have a separate java application that I can run from the command line and as long as the user has the correct env variables:
DB2DIR=/opt/IBMdb2/V7.1 DB2INSTANCE=rep owner INSTHOME=/home/repowner
Then the connection is fine. I am using the same code to try and make the connection via tomcat.
try { Class.forName(" COM.ibm.db2.jdb c.app.DB2Driver "); // next line is printed out System.out.prin tln(new java.util.Date( ).toString() + " DRIVER FOUND."); } catch(ClassNotF oundException e) { System.out.prin tln(new java.util.Date( ).toString() + " Error 1: "+e); } String dbType="db2"; // String ip="10.0.0.185" ; // String port="8790"; String dbName="pprepor t"; String reason="testing db connection"; String userName="repow ner"; String password="ilink 1"; Connection con = null;
String url = "jdbc:db2:"+dbN ame;
boolean dbConnected = false;
try { System.out.prin tln(new java.util.Date( ).toString() + " Connecting to database URL = " + url + " for " + reason);
Enumeration e = DriverManager.g etDrivers(); while (e.hasMoreEleme nts()) { Driver d = (Driver) e.nextElement() ; // doesn't print anything here System.out.prin tln("driver is " + d.toString()); } System.out.prin tln("a1"); // gets to here and stops! Driver d = DriverManager.g etDriver(url); System.out.prin tln("a1.1"+d.to String());
con = DriverManager.g etConnection(ur l, userName, password);
java.sql.Statem ent stmt = con.createState ment(); System.out.prin tln("SETTING SCHEMA TO "+dbName); try { stmt.execute("S ET SCHEMA = "+dbName); System.out.prin tln("SCHEMA SET."); } catch (Exception ex) { System.out.prin tln("Error Setting Schema:"+ex); }
System.out.prin tln(new java.util.Date( ).toString() + " Database connection established.XX" ); dbConnected = true; } catch(Exception e) { System.out.prin tln(new java.util.Date( ).toString() + " Failed to connect, reason : \n" + e);
}
However via tomcat the driver cannot be loaded by the class loader. The class is found, but not loaded. The error I receive is "java.sql.SQLEx ception: No suitable driver"
I have placed the db2java.zip (renamed as db2java.jar) in several places to try and solve the problem (restarting Tomcat each time) but to no avail:
/usr/apache/tomcat/common/lib/db2java.jar .../WEB-INF/classes/db2java.jar
I have read many posts, but I can't understand how the driver will know the correct env variables even if the class is loaded.
Any help would be much appreciated!!!
Thanks! Andy. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jack |
last post by:
Hello,
I wrote this code:
<%@ LANGUAGE=VBScript %>
<SCRIPT LANGUAGE=JavaScript>
function CustomerNameChange()
{
var forwarding_dbX;
var CustomerTableX;
set forwarding_dbX = Server.CreateObject("ADODB.Connection");
forwarding_dbX.Open "Forwarding";
|
by: Chavan Koya |
last post by:
Hi,
This is my first posting to this group. We are thinking to migrate
a Informix database which is running on HP-UX 11. Initially we are try
to evaluate the Oracle Migration WorkBench to do this. Did any one do
migration using this tool. We are getting "No suitable Driver" error
message after giving the INFORMIXSERVER name, port number, user id,
password. We are using JDBC 2.1 Version for connectivity. Does any
body has any ides or...
|
by: Luong Phan |
last post by:
--0-342085162-1061547060=:86593
Content-Type: text/plain; charset=us-ascii
Hi all,
In my web application, I use mysql supported by Redhat Linux 7.3 to store database, jakarta-tomcat-3.2.4,
mysql-connector-java-3.0.6-stable-bin.jar, and JSP.
Every time, I run the program:
|
by: Raquel |
last post by:
Have installed UDB PE V8.0 on Win XP and wrote a JDBC program using
driver
com.ibm.db2.jcc.DB2Driver. At run time, it throws error "No Suitable
Driver". Why is it?
When I use JDBC-ODBC bridge sun.jdbc.odbc.JdbcOdbcDriver (instead of
the above driver), the program runs fine.
TIA
Raquel.
|
by: sebtiber |
last post by:
Hi,
I try to connect to db2 with tomcat4.0.6 on linux redhat9.0. with
driver db2java.jar
I have always the same error "no suitable driver".
i try different actions that have read on the forum :
copy db2java.zip in $TOMCAT_HOME/common/lib
rename it in db2java.jar
| |
by: Rakesh |
last post by:
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)
|
by: tarunsharma_454 |
last post by:
hi,
i m trying to connect ms access with jdbc odbc bridge.
forName(sun.jdbc.odbc.JdbcOdbcDriver) is working well.
when i m trying 2 get connection with
con.getConnection(jdbc.odbc.office);
where office is a dsn 4 ms access setup by odbc.
i m getting exception that "NO SUITABLE DRIVER FOUND".
WAT IS THE PROBLEM.
PLZ HELP ME.
|
by: nurmaiza |
last post by:
Hello, i'm using windows, eclipse, Tomcat 5.5 and JSP file trying to connect jdbc ms sql using jdts driver.
i've download the driver and assigned the path at en.variable..but it give me an error no suitable driver
anyone ve idea on what the setting shud i set?i've no idea after followed some instruction on web site still it give me the same error.
this is my code
<title>Obtain connection</title>
</head>
<body>
|
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...
|
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,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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...
|
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();...
|
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...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |