× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



It's kind of horrible how much time I spent on this, and of course, after I send the email I realize there's a typo.
conn = JDBC_ConnProp( 'net.sourceforge.jtds.jdbc.Driver'
should have been
conn = JDBC_ConnProp( 'net.sourceforge.jdts.jdbc.Driver'

jtds vs jdts

-Kurt

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Kurt Anderson
Sent: Friday, October 21, 2011 2:34 PM
To: RPG programming on the IBM i / System i (rpg400-l@xxxxxxxxxxxx)
Subject: JDBC4R - Issue finding driver

I'm trying to setup connections to our SQLServer 2005 & 2008 servers.

I'm not at all familiar with JDBC stuff or setting up java. I've been following Scott's presentation:
http://www.scottklement.com/presentations/External%20Databases%20from%20RPG.pdf

I downloaded the jtds jar and placed it in the IFS root in a folder called /java/jdts/
The jar is jtds-1.2.5.jar. I thought I'd rename it to try jtds.jar as well. Since it wasn't working I didn't know if I needed the /java/jdts/ under the Home directory in the IFS so I put it there as well.

Here is the code I'm trying to run (taken from Scott's MSSQLTEST source):
/copy jdbcr4lib/qrpg,jdbc_h

D getenv PR * EXTPROC('Qp0zGetEnvNoCCSID')
D name * VALUE OPTIONS(*STRING)

D putenv PR * EXTPROC('Qp0zPutEnvNoCCSID')
D name * VALUE OPTIONS(*STRING)

D EnvVal S 256A VARYING
D EnvValChanged S N INZ(*off)
D p_EnvVal s *

D ErrMsg s 50A
D wait s 1A
D count s 10I 0

D CaseID s 15A

D conn s like(Connection)
D rs s like(ResultSet)
D prop s like(Properties)
D prepstm s like(PreparedStatement)

// Set up CLASSPATH before starting JVM

p_envval = getenv('CLASSPATH');
if (p_envval <> *null);
EnvVal = %str(p_envval);
endif;
if %scan('.:':EnvVal) = *zeros;
EnvVal = '.:' + EnvVal;
EnvValChanged = *on;
endif;
if %scan('/sqljdbc.jar':EnvVal) = *zeros;
//EnvVal += ':/java/jdbc/jdts-1.2.5.jar';
EnvVal += ':/java/jdbc/jdts.jar';
EnvValChanged = *on;
endif;
if EnvValChanged;
putenv('CLASSPATH=' + EnvVal);
endif;

prop = JDBC_Properties();
JDBC_setProp(prop: 'userName' : 'user');
JDBC_setProp(prop: 'password' : 'password');
JDBC_setProp(prop: 'databaseName' : 'cdwEQX');

//conn = JDBC_ConnProp('com.microsoft.sqlserver.jdbc.SQLServerDriver'
conn = JDBC_ConnProp( 'net.sourceforge.jtds.jdbc.Driver'
:'jdbc:jtds:sqlserver://172.16.20.20:1433'
: prop );
JDBC_freeProp(prop);

if (conn = *NULL);
return;
endif;


test dsply 'connected' 'KURT';
test return;

The error I'm getting is ClassNotFoundException: net.sourceforge.jtds.jdbc.Driver

The FAQ at the JTDS site says it's likely having an issue finding the JAR.
After the program runs I check the environment variable and it looks right:
CLASSPATH '.::/java/jdbc/jdts.jar'

I'm really at a loss here. Anyone have any ideas?

Thanks,
Kurt Anderson
Sr. Programmer/Analyst
CustomCall Data Systems
--
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.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.