Accesssing External Databases

Scott Klement's open source interface to using JDBC database drivers from RPG. http://www.scottklement.com/jdbc/
Post Reply
maxino
Posts: 5
Joined: Sun Jan 21, 2024 9:16 am

Accesssing External Databases

Post by maxino »

Good morning, I read data from a SQL server.

My as400 is V6R1

In Scott's manual, it says to:

Set CLASSPATH as follows:
ADDENVVAR ENVVAR(CLASSPATH) VALUE('/java/jdbc/jdts-1.3.1.jar')

In my as400 in the indicated directory:
/java/jdbc/
jdts-1.3.1.jar file is missing

How does it all work?

If I use the WRKENVVAR command I don't see anything, there is no CLASSPATH.

Can anyone help me understand? Thank you
Scott Klement
Site Admin
Posts: 658
Joined: Sun Jul 04, 2021 5:12 am

Re: Accesssing External Databases

Post by Scott Klement »

maxino wrote: Sun Jan 21, 2024 9:24 am My as400 is V6R1
V6R1 won't run on an AS/400. The last AS/400 was made 24 years ago. It is time to get a new computer.
maxino wrote: Sun Jan 21, 2024 9:24 am In Scott's manual, it says to:

Set CLASSPATH as follows:
ADDENVVAR ENVVAR(CLASSPATH) VALUE('/java/jdbc/jdts-1.3.1.jar')

In my as400 in the indicated directory:
/java/jdbc/
jdts-1.3.1.jar file is missing
Did you download the jar file into that directory?
maxino wrote: Sun Jan 21, 2024 9:24 am How does it all work?
You download the JDBC driver that you want to use and put it somewhere in the IFS on your system, then point the CLASSPATH variable to it so that it knows where to find it.
maxino wrote: Sun Jan 21, 2024 9:24 am If I use the WRKENVVAR command I don't see anything, there is no CLASSPATH.

Can anyone help me understand? Thank you
Did you run the ADDENVVAR command that you mentioned, above? That will ADD the ENVironment VARiable so that WRKENVVAR will see it. It won't be there if you (or someone) doesn't add it.

Also there are two different levels it can be added at. The *SYS (system) and *JOB level. IF you add it at the job level, it will only exist for the duration of your job. If you add it at the system level, it will be copied to a job-level variable the first time anyone uses an environment variable in the job. So if you added it at the system level, it may not show up until you sign off and on again. (But unlike *JOB, the *SYS level will exist for all jobs, and persist when your job ends.)
maxino
Posts: 5
Joined: Sun Jan 21, 2024 9:16 am

Re: Accesssing External Databases

Post by maxino »

Thanks for the reply Scott.

If programs work ONLY if a CLASSPATH exists, I certainly did the ADDENVVAR command.

The question is, how do I see where I put the jar file?

If it's not in /java/jdbc/ where is it?

Is there a command to see where I put it?

Best regard

PS:
The ADDENVVAR command was almost certainly done at system level, because every time I run an RPG program to read an external database in the CLP I don't indicate the ADDENVVAR.
Scott Klement
Site Admin
Posts: 658
Joined: Sun Jul 04, 2021 5:12 am

Re: Accesssing External Databases

Post by Scott Klement »

Normally, Java will only find JAR files that are explicitly listed in the CLASSPATH. So if you are telling me that it's not located where it's listed in the CLASSPATH, then I'm very confused.

The only thing I can think of is that someone put it into the Java Extensions directory. Last time I used it, it was /QIBM/UserData/Java400/ext -- look and see if the JAR is in there. But... if it's there, then why do you need to set a CLASSPATH at all? Note: I do NOT recommend putting JAR files in this folder because that means that Java is to treat them as "extensions" that are always loaded and available. That means you can't use different versions of the same JAR file, and it means that every project loads it whether it needs it or not. It's much better to use CLASSPATH.

As for a tool to find where you put it.... Surely when you uploaded it you picked a location? Do you not remember? I suppose you could search all of the IFS for it -- but obviously that could take a long time.
maxino
Posts: 5
Joined: Sun Jan 21, 2024 9:16 am

Re: Accesssing External Databases

Post by maxino »

Thanks Scott for the reply.

I found the sqljdbc.jar file

It's in the directory
/QIBM/UserData/Java400/ext

Perhaps I referred to an old article of yours in which you indicated this directory.

Thanks again
Post Reply