JDBC driver not returning correct table meta data

JDBC driver not returning correct table meta data

am 06.08.2007 09:02:23 von sadeepa

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-tabl e-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=gcdmb-bugs@m.gmane.org

Re: JDBC driver not returning correct table meta data

am 06.08.2007 09:16:33 von Valeriy Kravchuk

Hi,

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

If you are a customer, please, open a new support issue at
https://support.mysql.com (or send me your contract number, and I'll do it
myself).

If you are not a customer, please, report this as Connector/J bug at
bugs.mysql.com.

Best regards,
--
Valeriy Kravchuk, Senior Support Engineer
MySQL AB, Kiev, Ukraine, www.mysql.com


--
MySQL Bugs Mailing List
For list archives: http://lists.mysql.com/bugs
To unsubscribe: http://lists.mysql.com/bugs?unsub=gcdmb-bugs@m.gmane.org