List:Bugs« Previous MessageNext Message »
From:sadeepa Date:August 6 2007 9:02am
Subject:JDBC driver not returning correct table meta data
View as plain text  
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;

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

Thread
JDBC driver not returning correct table meta datasadeepa6 Aug
  • Re: JDBC driver not returning correct table meta dataValeriy Kravchuk6 Aug