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



Yes, jdbc_freeResult(rs) will throw a null-pointer exception if rs is null.

The code looks pretty good, syntax-wise.

dbmd must be a reference to a java object derived from aConnection.getMetaData().

unique and approximate are going to have to be hex '01' or hex '00'. 1N is an indicator type. In RPG an indicator is either hex 'F1' or hex 'F0'.

This might work:

D getIndexInfo...
D PR ExtProc(*JAVA:
D 'java.sql.DatabaseMetaData':
D 'getIndexInfo')
D like(ResultSet)
D catalog like(jString) const
D schema like(jString) const
D table like(jString) const
D unique 1A value
D approximate 1A value
. . .
P JDBC_GetIndexInfo...
P B export
D JDBC_GetIndexInfo...
D PI like(ResultSet)
D dbmd like(DatabaseMetaData) const
D catalog 32767A varying const options(*varsize)
D schema 32767A varying const options(*varsize)
D table 32767A varying const options(*varsize)
D unique 1A
D approximate 1A
D temp s like(ResultSet)
D rs s like(ResultSet)
D cat s like(jString)
D sch s like(jString)
/free
jdbc_begin_object_group(50);
if (catalog = '*NULL');
cat = *NULL;
else;
cat = s(catalog);
endif;
if (schema = '*NULL');
sch = *NULL;
else;
sch = s(schema);
endif;
monitor;
temp = getIndexInfo(dbmd: cat: sch: s(table):
unique: approximate);
jdbc_end_object_group(temp: rs);
on-error;
jdbc_end_object_group();
return *NULL;
endmon;

return rs;
/end-free
P E

and in the calling program:

rs = JDBC_GetIndexInfo(dbmd: '*NULL': %TRIM(MPLIBR): %TRIM(MPFILE):
x'01': x'01');
jdbc_freeResult(rs);
-----Original Message-----
From: java400-l-bounces@xxxxxxxxxxxx [mailto:java400-l-bounces@xxxxxxxxxxxx] On Behalf Of James H. H. Lampert
Sent: Friday, March 22, 2013 5:09 PM
To: Java 400 List
Subject: JDBCR4 help: having trouble front-ending Java DatabaseMetaData.getIndexInfo() for ILE RPG

With nobody answering on the RPG list . . .

I'm having difficulty adding an RPG front-end for the
DatabaseMetaData.getIndexInfo() method to JDBCR4.

Given that the following Java fragment:
DatabaseMetaData dbmd = conn.getMetaData(); ResultSet indexInfo =
dbmd.getIndexInfo(null, "AQUESTVIEW", "VIEWCUS",
true, true);
while(indexInfo.next()){ System.out.println(" " +
indexInfo.getString(5)
+ " " + indexInfo.getString(6)
+ " " + indexInfo.getShort(7)
+ " " + indexInfo.getShort(8)
+ " " + indexInfo.getString(9)
+ " " + indexInfo.getString(10)); }

produces the expected output of:
AQUESTVIEW VIEWCUS 3 1 CUNMBR A
null null 0 0 null null

can anybody suggest a reason (other than my own inexperience with front-ending Java for RPG) why the following blows up when executed:

(in JDBCR4):
D getIndexInfo...
D PR ExtProc(*JAVA:
D 'java.sql.DatabaseMetaData':
D 'getIndexInfo')
D like(ResultSet)
D catalog like(jString) const
D schema like(jString) const
D table like(jString) const
D unique 1N value
D approximate 1N value
. . .
P JDBC_GetIndexInfo...
P B export
D JDBC_GetIndexInfo...
D PI like(ResultSet)
D dbmd like(DatabaseMetaData) const
D catalog 32767A varying const options(*varsize)
D schema 32767A varying const options(*varsize)
D table 32767A varying const options(*varsize)
D unique 1N
D approximate 1N
D temp s like(ResultSet)
D rs s like(ResultSet)
D cat s like(jString)
D sch s like(jString)
/free
jdbc_begin_object_group(50);
if (catalog = '*NULL');
cat = *NULL;
else;
cat = s(catalog);
endif;
if (schema = '*NULL');
sch = *NULL;
else;
sch = s(schema);
endif;
monitor;
temp = getIndexInfo(dbmd: cat: sch: s(table):
unique: approximate);
jdbc_end_object_group(temp: rs);
on-error;
jdbc_end_object_group();
return *NULL;
endmon;

return rs;
/end-free
P E

and in the calling program:

rs = JDBC_GetIndexInfo(dbmd: '*NULL': %TRIM(MPLIBR): %TRIM(MPFILE):
*ON: *ON);
jdbc_freeResult(rs);

(Note that, as with my front-end for DatabaseMetaData.getPrimaryKeys(),
there is code in the front-end to turn the quoted string '*NULL' into an actual *NULL passed to the Java method.)

It blows up at the freeResult call. In my own miniscule experience with expanding JDBCR4, this usually happens if the result set passed is null.
That suggests that I've screwed up something in the call to getIndexInfo, such that it's returning *NULL instead of a result set.

But what?

--
JHHL
--
This is the Java Programming on and around the IBM i (JAVA400-L) mailing list To post a message email: JAVA400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/java400-l
or email: JAVA400-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/java400-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.