Bug #1099 DataBaseMetaData.getColumns throws ArrayIndexOutOfBoundsException
Submitted: 19 Aug 2003 8:50 Modified: 20 Aug 2003 9:01
Reporter: [ name withheld ] Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:3.0.8 OS:Microsoft Windows (W2K)
Assigned to: Mark Matthews CPU Architecture:Any

[19 Aug 2003 8:50] [ name withheld ]
Description:
Connecting the driver to MySQL 4.10 depending of the type of the columns DataBaseMetaData.getColumns throws an ArrayIndexOutOfBoundsException. The nightly snapshot shows the same behaviour.

How to repeat:
Connect the driver to a MySQL 4.10 server.
Execute DataBaseMetaData.getColumns on a table containing a column of type TEXT.

Suggested fix:
changing

                    if (typeInfo != null) {
                        if ((typeInfo.indexOf("enum") != -1)
                                || (typeInfo.indexOf("set") != -1)) {
                            String temp = typeInfo.substring(typeInfo.indexOf(
                                        "("), typeInfo.lastIndexOf(")"));

to

                        int delimPos = typeInfo.indexOf('(');
                        int setPos = typeInfo.indexOf("set");
                        if (delimPos > 0 && ((typeInfo.indexOf("enum") != -1)
                                             || (setPos != -1 && setPos < delimPos))) {
                            String temp = typeInfo.substring(delimPos, typeInfo.lastIndexOf(")"));

works for me.
typeInfo comes in as "text character set latin1" and "set" is interpreted as the columns type in the unfixed snipplet. OTOH the character set may be not expected here.
[19 Aug 2003 9:01] Mark Matthews
Thank you for your bug report. This issue has already been fixed
in the latest released version of that product, which you can download at 
http://www.mysql.com/downloads/
[19 Aug 2003 9:01] Mark Matthews
This should already be fixed in the nightly builds of Connector/J 3.0.8 and 3.1.0 (see http://mmmysql.sourceforge.net/snapshots).
[19 Aug 2003 9:02] Mark Matthews
Sorry, I closed this as already fixed, but it is a different bug. This will be patched ASAP!

Thank you for your bug report.
[20 Aug 2003 9:01] Mark Matthews
Fixed in the source trees. You should be able to test it with a nightly snapshot of either 3.0 or 3.1 from http://mmmysql.sourceforge.net/snapshots/

Thanks for your bug report!