I too am trying to access the SQL server using the MSSQLTEST routines. After applying a full set of cumulative PTF's, downloading the JAVA (5722JV1) options 10 & 11, then applying the Java Group PTF's, and finding out how to get the iSeries to use a different version of the JVM, I have finally gotten past all the "Invalid ClassDefinition" errors etc. and the program runs, however all I get is the "Unable to Connect." Error message. When I run in debug (code snippet below)
prop = JDBC_Properties();
JDBC_setProp(prop: 'databaseName=': 'database name');
JDBC_setProp(prop: 'user=' : 'domain name\user'); (I've also tried it with just the user name without the domain name)
JDBC_setProp(prop: 'password=' : 'password');
(Prop Values changed to protect the innocent)
conn = JDBC_ConnProp('com.microsoft.sqlserver.jdbc.SQLServerDriver'
:'java:jdbc:sqljdbc.jar:192.168.1.21:1433'
: prop );
In the service program JDBCR4, I am failing in the CallConnectMethod routine.
conn = CallConnectMethod(JNIENV_P: drv: mid: str: prop)
Looking at the values of the parameters to this routine I see:
JNIENV_P = SPP:FD8840C214002000
Drv = 12
Mid = 8
Str = 15
Prop = 5
I am told by my network person that port 1433 is open and listening, however I do not see that when I run a "netstat -a" command from the dos prompt on the SQL server. I CAN CONNECT with the above user/password combination using the SQL Server Management Studio...
iSeries V5R4M0
SQL Server 2012
-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Kim Massar
Sent: Thursday, December 06, 2012 6:40 AM
To: RPG programming on the IBM i / System i
Subject: RE: accessing SQL db in RPG
Since this is the first time I am learning this I was trying to read all I could, and I think I have confused myself with all the problems members had on the iseriesnetwork forums. So is the best way to establish the classpath thru the ADDENVVAR command? Then I would not need the classpath in my programs.
I ask our system administrator to add the jTDS jar files on the /QIBM/UserData/Java400/ext directory, from what I am reading that is not the best place?
Thanks a lot, Kim
-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Scott Klement
Sent: Wednesday, December 05, 2012 5:38 PM
To: RPG programming on the IBM i / System i
Subject: Re: accessing SQL db in RPG
Hi Kim,
On 12/5/2012 1:53 PM, Kim Massar wrote:
I ran it this morning and it was ok, then I added the query part back
into the program and recompiled it. Now I am getting the
NoClassDefFoundError:.
This means it can't find a class definition. With JDBC, you typically will have classes defined in a JAR file (which, under the covers, is really just a glorified ZIP file containing compiled Java classes).
Java will read the CLASSPATH environment variable for the list of JAR files (or other containers, such as directories) that might contain class definitions.
You didn't say which Java class is missing -- but, as most of JDBC is built-in to Java, I suspect it's the specific database driver that's missing. Have you placed your JAR file into the CLASSPATH?
Also, MSSQLTEST is an old example that I do not like:
1) It attempts to set the CLASSPATH inside the RPG program that uses it.
IMHO, that's not a good idea. (I did not write the code in this example, this was provided by someone else.)
2) It uses the sqljdbc.jar driver from Microsoft that in my opinion, isn't a very good driver. I recommend using the jTDS one instead.
Could I be getting the error because it was defined from running this
morning and now I am trying to define it again? Thanks
Aside from the CLASSPATH stuff I mentioned, above... My only guess is
that something got messed up in the JVM. Signing off and back on again will give you a fresh JVM, and will cause Java to re-load the CLASSPATH as well. (So make sure it's set properly before starting any Java programs in the fresh job.)
-SK
--
This is the RPG programming on the IBM i / System i (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit:
http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
http://archive.midrange.com/rpg400-l.
Email Confidentiality Notice: The information contained in this transmission is confidential, proprietary or privileged and may be subject to protection under the law, including the Health Insurance Portability and Accountability Act (HIPAA). The message is intended for the sole use of the individual or entity to whom it is addressed. If you are not the intended recipient, you are hereby notified that any use, distribution, copying or printing of this message is strictly prohibited and may subject you to criminal or civil penalties. If you received this transmission in error, please contact the sender immediately by replying to this email and then delete the material from any computer.
--
This is the RPG programming on the IBM i / System i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit:
http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at
http://archive.midrange.com/rpg400-l.
[Rodda Paint Turns 80!]
Chuck Graves
Director of Information Systems
Rodda Paint Co.<
http://www.roddapaint.com>
6107 N. Marine Drive
Portland, Oregon 97203
(503) 737-6042
As an Amazon Associate we earn from qualifying purchases.