Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Informix JDBC:sqli connection problem.

371 views
Skip to first unread message

muchan

unread,
Oct 6, 1999, 3:00:00 AM10/6/99
to

I have experiences writing Informix Esql/C programs. This time I'm thinking to
immigrate to JDBC, and downloaded trial version of Informix JDBC driver 2.00.

After installation, I had a difficulty connecting to the database.
The most simple program to test connection was demo/basic/DBConnection.java

After managing to find to write correct argument, like
java DBConnection 'jdbc:informix-sqli://classic:1525:informixserver=classicnet;
user=muchan;passwd=pwd'

I get:
ERROR: failed to load Informix JDBC driver.
ERROR: failed to connect!
Exception in thread "main" java.lang.NullPointerException
at DBConnection.main(Compiled Code)

The code causing the error message is:

try
{
Class.forName("com.informix.jdbc.IfxDriver");
}
catch (Exception e)
{
System.out.println("ERROR: failed to load Informix JDBC driver.");
}

I checked ClassPath, and there is "ifxjdbc.jar", which contains the class
"com.informix.jdbc.IfxDriver". So I suppose the class should be found and
loaded.

Do I missing something?

Thanks in advance.

muchan

Octav Chiriac

unread,
Oct 6, 1999, 3:00:00 AM10/6/99
to

Check again your CLASSPATH env variable.
As I understand you are using some sort of jdk1.2.*. In this
case try as an workaround (and for testing) to specify the
classpath on comand line (-cp option) or put the
ifxjdbc.jar file into your JREHOME/lib/ext directory.

If this will not work, can you post more of your code ?

Best Regards,
Octav

--
Octav Chiriac Phone: (373) 2 22 99 67
NetInfo S.R.L. Fax: (373) 2 21 36 59
Chisinau (373) 2 22 84 88
Moldova, Republic of mailto:c...@netinfo-moldova.com

muchan

unread,
Oct 8, 1999, 3:00:00 AM10/8/99
to

I could solve the problem of loading JDBC driver, but connection to
the database (on SE server on UNIX machine) never succeed...

I always get Error message:


ERROR: failed to connect!
Exception in thread "main" java.lang.NullPointerException
at DBConnection.main(Compiled Code)

The code causing exception is:

try
{
conn = DriverManager.getConnection(newUrl);
}
catch (SQLException e)
{
System.out.println("ERROR: failed to connect!");
}

Can I trace down into DriverManager.getConnection() where the
exception occurs? Does Informix gives source code for JDBC driver?

Debugging tips appreciated.

muchan

Angel Gomez

unread,
Oct 8, 1999, 3:00:00 AM10/8/99
to

Hello.


>From: muchan <muc...@promikra.si>
>Reply-To: muchan <muc...@promikra.si>
>To: inform...@iiug.org
>Subject: Re: Informix JDBC:sqli connection problem.
>Date: Fri, 08 Oct 1999 14:04:04 +0200
>
>I could solve the problem of loading JDBC driver, but connection to
>the database (on SE server on UNIX machine) never succeed...
>
>I always get Error message:
> ERROR: failed to connect!
> Exception in thread "main" java.lang.NullPointerException
> at DBConnection.main(Compiled Code)
>
>The code causing exception is:
>
> try
> {
> conn = DriverManager.getConnection(newUrl);
> }
> catch (SQLException e)
> {
> System.out.println("ERROR: failed to connect!");
> }
>
>Can I trace down into DriverManager.getConnection() where the
>exception occurs? Does Informix gives source code for JDBC driver?
>
>Debugging tips appreciated.
>
>muchan
>

Check this from the Informix JDBC Doc.
Software Dependencies

To use Informix JDBC Driver to connect to an Informix database, you must
use one of the following Informix database
servers:

Informix Dynamic Server, Version 7.x
Informix Dynamic Server, Workgroup and Developer Editions, Version
7.x
Informix Dynamic Server with Advanced Decision Support and
Extended Parallel Options, Version 8.x
Informix Dynamic Server with Universal Data Option, Version 9.x
INFORMIX-OnLine, Version 5.x

You must also use the following JavaSoft software:

Java Development Kit (JDK), Version 1.1.5 or later


So, if you're using SE, it won't connect. :-(


>
>
> > >
> > > After managing to find to write correct argument, like
> > > java DBConnection
>'jdbc:informix-sqli://classic:1525:informixserver=classicnet;
> > > user=muchan;passwd=pwd'
> > >
> > > I get:
> > > ERROR: failed to load Informix JDBC driver.
> > > ERROR: failed to connect!
> > > Exception in thread "main" java.lang.NullPointerException
> > > at DBConnection.main(Compiled Code)
> > >
> > > The code causing the error message is:
> > >
> > > try
> > > {
> > > Class.forName("com.informix.jdbc.IfxDriver");
> > > }
> > > catch (Exception e)
> > > {
> > > System.out.println("ERROR: failed to load Informix JDBC
>driver.");
> > > }
> > >
> > > I checked ClassPath, and there is "ifxjdbc.jar", which contains the
>class
> > > "com.informix.jdbc.IfxDriver". So I suppose the class should be found
>and
> > > loaded.
> > >
> > > Do I missing something?
> > >
> > > Thanks in advance.
> > >
> > > muchan


Angel Gomez
TelNor, S.A.
Tijuana, B.C., Mexico.
<Angel...@telnor.com>

______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com

Suji...@bankofamerica.com

unread,
Oct 8, 1999, 3:00:00 AM10/8/99
to


Muchan

For SE, you need to specify the path to the database.dbs file in your JDBC URL.
Assume your database is contained in /data/database.dbs, then your URL would
look like this.

jdbc:informix-sqli://machine:port/ /data/database:INFORMIXSERVER=...

Note the space between machine:port/ and the path name. I had this problem too,
till someone on this list told me about this.

HTH
Sujit

muchan <muc...@promikra.si> on 10/08/99 05:04:04 AM

Please respond to muchan <muc...@promikra.si>

To: inform...@iiug.org
cc: (bcc: Sujit Pal)


Subject: Re: Informix JDBC:sqli connection problem.

I could solve the problem of loading JDBC driver, but connection to
the database (on SE server on UNIX machine) never succeed...

I always get Error message:
ERROR: failed to connect!
Exception in thread "main" java.lang.NullPointerException
at DBConnection.main(Compiled Code)

The code causing exception is:

try
{
conn = DriverManager.getConnection(newUrl);
}
catch (SQLException e)
{
System.out.println("ERROR: failed to connect!");
}

Can I trace down into DriverManager.getConnection() where the
exception occurs? Does Informix gives source code for JDBC driver?

Debugging tips appreciated.

muchan

> >

Suji...@bankofamerica.com

unread,
Oct 8, 1999, 3:00:00 AM10/8/99
to


Angel

Yes it will. I am using SE 7.24 on Linux, JDK 1.1.6 on Linux and Informix JDBC
Driver 1.4. It works. You just need to change the JDBC URL slightly.

Sujit

Angel Gomez <an...@hotmail.com> on 10/08/99 07:35:58 AM

To: muc...@promikra.si, inform...@iiug.org


cc: (bcc: Sujit Pal)
Subject: Re: Informix JDBC:sqli connection problem.


Hello.


>From: muchan <muc...@promikra.si>
>Reply-To: muchan <muc...@promikra.si>
>To: inform...@iiug.org

>Subject: Re: Informix JDBC:sqli connection problem.

>Date: Fri, 08 Oct 1999 14:04:04 +0200
>

>I could solve the problem of loading JDBC driver, but connection to
>the database (on SE server on UNIX machine) never succeed...
>
>I always get Error message:
> ERROR: failed to connect!
> Exception in thread "main" java.lang.NullPointerException
> at DBConnection.main(Compiled Code)
>
>The code causing exception is:
>
> try
> {
> conn = DriverManager.getConnection(newUrl);
> }
> catch (SQLException e)
> {
> System.out.println("ERROR: failed to connect!");
> }
>
>Can I trace down into DriverManager.getConnection() where the
>exception occurs? Does Informix gives source code for JDBC driver?
>
>Debugging tips appreciated.
>
>muchan
>

Check this from the Informix JDBC Doc.
Software Dependencies

To use Informix JDBC Driver to connect to an Informix database, you must
use one of the following Informix database
servers:

Informix Dynamic Server, Version 7.x
Informix Dynamic Server, Workgroup and Developer Editions, Version
7.x
Informix Dynamic Server with Advanced Decision Support and
Extended Parallel Options, Version 8.x
Informix Dynamic Server with Universal Data Option, Version 9.x
INFORMIX-OnLine, Version 5.x

You must also use the following JavaSoft software:

Java Development Kit (JDK), Version 1.1.5 or later


So, if you're using SE, it won't connect. :-(
>
>
> > >

> > > After managing to find to write correct argument, like
> > > java DBConnection
>'jdbc:informix-sqli://classic:1525:informixserver=classicnet;
> > > user=muchan;passwd=pwd'
> > >
> > > I get:
> > > ERROR: failed to load Informix JDBC driver.
> > > ERROR: failed to connect!
> > > Exception in thread "main" java.lang.NullPointerException
> > > at DBConnection.main(Compiled Code)
> > >
> > > The code causing the error message is:
> > >
> > > try
> > > {
> > > Class.forName("com.informix.jdbc.IfxDriver");
> > > }
> > > catch (Exception e)
> > > {
> > > System.out.println("ERROR: failed to load Informix JDBC
>driver.");
> > > }
> > >
> > > I checked ClassPath, and there is "ifxjdbc.jar", which contains the
>class
> > > "com.informix.jdbc.IfxDriver". So I suppose the class should be found
>and
> > > loaded.
> > >
> > > Do I missing something?
> > >
> > > Thanks in advance.
> > >
> > > muchan

Angel Gomez

unread,
Oct 8, 1999, 3:00:00 AM10/8/99
to

OK, OK...

You're right, i'm using Informix JDBC Driver 1.4 also, but the
documentation installed in the server is from an older release ( 1.22 and i
will update it), so... Yes it works with SE 5.X and 7.X.

So... how do you specify the URL ?

muchan

unread,
Oct 11, 1999, 3:00:00 AM10/11/99
to
Suji...@bankofamerica.com wrote:
>
> Muchan
>
> For SE, you need to specify the path to the database.dbs file in your JDBC URL.
> Assume your database is contained in /data/database.dbs, then your URL would
> look like this.
>
> jdbc:informix-sqli://machine:port/ /data/database:INFORMIXSERVER=...
>
> Note the space between machine:port/ and the path name. I had this problem too,
> till someone on this list told me about this.
>
> HTH
> Sujit
>

Thanks for everyone who helped me solving the problem.
With above URL, I could connect to SE server by "Direct Connection" method.
("Indirect Connection" method still fails, but I can live with one method.)

and thanks Andy for the tips

> catch (Exception e)
> {
> System.out.println(e.getErrorCode());
> System.out.println(e.getMessage());
> }

it seems
catch (SQLException e)
{
...
}
works better.

muchan

0 new messages