× 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 1:18 PM, James H. H. Lampert wrote:
I think that under the circumstances, I've already been asking more than
too much of Mr. Klement, and so if somebody else can coach me on this,
please do.

Which is to say that Sctt, you need to concentrate on healing.

But as to the matter where I need help: it appears that I'm going to
have to do some things that involve non-trivial extensions to JDBCR4.
Case in point, to find out what a file's primary keys are, through a
JDBC connection, it seems I need to do something like:

conn = DriverManager.getConnection(DB_URL,USER,PASS);
DatabaseMetaData dmd = conn.getMetaData();
ResultSet mdrs = dmd.getPrimaryKeys(null, "EMP", "Employees");
while (mdrs.next()) {
System.out.println("column name: /" + mdrs.getString("COLUMN_NAME")
+ "/ KEY_SEQ: /"+ mdrs.getString("KEY_SEQ")
+ "/ PK_NAME: /" + mdrs.getString("PK_NAME") + "/");
};

(assuming we're looking at a table called "Employees," in a schema
called "EMP," from the TutorialsPoint JDBC tutorial). This Java code
works fine for both DB2/400 and MySQL. MySql produces:
column name: /id/ KEY_SEQ: /1/ PK_NAME: /PRIMARY/

while DB2/400 produces:
column name: /ID/ KEY_SEQ: /1/ PK_NAME: /Q_EMP_EMPLOYEES_ID_00001/

The problem is that JDBCR4 doesn't appear to have any front-end for the
DatabaseMetaData class, let alone the Connection.getMetaData() and
DatabaseMetaData.getPrimaryKeys(<catalog>, <schema>, <table>) methods.

While I managed to successfully front-end the GetColLabel(<index>),
getPrecision(<index>), and getScale(<index>) methods, those appear to be
Tinkertoys compared with front-ending DatabaseMetaData.

Can anybody help?

I didn't do getPrimaryKeys, but see if this gets you moving in the right
direction.

JDBC_H

#b D DatabaseMetaData...
#b D s O CLASS(*JAVA:
#b D 'java.sql.DatabaseMetaData')


#b *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#b * DB_GetMetaData(): Get DatabaseMetaData
#b *
#b * connection = (input) Connection to get metadata for
#b *
#b * Returns a database metadata, or *NULL upon failure
#b *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#b D DB_GetMetaData...
#b D PR like(DatabaseMetaData)
#b D conn like(Connection) const
#b
#b
#b *+++++++++++++++++++++++++++++++++++++++++++++++++++++++1+++++
#b * DBMD_GetDriverVersion(): Get JDBC driver version
#b *
#b * dbmd = (input) DatabaseMetaData
#b *
#b * Returns a string containing the driver version, or *NULL upon error
#b *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#b D DBMD_GetDriverVersion...
#b D PR 32 varying
#b D dbmd like(DatabaseMetaData) const
#b
#b
#b *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#b * DBMD_GetDatabaseProductName(): Get Database Product name
#b *
#b * dbmd = (input) DatabaseMetaData
#b *
#b * Returns a string containing the name of the database product
#b *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#b D DBMD_GetDatabaseProductName...
#b D PR 256 varying
#b D dbmd like(DatabaseMetaData) const



JDBCR4 source

#b d getDatabaseMetaData...
#b d pr extproc(*JAVA:
#b d 'java.sql.Connection':
#b d 'getMetaData')
#b d like(DatabaseMetaData)
#b
#b d getDatabaseMetaData_getDriverVersion...
#b d pr ExtProc(*JAVA:
#b d 'java.sql.DatabaseMetaData':
#b d 'getDriverVersion')
#b d like(jString)
#b
#b d getDatabaseMetaData_getDatabaseProductName...
#b d pr ExtProc(*JAVA:
#b d 'java.sql.DatabaseMetaData':
#b d 'getDatabaseProductName')
#b d like(jString)

#b *+++++++++++++++++++++++++++++++++++++++++++++++++++++++1+++++
#b * DB_GetMetaData(): Get database metadata
#b *
#b * conn = (input) Connection
#b *
#b * Returns a DatabaseMetaData object, or *NULL upon error
#b *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#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
#b
#b
#b *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#b * DBMD_GetDriverVersion(): Get JDBC driver version
#b *
#b * dbmd = (input) DatabaseMetaData
#b *
#b * Returns a string containing the driver version
#b *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#b P DBMD_GetDriverVersion...
#b p B export
#b D DBMD_GetDriverVersion...
#b D PI 32 varying
#b D dbmd like(DatabaseMetaData) const
#b D str s like(jString)
#b D version s 32 varying
#b /free
#b
#b monitor;
#b str = getDatabaseMetaData_getDriverVersion( dbmd );
#b on-error;
#b return '';
#b endmon;
#b
#b version = r(str);
#b return version;
#b /end-free
#b P E
#b
#b
#b *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#b * DBMD_GetDatabaseProductName(): Get Database Product name
#b *
#b * dbmd = (input) DatabaseMetaData
#b *
#b * Returns a string containing the name of the database product
#b *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#b P DBMD_GetDatabaseProductName...
#b p B export
#b D DBMD_GetDatabaseProductName...
#b D PI 256 varying
#b D dbmd like(DatabaseMetaData) const
#b D str s like(jString)
#b D name s 256 varying
#b /free
#b
#b monitor;
#b str = getDatabaseMetaData_getDatabaseProductName( dbmd );
#b on-error;
#b return '';
#b endmon;
#b
#b name = r(str);
#b return name;
#b /end-free
#b P E


Program fragment that uses the above

// get the database metadata
dbmd = DB_GetMetaData(conn);
if (dbmd = *NULL);
dump(a) 'getDatabaseMetaData';
jdbc_close(conn);
return;
endif;
DriverVer = DBMD_GetDriverVersion(dbmd);
DBProduct = DBMD_GetDatabaseProductName(dbmd);


--buck

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

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.