Pantek Library
Hosting Provided By
CybrHost
High Speed Hosting

JDBC driver not returning correct table meta data

From: sadeepa <sadeepa(at)lk.opro.net>
Date: Mon Aug 06 2007 - 03:02:23 EDT

while accessing MySQL Enterprise Edition (Version : 5.0.36sp1-enterprise-gpl) using the
JDBC driver (mysql-connector-java-5.0.7 driver), we got the following problem.

One of the tables in our database contains 5 fields with date, time, datetime, timestamp
and year Field Types.

We could retrieve the table field information using getColumns() method, on DatabaseMetadata with mysql-connector-java-3.0.11 driver.

We wanted the same thing to happen with mysql-connector-java-5.0.7 driver.

However when we executed the same code with mysql-connector-java-5.0.7 driver, it returned
null for field size.  

The steps followed and code segments used are as follows:

  1. A database connection (conn) is obtained
  2. Get the database metadata and field sizes using:

    DatabaseMetaData databaseMetaData;

Do you need help?X

    databaseMetaData = conn.getMetaData();

    ResultSet rs = databaseMetaData.getColumns(null,null,tableName,"%");

    while (rs.next()) {

        String fieldSize=rs.getString(7);     }

We could obtain the metadata of other types (varchar / char / etc)

We also used JBuilder's "Database Pilot" tool to check this. It returnd 0 as the size for
the above fields when "mysql-connector-java-5.0.7 driver" is used and the correct size
when "mysql-connector-java-3.0.11" is used.

How to repeat:
1. Create a table with date, time, datetime, timestamp and year Field Types. On MySQL
5.0.36sp1-enterprise-gpl

2. Create a database connection to the MySql Enterprise Edition DB and mysql-connector-java-5.0.7  

Do you need more help?X

3. Try to get the database metadata and field sizes using:

    DatabaseMetaData databaseMetaData;
    databaseMetaData = conn.getMetaData();     ResultSet rs = databaseMetaData.getColumns(null,null,tableName,"%");     while (rs.next()) {

        String fieldSize=rs.getString(7);     }
4. You will receive null for the field size instead of the expected value.

When we connected to the same database using mysql-connector-odbc-3.51.16-win32 we were able to receive the expected results.

--

View this message in context: http://www.nabble.com/JDBC-driver-not-returning-correct-table-meta-data-tf4222562.html#a12011868 Sent from the MySQL - Bugs mailing list archive at Nabble.com.

--

MySQL Bugs Mailing List
For list archives: http://lists.mysql.com/bugs To unsubscribe: http://lists.mysql.com/bugs?unsub=lists@pantek.com Received on Mon Aug 6 03:02:36 2007

This archive was generated by hypermail 2.1.8 : Thu Aug 09 2007 - 19:30:40 EDT


Contact Us  Legal Notices  Order Services Online 
Pantek Home  Privacy Policy  IT news  Site Map  Pantek Library