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



On 2/11/2013 5:39 PM, James H. H. Lampert wrote:
Dear Buck (et al):

Excuse my top-posting, but I noticed that a number of JDBC objects need
to be explicitly disposed of. Does anything here have that requirement?

JDBCR4 has an interesting way to handle that. It isn't often that we
need to individually free memory; more typically we free up a group of
objects when we're done with a series of functions. Check out
jdbc_begin_object_group and jdbc_end_object_group in JDBCR4.

At any rate, thanks, Buck; I think you almost certainly managed to save
my butt here.

I found Scott's coding / thinking quite clear despite my utter amateur
status as an OO programmer. What I personally found helpful was to look
at the Javadoc and the RPG code at the same time. Then, writing new
wrappers was not so hard. I tend to work in short bursts: first, an
object declaration and a compile. Then a PR declaration and a compile.
Baby steps.

One other thing, though: how do you pass a java "null" from RPG?

Not sure I've actually done that, but I'd go with myJavaObject = *null;

On 2/11/13 12:24 PM, Buck Calabro wrote:
#b D DatabaseMetaData...
#b D s O CLASS(*JAVA:
#b D 'java.sql.DatabaseMetaData')
. . .
#b D DB_GetMetaData...
#b D PR like(DatabaseMetaData)
#b D conn like(Connection) const
. . .
#b d getDatabaseMetaData...
#b d pr extproc(*JAVA:
#b d 'java.sql.Connection':
#b d 'getMetaData')
#b d like(DatabaseMetaData)
. . .
#b P DB_GetMetaData B export
#b D DB_GetMetaData PI like(DatabaseMetaData)
#b D conn like(Connection) const
#b D temp s like(DatabaseMetaData)
#b D dbmd s like(DatabaseMetaData)
#b /free
#b jdbc_begin_object_group(50);
#b
#b monitor;
#b temp = getDatabaseMetaData( conn );
#b jdbc_end_object_group(temp: dbmd);
#b on-error;
#b jdbc_end_object_group();
#b return *NULL;
#b endmon;
#b
#b return dbmd;
#b /end-free
#b P E

More fragmentary code to read the keys. I thought it was an interesting
problem and had some time while I was crunching a 15M row database.

d catalog s like(jString)
d schema s like(jString)
d table s like(jString)
d keysRS s like(ResultSet)
d keysRSMeta s like(ResultSetMetaData)
d keysColCount s 10i 0
d c s 10i 0
d column s 100a varying
d success s 1n

// getPrimaryKeys
// returns a result set of keys
// or SQLException if error
#b d getDatabaseMetaData_getPrimaryKeys...
#b d pr ExtProc(*JAVA:
#b d 'java.sql.DatabaseMetaData':
#b d 'getPrimaryKeys')
#b d like(ResultSet)
#b D catalog like(jString)
#b D schema like(jString)
#b D table like(jString)

#b d char2str pr like(jString)
#b d EXTPROC(*JAVA
#b d :'java.lang.String'
#b d :*CONSTRUCTOR)
#b d inp_char 32767A VARYING const


// after getting database metadata, get primary key info
catalog = char2str('cccccc');
schema = char2str('ssssss');
table = char2str('tttttt');
keysRS = getDatabaseMetaData_getPrimaryKeys(dbmd:
catalog:
schema:
table);

keysRSMeta = JDBC_GetMetaData(keysRS);
keysColCount = JDBC_GetColCount(keysRSMeta);

// print the column names of the metadata result set
for c = 1 to keysColCount;
column = JDBC_GetColName(keysRSMeta:
c);
except prtCol;
endfor;

// print the actual keys
success = *on;

dow success;
success = JDBC_nextRow(keysRS);

if success;
for c = 1 to keysColCount;
column = JDBC_GetCol(keysRS:
c:
nullInd);
if nullInd;
column = 'null';
endif;
except prtCol;

endfor;
else;
except noNextRow;
endif;
enddo;

--buck

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.