How to access JDBC Meta Data functions like getColumns or getMetaData

Asked by firefoxtester

I want to be able to get column datatype info for a table.

In the JDBC documentation [1] it lists the following functions:

JDBC Meta Data functions
The JDBC client driver supports the following Meta Data functions:
getColumns
getColumnPrivileges
getMetaData
getTypeInfo
getTables
getTableTypes

Any ideas how I might call them from JayDeBeAPI?

[1] http://www.filemaker.com/support/product/docs/11/fmp/fm11_odbc_jdbc_guide_en.pdf
(page 55)

Question information

Language:
English Edit question
Status:
Solved
For:
JayDeBeApi Edit question
Assignee:
No assignee Edit question
Solved by:
firefoxtester
Solved:
Last query:
Last reply:
Revision history for this message
firefoxtester (gregpinero) said :
#1
Revision history for this message
Bastian (baztian) said :
#2

JayDeBeApi exposes a Python DB-API 2.0. So you should find your information here: http://www.python.org/dev/peps/pep-0249/#description
Please report if you are still missing something.

BTW: Please try to avoid double posting.

Revision history for this message
firefoxtester (gregpinero) said :
#3

I should have mentioned I want to get all the tables too. I updated my SO question to reflect that.

It looks like the DBAPI doesn't offer that. So I'm guessing that makes this a Jpype question instead?

Revision history for this message
Bastian (baztian) said :
#4

Usually your database offers this kind of information in system tables. Please check your database vendor manual. The advantage of the JDBC-methods is of course the platform independence. If you really want you can access JayDeBeApis Java JDBC connection using conn.jconn

jconn is a java.sql.Connection (http://docs.oracle.com/javase/6/docs/api/java/sql/Connection.html) and offers getMetaData()

To get all tables for example use
conn.jconn.getMetaData().getTables() and iterate over the ResultSet. See the link above for details and to navigate through the class documentation.

And yes, it's more of a JPype question. But maybe it's a good idea to extend JayDeBeApi to allow access to general (non .description) metadata.

Revision history for this message
Bastian (baztian) said :
#5
Revision history for this message
firefoxtester (gregpinero) said :
#6

Thanks again! It seems like I'm on the right track. Any idea why I might be getting this error?

> conn.jconn.metadata.getTables()
*** RuntimeError: No matching overloads found. at src/native/common/jp_method.cpp:121

Revision history for this message
firefoxtester (gregpinero) said :
#7

Ok, I got it working. I just had to pass in the same parameters the method was expecting. I've posted the working code on the Stack Overflow question.

http://stackoverflow.com/questions/21027904/using-jpype-how-can-i-access-jdbc-meta-data-functions

Revision history for this message
Bastian (baztian) said :
#8

Thank you, glad you solved the issue.