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

Java & SQL - How to get it to work?

345 views
Skip to first unread message

Mr. K.V.B.L.

unread,
Jun 15, 2009, 3:29:12 PM6/15/09
to
Why is this? I have a simple program from a vendor that import
java.io.* and java.sql.*. It attempts to do some basic stuff through
SQL: create a table, insert some trivial records, select those
records, drop the table. Even they aren't sure how it should work
because they built in 3 different JDBC driver options based on
commandline switches:

com.ibm.as400.access.AS400JDBCDriver
COM.ibm.db2.jdbc.app.DB2Driver
com.ibm.db2.jcc.DB2Driver (not sure about this one)

I can't seem to anything to load by default without some SQLException
being thrown, mostly java.lang.UnsatisfiedLinkError. I don't use Java
in my day-to-day activities but I sure thought it would be easier than
this. I only need to make a connection to the DB on the same machine
that the program is running on, which in this case is the 400 itself.
My searches say that com.ibm.db2.jcc.app.DB2Driver is the 'native'
driver to use but I can't get it to load. I'm finding a name
discrepancy between com.ibm.db2.jcc.DB2Driver and
com.ibm.db2.jcc.app.DB2Driver, although the one without the 'app' is
one I can at least find on the system.

Kelly Beard

unread,
Jun 15, 2009, 3:47:12 PM6/15/09
to

We have the following Java-related options:
5761JC1 *BASE 5050 IBM Toolbox for Java
5761JC1 *BASE 2924 IBM Toolbox for Java
5761JV1 *BASE 5050 IBM Developer Kit for Java
5761JV1 *BASE 2924 IBM Developer Kit for Java
5761JV1 6 5106 Java Developer Kit 1.4
5761JV1 7 5107 Java Developer Kit 5.0
5761JV1 8 5108 J2SE 5.0 32 bit
5761JV1 10 5110 Java SE Development Kit 6
5761JV1 11 5111 Java SE 6 32 bit

Kelly Beard

unread,
Jun 15, 2009, 4:49:52 PM6/15/09
to

I'm getting closer - maybe. Found through another post to use /QIBM/
ProdData/Java400/ext/db2_classes.jar. I had to change the name of the
driver in the code from com.ibm.db2.jcc.app.DB2Driver (which was wrong
anyway, see the "jcc" part) to com.ibm.db2.jdbc.app.DB2Driver. Now
I'm getting this:

com.ibm.db2.jdbc.app.DB2JDBCDataException: CCSID value is not
valid.
at java.lang.Throwable.<init>(Throwable.java:
195)
at java.lang.Exception.<init>(Exception.java:
41)
at java.sql.SQLException.<init>(SQLException.java:
40)
at com.ibm.db2.jdbc.app.DB2JDBCDataException.<init>
(DB2JDBCDataException.java:45)
at com.ibm.db2.jdbc.app.DB2SQLException.createException
(DB2SQLException.java:94)
at com.ibm.db2.jdbc.app.DB2Driver.<init>(DB2Driver.java:
754)
at com.ibm.as400.system.nativ.JavaLangClassObject.newInstance0
(JavaLangClassObject.java:164)
at java.lang.Class.newInstance(Class.java:
285)
at as400test.DBTest(as400test.java:
134)
at as400test.main(as400test.java:
113)

CRPence

unread,
Jun 15, 2009, 5:31:50 PM6/15/09
to
Kelly Beard wrote:
>
> <<SNIP>> Now I'm getting this:
>
> com.ibm.db2.jdbc.app.DB2JDBCDataException:
> CCSID value is not valid. <<SNIP>>

Just a SWAG: That the CCSID() being established for the User
Profile is *HEX [aka 65535] which requests not to translate the
data. Requesting no character data translation is problematic for
EBCDIC to ASCII and vice versa. Perhaps by signing on interactively
to the server, signed on as the user making the connection and then
issuing the command CHGPRF CCSID(37) or as any user CHGUSRPRF
TheUser CCSID(37) [or any EBCDIC CCSID value appropriate to the
language used by that user profile; optionally, first issuing
DSPUSRPRF, to review the current CCSID setting] will effect a valid
CCSID value being established for a new connection.

If not that, then a small possibility that file(s) being accessed
have Character data types with the CCSID(65535). However for that,
I would expect the JDBC to just honor the request to treat the data
as binary character string. That is, the results for the character
data would not be readable as ASCII, but the request should function
without any CCSID error.

http://www.google.com/#hl=en&q="+CCSID+value+is+not+valid"+jdbc
FWiW the above search returns the following, and more:
http://www.ibm.com/developerworks/forums/thread.jspa?messageID=13721939&tstart=0
http://www-912.ibm.com/s_dir/slkbase.NSF/0/9ea41ee0c6099d1e86256caa006e4b59?OpenDocument
http://article.gmane.org/gmane.comp.lang.as400.java/10019
http://archive.midrange.com/midrange-l/200802/msg01136.html
http://archive.midrange.com/web400/200702/msg00096.html

Regards, Chuck

dieter...@t-online.de

unread,
Jun 16, 2009, 2:44:35 AM6/16/09
to
where did you get this ugly code from? one starting point could be here:
http://java.sun.com/docs/books/tutorial/jdbc/basics/

Dieter

Dr.Ugo Gagliardelli

unread,
Jun 16, 2009, 4:37:56 AM6/16/09
to
il 15/06/2009 22.49, Scrive Kelly Beard 43839784:

> On Jun 15, 2:47 pm, Kelly Beard <kenverybigl...@gmail.com> wrote:
[...]

> I'm getting this:
>
> com.ibm.db2.jdbc.app.DB2JDBCDataException: CCSID value is not
> valid.
That's because sysval QCCSID is set at 65535 and CCSID attribute of the
job or the usrprf is set at 65535

--
Dr.Ugo Gagliardelli,Modena,ItalyCertifiedUindoscrasherA�ejoAlcoolInside
Spaccamaroni andate a cagare/Spammers not welcome/Spammers v�o � merda
Spamers iros a la mierda/Spamers allez vous faire foutre/Spammers loop
schijten/Spammers macht Euch vom Acker/Spamerzy wypierdalac'

walker.l2

unread,
Jun 16, 2009, 5:44:27 AM6/16/09
to
If you're dealing with CCSID 65535, you may need to change the
"translateBinary" JDBC connection parameter from the default "false"
to "true".

Kelly Beard

unread,
Jun 16, 2009, 11:23:46 AM6/16/09
to
On Jun 16, 1:44 am, dieter.ben...@t-online.de wrote:
> where did you get this ugly code from? one starting point could be here:http://java.sun.com/docs/books/tutorial/jdbc/basics/
>
> Dieter
>

The relative beauty of the code notwithstanding, came from a vendor.
Nevertheless, it should have worked.

Kelly Beard

unread,
Jun 16, 2009, 11:33:28 AM6/16/09
to

Ok. Some of the links that were posted (Chuck) I had found through
Google. I just needed some time to make sense of what the whole CCSID
issue was about. After I changed the name of the driver jar from
db2jcc.jar to db2_classes.jar and the driver classname from
com.ibm.db2.jcc.DB2Driver to com.ibm.db2.jdbc.app.DB2Driver I had our
sysadmin assign my profile CCSID of 37 (funny he didn't know what 37
was...), ran the sample program again and success.

So thanks to everyone for your help and input. I get to touch Java
once every 5 years of so.

Back to my C++ duties I guess.....

Kelly Beard

dieter...@t-online.de

unread,
Jun 16, 2009, 11:32:27 AM6/16/09
to
Hi,

in java its state of the art to have all driver dependent information
outside the java class and the code runs if the environment is set up
properly and you never would have to look inside the code

Dieter

0 new messages