473,398 Members | 2,812 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,398 software developers and data experts.

ClassNotFoundException

Hi all

I'm having no "luck" trying my first-time connect to an I-SE server from a
Java application, using JDBC.
I'm always getting then error:
"Error: java.lang.ClassNotFoundException: com.informix.jdbc.IfxDriver"

I suspect the problem is in my CLASSPATH system variable, but I don't know
how to set it. Or, perhaps, the strings I'm using aren't correct.
Facts:
1) My network is "up and running";
2) Informix-SE is on a Unix remote machine;
3) My Java app is on Windows XP Home;
4) Informix Client-SDK 2.81 TC3 is installed on XP;
5) ODBC has no problems
(I've an MS-Access app that retrieves data from my SE server. My Java
app, with JDBC-ODBC bridge, also works fine);
6) Using Informix Client-SDK dbping, every connection are made successfully,
except... JDBC!;
7) In JDBC dbping tab, only "com.informix.jdbc.IfxDriver" seems to be the
right value since the other two options appears to be for db2
(COM.ibm.db2.jdbc.app.DB2Driver and COM.ibm.db2.jdbc.net.DB2Driver)
8) I'm trying protocol "jdbc:informix-sqli". The other option is "jdbc:db2"
(dbping);
9) My Java app:
try {
//Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); //jdbc-odbc
bridge: works fine!
Class.forName("com.informix.jdbc.IfxDriver");
} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}

try {
//String url = "jdbc:odbc:ifx_dsn"; //jdbc-odbc bridge: works
fine!
String url = "jdbc:informix-sqli"
Connection con = DriverManager.getConnection(url, "login",
"password");
Statement stmt = con.createStatement();
//retrieval of values
(...)
}
stmt.close();
con.close();
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}

On JDBC dbping tab is written "This Utility assumes that you have a JDBC
driver installed and a CLASSPATH set before running DBPING"
a) What do they mean by having a JDBC driver installed? Isn't this driver
installed when I installed Informix-SDK? If not, how can I get it?
b) Do I have to do something like I did to the ODBC driver (by creating and
configuring a
DSN)? Where and how?
c) I know CLASSPATH system variable isn't set. Should I set it in my system?
By what value? By a path within Informix-SDK folders? Should CLASSPATH be
set anywhere else (e.g. setnet32)?
I suspect the problem is in my CLASSPATH system variable, but I don't know
how to set it. Or, perhaps, the strings I'm using aren't correct.
Can Anyone help?

Thanks in advance,
Jorge Cecilio

Jul 17 '05 #1
2 20566
[cut]

When you using database you must have the JDBC Driver for that type of database.
JDBC: Java Database Connectivity.
JDBC Defines an framework/api for java connecting to sql databases.
It has some Interface objets in iut that a specific driver for a specific database must implement.

So you must have a driver for your specific database in your classpath
The driver you want to use is: com.informix.jdbc.IfxDriver


On JDBC dbping tab is written "This Utility assumes that you have a JDBC
driver installed and a CLASSPATH set before running DBPING"
a) What do they mean by having a JDBC driver installed? Isn't this driver
installed when I installed Informix-SDK? If not, how can I get it?
I think, but am not sure, that the driver is in your Informix-SDK
But you must include the .jar or .class that is the driver in your classpath.
b) Do I have to do something like I did to the ODBC driver (by creating and
configuring a
DSN)? Where and how?
dsn? i do not follow you here.
c) I know CLASSPATH system variable isn't set. Should I set it in my system?
By what value? By a path within Informix-SDK folders? Should CLASSPATH be
set anywhere else (e.g. setnet32)?
When you run your application you must bee sure that the com.informix.jdbc.IfxDriver
class is in your classpath, see the documentation of Informix where com.informix.jdbc.IfxDriver resides.

I suspect the problem is in my CLASSPATH system variable, but I don't know
how to set it. Or, perhaps, the strings I'm using aren't correct.
Can Anyone help?
You CAN set your classpath system var to include com.informix.jdbc.IfxDriver but it will then only
work on your computer. Better is to set the classpath in your application,
for example if you start your application from a .jar you can include com.informix.jdbc.IfxDriver
by editing the manifest file of the jar.

Else you could create a Start script that sets up the classpath first

Thanks in advance,
Jorge Cecilio


Jul 17 '05 #2
Jorge Cecílio wrote:
Hi all

I'm having no "luck" trying my first-time connect to an I-SE server from a
Java application, using JDBC.
I'm always getting then error:
"Error: java.lang.ClassNotFoundException: com.informix.jdbc.IfxDriver"

I suspect the problem is in my CLASSPATH system variable, but I don't know
how to set it. Or, perhaps, the strings I'm using aren't correct.
Facts:
1) My network is "up and running";
2) Informix-SE is on a Unix remote machine;
3) My Java app is on Windows XP Home;
4) Informix Client-SDK 2.81 TC3 is installed on XP;
5) ODBC has no problems
(I've an MS-Access app that retrieves data from my SE server. My Java
app, with JDBC-ODBC bridge, also works fine);
6) Using Informix Client-SDK dbping, every connection are made successfully,
except... JDBC!;
7) In JDBC dbping tab, only "com.informix.jdbc.IfxDriver" seems to be the
right value since the other two options appears to be for db2
(COM.ibm.db2.jdbc.app.DB2Driver and COM.ibm.db2.jdbc.net.DB2Driver)
8) I'm trying protocol "jdbc:informix-sqli". The other option is "jdbc:db2"
(dbping);
9) My Java app:
try {
//Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); //jdbc-odbc
bridge: works fine!
Class.forName("com.informix.jdbc.IfxDriver");
} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}

try {
//String url = "jdbc:odbc:ifx_dsn"; //jdbc-odbc bridge: works
fine!
String url = "jdbc:informix-sqli"
Connection con = DriverManager.getConnection(url, "login",
"password");
Statement stmt = con.createStatement();
//retrieval of values
(...)
}
stmt.close();
con.close();
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}

On JDBC dbping tab is written "This Utility assumes that you have a JDBC
driver installed and a CLASSPATH set before running DBPING"
a) What do they mean by having a JDBC driver installed? Isn't this driver
installed when I installed Informix-SDK? If not, how can I get it?
b) Do I have to do something like I did to the ODBC driver (by creating and
configuring a
DSN)? Where and how?
c) I know CLASSPATH system variable isn't set. Should I set it in my system?
By what value? By a path within Informix-SDK folders? Should CLASSPATH be
set anywhere else (e.g. setnet32)?
I suspect the problem is in my CLASSPATH system variable, but I don't know
how to set it. Or, perhaps, the strings I'm using aren't correct.
Can Anyone help?

Thanks in advance,
Jorge Cecilio


Your post is quite long.

A ClassNotFoundException is simply java telling u it cannot find a class
that u are trying to load, in this case: com.informix.jdbc.IfxDriver.

I assume this class is in a jar.
U can use the system classpath to include the path to this jar, or use
the -cp option from java.exe to specify where the jar resides.

For example, if your informix driver is located in a jar called
informix.jar, residing in the same directory as where u call java.exe to
start your application, the command would be:
java -cp informix.jar <your.class>

hth

Stijn
Jul 17 '05 #3

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

Similar topics

1
by: Kent | last post by:
I'm running on Win2000 and JRE 1.4.1.... I've got a small client trying to do get an InitialContext() and talk to the local JBoss server running on same machine (different VM of course). When...
1
by: David Liebtag | last post by:
I have what I hope is a simple question: I'm learning how to serialize objects. I create an ObjectOutputStream and writeObject an object to it. I then create an ObjectInputStream and try to...
0
by: schwarcz | last post by:
I'm trying to resurrect some of my old RMI code and running into problems where the bind() throws a ClassNotFoundException for the remote interface. The old code ran on a older JDK and an older...
1
by: Anoniem | last post by:
Hi, I'm trying to start a example which comes with the midp2.0 distribution. My relevant environment variables are set in a batch file like: ...
1
by: nithiya sri | last post by:
i am new to struts.I try running struts application in Eclipse with the tomcat plug in .. it shows the following error:; please help me in this... SEVERE: Error loading WebappClassLoader ...
1
by: mayurapink | last post by:
Hello, I've been banging my metaphorically banging my head again the wall all day attempting to use a simple servlet to connect to a db2 database and update a table. I eventually run into the...
2
by: mayurapink | last post by:
Hello, I've been banging my metaphorically banging my head again the wall all day attempting to use a simple servlet to connect to a db2 database and update a table. I eventually run into the...
2
by: pradeep84 | last post by:
Hi to all....... i hav compiled my program.. i got error like this java.lang.ClassNotFoundException: sun.jdbc.odbc.Jdbc.OdbcDriver can any one wat does it mean and how to resolve it.... ...
2
by: jith87 | last post by:
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver Ths s the error i get whn i try to connect to mysql using jdbc driver.....Can u help me out...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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,...
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
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.