× 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.



JDBC abstracts away this kind of difference between underlying databases. Use (Connection)con.setSchema(String schemaName) rather than trying to work out which database engine you are using. Don't use the "SET SCHEMA" or "USE " statements. Let the driver work out what is the appropriate statement.

-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of James H. H. Lampert
Sent: Monday, February 04, 2013 12:03 PM
To: Midrange Systems Technical Discussion
Subject: Re: Starting to experiment with Scott Klement's JDBCR4 -- what's the DB2/400 equivalent to MySQL "USE"

Thanks, Scott and Coy; "SET SCHEMA" worked, and the test program got as far as creating and populating RPGTEST.

But then I ran into another error that really blew things up: DB2/400 didn't like the double quotes in the test query, and I ended up with multiple dumps going both to STDOUT and to spool files. As soon as I changed them to single quotes, everything worked perfectly.

Hmm. So MySQL "USE FOO" and DB2/400 "SET SCHEMA FOO" are more-or-less equivalent. And DB2/400 doesn't like "USE FOO," and it appears that MySQL doesn't like "SET SCHEMA FOO."

That adds complexity to the task of writing something that can talk to any database that has a JDBC driver. Then again, now that I think about it, the nature of my project suggests that I'm either going to be fully qualifying every table name, every time I call anything that takes a table name, or specifying the schema when opening the connection. (Which would work better?)

And Scott: Thanks for your detailed response Now that the immediate problem is solved, I'm going to re-read it in depth, in order to learn as much as I can from it. How are you feeling?

--
JHHL
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list To post a message email: MIDRANGE-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/midrange-l.




As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
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.