DatabaseMetaData.java
上传用户:tanyanyong
上传日期:2013-06-23
资源大小:1355k
文件大小:231k
源码类别:
电子政务应用
开发平台:
MultiPlatform
- }
- /**
- * Get a comma separated list of time and date functions.
- *
- * @return the list
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public String getTimeDateFunctions() throws java.sql.SQLException {
- return "DAYOFWEEK,WEEKDAY,DAYOFMONTH,DAYOFYEAR,MONTH,DAYNAME,"
- + "MONTHNAME,QUARTER,WEEK,YEAR,HOUR,MINUTE,SECOND,PERIOD_ADD,"
- + "PERIOD_DIFF,TO_DAYS,FROM_DAYS,DATE_FORMAT,TIME_FORMAT,"
- + "CURDATE,CURRENT_DATE,CURTIME,CURRENT_TIME,NOW,SYSDATE,"
- + "CURRENT_TIMESTAMP,UNIX_TIMESTAMP,FROM_UNIXTIME,"
- + "SEC_TO_TIME,TIME_TO_SEC";
- }
- /**
- * Get a description of all the standard SQL types supported by this
- * database. They are ordered by DATA_TYPE and then by how closely the
- * data type maps to the corresponding JDBC SQL type.
- *
- * <P>
- * Each type description has the following columns:
- *
- * <OL>
- * <li>
- * <B>TYPE_NAME</B> String => Type name
- * </li>
- * <li>
- * <B>DATA_TYPE</B> short => SQL data type from java.sql.Types
- * </li>
- * <li>
- * <B>PRECISION</B> int => maximum precision
- * </li>
- * <li>
- * <B>LITERAL_PREFIX</B> String => prefix used to quote a literal (may be
- * null)
- * </li>
- * <li>
- * <B>LITERAL_SUFFIX</B> String => suffix used to quote a literal (may be
- * null)
- * </li>
- * <li>
- * <B>CREATE_PARAMS</B> String => parameters used in creating the type (may
- * be null)
- * </li>
- * <li>
- * <B>NULLABLE</B> short => can you use NULL for this type?
- *
- * <UL>
- * <li>
- * typeNoNulls - does not allow NULL values
- * </li>
- * <li>
- * typeNullable - allows NULL values
- * </li>
- * <li>
- * typeNullableUnknown - nullability unknown
- * </li>
- * </ul>
- *
- * </li>
- * <li>
- * <B>CASE_SENSITIVE</B> boolean=> is it case sensitive?
- * </li>
- * <li>
- * <B>SEARCHABLE</B> short => can you use "WHERE" based on this type:
- *
- * <UL>
- * <li>
- * typePredNone - No support
- * </li>
- * <li>
- * typePredChar - Only supported with WHERE .. LIKE
- * </li>
- * <li>
- * typePredBasic - Supported except for WHERE .. LIKE
- * </li>
- * <li>
- * typeSearchable - Supported for all WHERE ..
- * </li>
- * </ul>
- *
- * </li>
- * <li>
- * <B>UNSIGNED_ATTRIBUTE</B> boolean => is it unsigned?
- * </li>
- * <li>
- * <B>FIXED_PREC_SCALE</B> boolean => can it be a money value?
- * </li>
- * <li>
- * <B>AUTO_INCREMENT</B> boolean => can it be used for an auto-increment
- * value?
- * </li>
- * <li>
- * <B>LOCAL_TYPE_NAME</B> String => localized version of type name (may be
- * null)
- * </li>
- * <li>
- * <B>MINIMUM_SCALE</B> short => minimum scale supported
- * </li>
- * <li>
- * <B>MAXIMUM_SCALE</B> short => maximum scale supported
- * </li>
- * <li>
- * <B>SQL_DATA_TYPE</B> int => unused
- * </li>
- * <li>
- * <B>SQL_DATETIME_SUB</B> int => unused
- * </li>
- * <li>
- * <B>NUM_PREC_RADIX</B> int => usually 2 or 10
- * </li>
- * </ol>
- * </p>
- *
- * @return ResultSet each row is a SQL type description
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- /**
- * Get a description of all the standard SQL types supported by this
- * database. They are ordered by DATA_TYPE and then by how closely the
- * data type maps to the corresponding JDBC SQL type.
- *
- * <P>
- * Each type description has the following columns:
- *
- * <OL>
- * <li>
- * <B>TYPE_NAME</B> String => Type name
- * </li>
- * <li>
- * <B>DATA_TYPE</B> short => SQL data type from java.sql.Types
- * </li>
- * <li>
- * <B>PRECISION</B> int => maximum precision
- * </li>
- * <li>
- * <B>LITERAL_PREFIX</B> String => prefix used to quote a literal (may be
- * null)
- * </li>
- * <li>
- * <B>LITERAL_SUFFIX</B> String => suffix used to quote a literal (may be
- * null)
- * </li>
- * <li>
- * <B>CREATE_PARAMS</B> String => parameters used in creating the type (may
- * be null)
- * </li>
- * <li>
- * <B>NULLABLE</B> short => can you use NULL for this type?
- *
- * <UL>
- * <li>
- * typeNoNulls - does not allow NULL values
- * </li>
- * <li>
- * typeNullable - allows NULL values
- * </li>
- * <li>
- * typeNullableUnknown - nullability unknown
- * </li>
- * </ul>
- *
- * </li>
- * <li>
- * <B>CASE_SENSITIVE</B> boolean=> is it case sensitive?
- * </li>
- * <li>
- * <B>SEARCHABLE</B> short => can you use "WHERE" based on this type:
- *
- * <UL>
- * <li>
- * typePredNone - No support
- * </li>
- * <li>
- * typePredChar - Only supported with WHERE .. LIKE
- * </li>
- * <li>
- * typePredBasic - Supported except for WHERE .. LIKE
- * </li>
- * <li>
- * typeSearchable - Supported for all WHERE ..
- * </li>
- * </ul>
- *
- * </li>
- * <li>
- * <B>UNSIGNED_ATTRIBUTE</B> boolean => is it unsigned?
- * </li>
- * <li>
- * <B>FIXED_PREC_SCALE</B> boolean => can it be a money value?
- * </li>
- * <li>
- * <B>AUTO_INCREMENT</B> boolean => can it be used for an auto-increment
- * value?
- * </li>
- * <li>
- * <B>LOCAL_TYPE_NAME</B> String => localized version of type name (may be
- * null)
- * </li>
- * <li>
- * <B>MINIMUM_SCALE</B> short => minimum scale supported
- * </li>
- * <li>
- * <B>MAXIMUM_SCALE</B> short => maximum scale supported
- * </li>
- * <li>
- * <B>SQL_DATA_TYPE</B> int => unused
- * </li>
- * <li>
- * <B>SQL_DATETIME_SUB</B> int => unused
- * </li>
- * <li>
- * <B>NUM_PREC_RADIX</B> int => usually 2 or 10
- * </li>
- * </ol>
- * </p>
- *
- * @return ResultSet each row is a SQL type description
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public java.sql.ResultSet getTypeInfo() throws java.sql.SQLException {
- Field[] fields = new Field[18];
- fields[0] = new Field("", "TYPE_NAME", Types.CHAR, 32);
- fields[1] = new Field("", "DATA_TYPE", Types.SMALLINT, 5);
- fields[2] = new Field("", "PRECISION", Types.INTEGER, 10);
- fields[3] = new Field("", "LITERAL_PREFIX", Types.CHAR, 4);
- fields[4] = new Field("", "LITERAL_SUFFIX", Types.CHAR, 4);
- fields[5] = new Field("", "CREATE_PARAMS", Types.CHAR, 32);
- fields[6] = new Field("", "NULLABLE", Types.SMALLINT, 5);
- fields[7] = new Field("", "CASE_SENSITIVE", Types.CHAR, 3);
- fields[8] = new Field("", "SEARCHABLE", Types.SMALLINT, 3);
- fields[9] = new Field("", "UNSIGNED_ATTRIBUTE", Types.CHAR, 3);
- fields[10] = new Field("", "FIXED_PREC_SCALE", Types.CHAR, 3);
- fields[11] = new Field("", "AUTO_INCREMENT", Types.CHAR, 3);
- fields[12] = new Field("", "LOCAL_TYPE_NAME", Types.CHAR, 32);
- fields[13] = new Field("", "MINIMUM_SCALE", Types.SMALLINT, 5);
- fields[14] = new Field("", "MAXIMUM_SCALE", Types.SMALLINT, 5);
- fields[15] = new Field("", "SQL_DATA_TYPE", Types.INTEGER, 10);
- fields[16] = new Field("", "SQL_DATETIME_SUB", Types.INTEGER, 10);
- fields[17] = new Field("", "NUM_PREC_RADIX", Types.INTEGER, 10);
- byte[][] rowVal = null;
- ArrayList tuples = new ArrayList();
- /*
- * The following are ordered by java.sql.Types, and
- * then by how closely the MySQL type matches the
- * JDBC Type (per spec)
- */
- /*
- * MySQL Type: BIT (silently converted to TINYINT(1))
- * JDBC Type: BIT
- */
- rowVal = new byte[18][];
- rowVal[0] = s2b("BIT");
- rowVal[1] = Integer.toString(java.sql.Types.BIT).getBytes();
- // JDBC Data type
- rowVal[2] = s2b("1"); // Precision
- rowVal[3] = s2b(""); // Literal Prefix
- rowVal[4] = s2b(""); // Literal Suffix
- rowVal[5] = s2b(""); // Create Params
- rowVal[6] = Integer.toString(java.sql.DatabaseMetaData.typeNullable)
- .getBytes();
- // Nullable
- rowVal[7] = s2b("true"); // Case Sensitive
- rowVal[8] = Integer.toString(java.sql.DatabaseMetaData.typeSearchable)
- .getBytes();
- // Searchable
- rowVal[9] = s2b("false"); // Unsignable
- rowVal[10] = s2b("false"); // Fixed Prec Scale
- rowVal[11] = s2b("false"); // Auto Increment
- rowVal[12] = s2b("BIT"); // Locale Type Name
- rowVal[13] = s2b("0"); // Minimum Scale
- rowVal[14] = s2b("0"); // Maximum Scale
- rowVal[15] = s2b("0"); // SQL Data Type (not used)
- rowVal[16] = s2b("0"); // SQL DATETIME SUB (not used)
- rowVal[17] = s2b("10"); // NUM_PREC_RADIX (2 or 10)
- tuples.add(rowVal);
- /*
- * MySQL Type: BOOL (silently converted to TINYINT(1))
- * JDBC Type: BIT
- */
- rowVal = new byte[18][];
- rowVal[0] = s2b("BOOL");
- rowVal[1] = Integer.toString(java.sql.Types.BIT).getBytes();
- // JDBC Data type
- rowVal[2] = s2b("1"); // Precision
- rowVal[3] = s2b(""); // Literal Prefix
- rowVal[4] = s2b(""); // Literal Suffix
- rowVal[5] = s2b(""); // Create Params
- rowVal[6] = Integer.toString(java.sql.DatabaseMetaData.typeNullable)
- .getBytes();
- // Nullable
- rowVal[7] = s2b("true"); // Case Sensitive
- rowVal[8] = Integer.toString(java.sql.DatabaseMetaData.typeSearchable)
- .getBytes();
- // Searchable
- rowVal[9] = s2b("false"); // Unsignable
- rowVal[10] = s2b("false"); // Fixed Prec Scale
- rowVal[11] = s2b("false"); // Auto Increment
- rowVal[12] = s2b("BOOL"); // Locale Type Name
- rowVal[13] = s2b("0"); // Minimum Scale
- rowVal[14] = s2b("0"); // Maximum Scale
- rowVal[15] = s2b("0"); // SQL Data Type (not used)
- rowVal[16] = s2b("0"); // SQL DATETIME SUB (not used)
- rowVal[17] = s2b("10"); // NUM_PREC_RADIX (2 or 10)
- tuples.add(rowVal);
- /*
- * MySQL Type: TINYINT
- * JDBC Type: TINYINT
- */
- rowVal = new byte[18][];
- rowVal[0] = s2b("TINYINT");
- rowVal[1] = Integer.toString(java.sql.Types.TINYINT).getBytes();
- // JDBC Data type
- rowVal[2] = s2b("3"); // Precision
- rowVal[3] = s2b(""); // Literal Prefix
- rowVal[4] = s2b(""); // Literal Suffix
- rowVal[5] = s2b("[(M)] [UNSIGNED] [ZEROFILL]"); // Create Params
- rowVal[6] = Integer.toString(java.sql.DatabaseMetaData.typeNullable)
- .getBytes();
- // Nullable
- rowVal[7] = s2b("false"); // Case Sensitive
- rowVal[8] = Integer.toString(java.sql.DatabaseMetaData.typeSearchable)
- .getBytes();
- // Searchable
- rowVal[9] = s2b("true"); // Unsignable
- rowVal[10] = s2b("false"); // Fixed Prec Scale
- rowVal[11] = s2b("true"); // Auto Increment
- rowVal[12] = s2b("TINYINT"); // Locale Type Name
- rowVal[13] = s2b("0"); // Minimum Scale
- rowVal[14] = s2b("0"); // Maximum Scale
- rowVal[15] = s2b("0"); // SQL Data Type (not used)
- rowVal[16] = s2b("0"); // SQL DATETIME SUB (not used)
- rowVal[17] = s2b("10"); // NUM_PREC_RADIX (2 or 10)
- tuples.add(rowVal);
- /*
- * MySQL Type: BIGINT
- * JDBC Type: BIGINT
- */
- rowVal = new byte[18][];
- rowVal[0] = s2b("BIGINT");
- rowVal[1] = Integer.toString(java.sql.Types.BIGINT).getBytes();
- // JDBC Data type
- rowVal[2] = s2b("19"); // Precision
- rowVal[3] = s2b(""); // Literal Prefix
- rowVal[4] = s2b(""); // Literal Suffix
- rowVal[5] = s2b("[(M)] [UNSIGNED] [ZEROFILL]"); // Create Params
- rowVal[6] = Integer.toString(java.sql.DatabaseMetaData.typeNullable)
- .getBytes();
- // Nullable
- rowVal[7] = s2b("false"); // Case Sensitive
- rowVal[8] = Integer.toString(java.sql.DatabaseMetaData.typeSearchable)
- .getBytes();
- // Searchable
- rowVal[9] = s2b("true"); // Unsignable
- rowVal[10] = s2b("false"); // Fixed Prec Scale
- rowVal[11] = s2b("true"); // Auto Increment
- rowVal[12] = s2b("BIGINT"); // Locale Type Name
- rowVal[13] = s2b("0"); // Minimum Scale
- rowVal[14] = s2b("0"); // Maximum Scale
- rowVal[15] = s2b("0"); // SQL Data Type (not used)
- rowVal[16] = s2b("0"); // SQL DATETIME SUB (not used)
- rowVal[17] = s2b("10"); // NUM_PREC_RADIX (2 or 10)
- tuples.add(rowVal);
- /*
- * MySQL Type: LONG VARBINARY
- * JDBC Type: LONGVARBINARY
- */
- rowVal = new byte[18][];
- rowVal[0] = s2b("LONG VARBINARY");
- rowVal[1] = Integer.toString(java.sql.Types.LONGVARBINARY).getBytes();
- // JDBC Data type
- rowVal[2] = s2b("16777215"); // Precision
- rowVal[3] = s2b("'"); // Literal Prefix
- rowVal[4] = s2b("'"); // Literal Suffix
- rowVal[5] = s2b(""); // Create Params
- rowVal[6] = Integer.toString(java.sql.DatabaseMetaData.typeNullable)
- .getBytes();
- // Nullable
- rowVal[7] = s2b("true"); // Case Sensitive
- rowVal[8] = Integer.toString(java.sql.DatabaseMetaData.typeSearchable)
- .getBytes();
- // Searchable
- rowVal[9] = s2b("false"); // Unsignable
- rowVal[10] = s2b("false"); // Fixed Prec Scale
- rowVal[11] = s2b("false"); // Auto Increment
- rowVal[12] = s2b("LONG VARBINARY"); // Locale Type Name
- rowVal[13] = s2b("0"); // Minimum Scale
- rowVal[14] = s2b("0"); // Maximum Scale
- rowVal[15] = s2b("0"); // SQL Data Type (not used)
- rowVal[16] = s2b("0"); // SQL DATETIME SUB (not used)
- rowVal[17] = s2b("10"); // NUM_PREC_RADIX (2 or 10)
- tuples.add(rowVal);
- /*
- * MySQL Type: MEDIUMBLOB
- * JDBC Type: LONGVARBINARY
- */
- rowVal = new byte[18][];
- rowVal[0] = s2b("MEDIUMBLOB");
- rowVal[1] = Integer.toString(java.sql.Types.LONGVARBINARY).getBytes();
- // JDBC Data type
- rowVal[2] = s2b("16777215"); // Precision
- rowVal[3] = s2b("'"); // Literal Prefix
- rowVal[4] = s2b("'"); // Literal Suffix
- rowVal[5] = s2b(""); // Create Params
- rowVal[6] = Integer.toString(java.sql.DatabaseMetaData.typeNullable)
- .getBytes();
- // Nullable
- rowVal[7] = s2b("true"); // Case Sensitive
- rowVal[8] = Integer.toString(java.sql.DatabaseMetaData.typeSearchable)
- .getBytes();
- // Searchable
- rowVal[9] = s2b("false"); // Unsignable
- rowVal[10] = s2b("false"); // Fixed Prec Scale
- rowVal[11] = s2b("false"); // Auto Increment
- rowVal[12] = s2b("MEDIUMBLOB"); // Locale Type Name
- rowVal[13] = s2b("0"); // Minimum Scale
- rowVal[14] = s2b("0"); // Maximum Scale
- rowVal[15] = s2b("0"); // SQL Data Type (not used)
- rowVal[16] = s2b("0"); // SQL DATETIME SUB (not used)
- rowVal[17] = s2b("10"); // NUM_PREC_RADIX (2 or 10)
- tuples.add(rowVal);
- /*
- * MySQL Type: LONGBLOB
- * JDBC Type: LONGVARBINARY
- */
- rowVal = new byte[18][];
- rowVal[0] = s2b("LONGBLOB");
- rowVal[1] = Integer.toString(java.sql.Types.LONGVARBINARY).getBytes();
- // JDBC Data type
- rowVal[2] = Integer.toString(Integer.MAX_VALUE).getBytes();
- // Precision
- rowVal[3] = s2b("'"); // Literal Prefix
- rowVal[4] = s2b("'"); // Literal Suffix
- rowVal[5] = s2b(""); // Create Params
- rowVal[6] = Integer.toString(java.sql.DatabaseMetaData.typeNullable)
- .getBytes();
- // Nullable
- rowVal[7] = s2b("true"); // Case Sensitive
- rowVal[8] = Integer.toString(java.sql.DatabaseMetaData.typeSearchable)
- .getBytes();
- // Searchable
- rowVal[9] = s2b("false"); // Unsignable
- rowVal[10] = s2b("false"); // Fixed Prec Scale
- rowVal[11] = s2b("false"); // Auto Increment
- rowVal[12] = s2b("LONGBLOB"); // Locale Type Name
- rowVal[13] = s2b("0"); // Minimum Scale
- rowVal[14] = s2b("0"); // Maximum Scale
- rowVal[15] = s2b("0"); // SQL Data Type (not used)
- rowVal[16] = s2b("0"); // SQL DATETIME SUB (not used)
- rowVal[17] = s2b("10"); // NUM_PREC_RADIX (2 or 10)
- tuples.add(rowVal);
- /*
- * MySQL Type: BLOB
- * JDBC Type: LONGVARBINARY
- */
- rowVal = new byte[18][];
- rowVal[0] = s2b("BLOB");
- rowVal[1] = Integer.toString(java.sql.Types.LONGVARBINARY).getBytes();
- // JDBC Data type
- rowVal[2] = s2b("65535"); // Precision
- rowVal[3] = s2b("'"); // Literal Prefix
- rowVal[4] = s2b("'"); // Literal Suffix
- rowVal[5] = s2b(""); // Create Params
- rowVal[6] = Integer.toString(java.sql.DatabaseMetaData.typeNullable)
- .getBytes();
- // Nullable
- rowVal[7] = s2b("true"); // Case Sensitive
- rowVal[8] = Integer.toString(java.sql.DatabaseMetaData.typeSearchable)
- .getBytes();
- // Searchable
- rowVal[9] = s2b("false"); // Unsignable
- rowVal[10] = s2b("false"); // Fixed Prec Scale
- rowVal[11] = s2b("false"); // Auto Increment
- rowVal[12] = s2b("BLOB"); // Locale Type Name
- rowVal[13] = s2b("0"); // Minimum Scale
- rowVal[14] = s2b("0"); // Maximum Scale
- rowVal[15] = s2b("0"); // SQL Data Type (not used)
- rowVal[16] = s2b("0"); // SQL DATETIME SUB (not used)
- rowVal[17] = s2b("10"); // NUM_PREC_RADIX (2 or 10)
- tuples.add(rowVal);
- /*
- * MySQL Type: TINYBLOB
- * JDBC Type: LONGVARBINARY
- */
- rowVal = new byte[18][];
- rowVal[0] = s2b("TINYBLOB");
- rowVal[1] = Integer.toString(java.sql.Types.LONGVARBINARY).getBytes();
- // JDBC Data type
- rowVal[2] = s2b("255"); // Precision
- rowVal[3] = s2b("'"); // Literal Prefix
- rowVal[4] = s2b("'"); // Literal Suffix
- rowVal[5] = s2b(""); // Create Params
- rowVal[6] = Integer.toString(java.sql.DatabaseMetaData.typeNullable)
- .getBytes();
- // Nullable
- rowVal[7] = s2b("true"); // Case Sensitive
- rowVal[8] = Integer.toString(java.sql.DatabaseMetaData.typeSearchable)
- .getBytes();
- // Searchable
- rowVal[9] = s2b("false"); // Unsignable
- rowVal[10] = s2b("false"); // Fixed Prec Scale
- rowVal[11] = s2b("false"); // Auto Increment
- rowVal[12] = s2b("TINYBLOB"); // Locale Type Name
- rowVal[13] = s2b("0"); // Minimum Scale
- rowVal[14] = s2b("0"); // Maximum Scale
- rowVal[15] = s2b("0"); // SQL Data Type (not used)
- rowVal[16] = s2b("0"); // SQL DATETIME SUB (not used)
- rowVal[17] = s2b("10"); // NUM_PREC_RADIX (2 or 10)
- tuples.add(rowVal);
- /*
- * MySQL Type: VARBINARY (sliently converted to VARCHAR(M) BINARY)
- * JDBC Type: VARBINARY
- */
- rowVal = new byte[18][];
- rowVal[0] = s2b("VARBINARY");
- rowVal[1] = Integer.toString(java.sql.Types.VARBINARY).getBytes();
- // JDBC Data type
- rowVal[2] = s2b("255"); // Precision
- rowVal[3] = s2b("'"); // Literal Prefix
- rowVal[4] = s2b("'"); // Literal Suffix
- rowVal[5] = s2b("(M)"); // Create Params
- rowVal[6] = Integer.toString(java.sql.DatabaseMetaData.typeNullable)
- .getBytes();
- // Nullable
- rowVal[7] = s2b("true"); // Case Sensitive
- rowVal[8] = Integer.toString(java.sql.DatabaseMetaData.typeSearchable)
- .getBytes();
- // Searchable
- rowVal[9] = s2b("false"); // Unsignable
- rowVal[10] = s2b("false"); // Fixed Prec Scale
- rowVal[11] = s2b("false"); // Auto Increment
- rowVal[12] = s2b("VARBINARY"); // Locale Type Name
- rowVal[13] = s2b("0"); // Minimum Scale
- rowVal[14] = s2b("0"); // Maximum Scale
- rowVal[15] = s2b("0"); // SQL Data Type (not used)
- rowVal[16] = s2b("0"); // SQL DATETIME SUB (not used)
- rowVal[17] = s2b("10"); // NUM_PREC_RADIX (2 or 10)
- tuples.add(rowVal);
- /*
- * MySQL Type: BINARY (silently converted to CHAR(M) BINARY)
- * JDBC Type: BINARY
- */
- rowVal = new byte[18][];
- rowVal[0] = s2b("BINARY");
- rowVal[1] = Integer.toString(java.sql.Types.BINARY).getBytes();
- // JDBC Data type
- rowVal[2] = s2b("255"); // Precision
- rowVal[3] = s2b("'"); // Literal Prefix
- rowVal[4] = s2b("'"); // Literal Suffix
- rowVal[5] = s2b("(M)"); // Create Params
- rowVal[6] = Integer.toString(java.sql.DatabaseMetaData.typeNullable)
- .getBytes();
- // Nullable
- rowVal[7] = s2b("true"); // Case Sensitive
- rowVal[8] = Integer.toString(java.sql.DatabaseMetaData.typeSearchable)
- .getBytes();
- // Searchable
- rowVal[9] = s2b("false"); // Unsignable
- rowVal[10] = s2b("false"); // Fixed Prec Scale
- rowVal[11] = s2b("false"); // Auto Increment
- rowVal[12] = s2b("BINARY"); // Locale Type Name
- rowVal[13] = s2b("0"); // Minimum Scale
- rowVal[14] = s2b("0"); // Maximum Scale
- rowVal[15] = s2b("0"); // SQL Data Type (not used)
- rowVal[16] = s2b("0"); // SQL DATETIME SUB (not used)
- rowVal[17] = s2b("10"); // NUM_PREC_RADIX (2 or 10)
- tuples.add(rowVal);
- /*
- * MySQL Type: LONG VARCHAR
- * JDBC Type: LONGVARCHAR
- */
- rowVal = new byte[18][];
- rowVal[0] = s2b("LONG VARCHAR");
- rowVal[1] = Integer.toString(java.sql.Types.LONGVARCHAR).getBytes();
- // JDBC Data type
- rowVal[2] = s2b("16777215"); // Precision
- rowVal[3] = s2b("'"); // Literal Prefix
- rowVal[4] = s2b("'"); // Literal Suffix
- rowVal[5] = s2b(""); // Create Params
- rowVal[6] = Integer.toString(java.sql.DatabaseMetaData.typeNullable)
- .getBytes();
- // Nullable
- rowVal[7] = s2b("false"); // Case Sensitive
- rowVal[8] = Integer.toString(java.sql.DatabaseMetaData.typeSearchable)
- .getBytes();
- // Searchable
- rowVal[9] = s2b("false"); // Unsignable
- rowVal[10] = s2b("false"); // Fixed Prec Scale
- rowVal[11] = s2b("false"); // Auto Increment
- rowVal[12] = s2b("LONG VARCHAR"); // Locale Type Name
- rowVal[13] = s2b("0"); // Minimum Scale
- rowVal[14] = s2b("0"); // Maximum Scale
- rowVal[15] = s2b("0"); // SQL Data Type (not used)
- rowVal[16] = s2b("0"); // SQL DATETIME SUB (not used)
- rowVal[17] = s2b("10"); // NUM_PREC_RADIX (2 or 10)
- tuples.add(rowVal);
- /*
- * MySQL Type: MEDIUMTEXT
- * JDBC Type: LONGVARCHAR
- */
- rowVal = new byte[18][];
- rowVal[0] = s2b("MEDIUMTEXT");
- rowVal[1] = Integer.toString(java.sql.Types.LONGVARCHAR).getBytes();
- // JDBC Data type
- rowVal[2] = s2b("16777215"); // Precision
- rowVal[3] = s2b("'"); // Literal Prefix
- rowVal[4] = s2b("'"); // Literal Suffix
- rowVal[5] = s2b(""); // Create Params
- rowVal[6] = Integer.toString(java.sql.DatabaseMetaData.typeNullable)
- .getBytes();
- // Nullable
- rowVal[7] = s2b("false"); // Case Sensitive
- rowVal[8] = Integer.toString(java.sql.DatabaseMetaData.typeSearchable)
- .getBytes();
- // Searchable
- rowVal[9] = s2b("false"); // Unsignable
- rowVal[10] = s2b("false"); // Fixed Prec Scale
- rowVal[11] = s2b("false"); // Auto Increment
- rowVal[12] = s2b("MEDIUMTEXT"); // Locale Type Name
- rowVal[13] = s2b("0"); // Minimum Scale
- rowVal[14] = s2b("0"); // Maximum Scale
- rowVal[15] = s2b("0"); // SQL Data Type (not used)
- rowVal[16] = s2b("0"); // SQL DATETIME SUB (not used)
- rowVal[17] = s2b("10"); // NUM_PREC_RADIX (2 or 10)
- tuples.add(rowVal);
- /*
- * MySQL Type: LONGTEXT
- * JDBC Type: LONGVARCHAR
- */
- rowVal = new byte[18][];
- rowVal[0] = s2b("LONGTEXT");
- rowVal[1] = Integer.toString(java.sql.Types.LONGVARCHAR).getBytes();
- // JDBC Data type
- rowVal[2] = Integer.toString(Integer.MAX_VALUE).getBytes();
- // Precision
- rowVal[3] = s2b("'"); // Literal Prefix
- rowVal[4] = s2b("'"); // Literal Suffix
- rowVal[5] = s2b(""); // Create Params
- rowVal[6] = Integer.toString(java.sql.DatabaseMetaData.typeNullable)
- .getBytes();
- // Nullable
- rowVal[7] = s2b("false"); // Case Sensitive
- rowVal[8] = Integer.toString(java.sql.DatabaseMetaData.typeSearchable)
- .getBytes();
- // Searchable
- rowVal[9] = s2b("false"); // Unsignable
- rowVal[10] = s2b("false"); // Fixed Prec Scale
- rowVal[11] = s2b("false"); // Auto Increment
- rowVal[12] = s2b("LONGTEXT"); // Locale Type Name
- rowVal[13] = s2b("0"); // Minimum Scale
- rowVal[14] = s2b("0"); // Maximum Scale
- rowVal[15] = s2b("0"); // SQL Data Type (not used)
- rowVal[16] = s2b("0"); // SQL DATETIME SUB (not used)
- rowVal[17] = s2b("10"); // NUM_PREC_RADIX (2 or 10)
- tuples.add(rowVal);
- /*
- * MySQL Type: TEXT
- * JDBC Type: LONGVARCHAR
- */
- rowVal = new byte[18][];
- rowVal[0] = s2b("TEXT");
- rowVal[1] = Integer.toString(java.sql.Types.LONGVARCHAR).getBytes();
- // JDBC Data type
- rowVal[2] = s2b("65535"); // Precision
- rowVal[3] = s2b("'"); // Literal Prefix
- rowVal[4] = s2b("'"); // Literal Suffix
- rowVal[5] = s2b(""); // Create Params
- rowVal[6] = Integer.toString(java.sql.DatabaseMetaData.typeNullable)
- .getBytes();
- // Nullable
- rowVal[7] = s2b("false"); // Case Sensitive
- rowVal[8] = Integer.toString(java.sql.DatabaseMetaData.typeSearchable)
- .getBytes();
- // Searchable
- rowVal[9] = s2b("false"); // Unsignable
- rowVal[10] = s2b("false"); // Fixed Prec Scale
- rowVal[11] = s2b("false"); // Auto Increment
- rowVal[12] = s2b("TEXT"); // Locale Type Name
- rowVal[13] = s2b("0"); // Minimum Scale
- rowVal[14] = s2b("0"); // Maximum Scale
- rowVal[15] = s2b("0"); // SQL Data Type (not used)
- rowVal[16] = s2b("0"); // SQL DATETIME SUB (not used)
- rowVal[17] = s2b("10"); // NUM_PREC_RADIX (2 or 10)
- tuples.add(rowVal);
- /*
- * MySQL Type: TINYTEXT
- * JDBC Type: LONGVARCHAR
- */
- rowVal = new byte[18][];
- rowVal[0] = s2b("TINYTEXT");
- rowVal[1] = Integer.toString(java.sql.Types.LONGVARCHAR).getBytes();
- // JDBC Data type
- rowVal[2] = s2b("255"); // Precision
- rowVal[3] = s2b("'"); // Literal Prefix
- rowVal[4] = s2b("'"); // Literal Suffix
- rowVal[5] = s2b(""); // Create Params
- rowVal[6] = Integer.toString(java.sql.DatabaseMetaData.typeNullable)
- .getBytes();
- // Nullable
- rowVal[7] = s2b("false"); // Case Sensitive
- rowVal[8] = Integer.toString(java.sql.DatabaseMetaData.typeSearchable)
- .getBytes();
- // Searchable
- rowVal[9] = s2b("false"); // Unsignable
- rowVal[10] = s2b("false"); // Fixed Prec Scale
- rowVal[11] = s2b("false"); // Auto Increment
- rowVal[12] = s2b("TINYTEXT"); // Locale Type Name
- rowVal[13] = s2b("0"); // Minimum Scale
- rowVal[14] = s2b("0"); // Maximum Scale
- rowVal[15] = s2b("0"); // SQL Data Type (not used)
- rowVal[16] = s2b("0"); // SQL DATETIME SUB (not used)
- rowVal[17] = s2b("10"); // NUM_PREC_RADIX (2 or 10)
- tuples.add(rowVal);
- /*
- * MySQL Type: CHAR
- * JDBC Type: CHAR
- */
- rowVal = new byte[18][];
- rowVal[0] = s2b("CHAR");
- rowVal[1] = Integer.toString(java.sql.Types.CHAR).getBytes();
- // JDBC Data type
- rowVal[2] = s2b("255"); // Precision
- rowVal[3] = s2b("'"); // Literal Prefix
- rowVal[4] = s2b("'"); // Literal Suffix
- rowVal[5] = s2b("(M)"); // Create Params
- rowVal[6] = Integer.toString(java.sql.DatabaseMetaData.typeNullable)
- .getBytes();
- // Nullable
- rowVal[7] = s2b("false"); // Case Sensitive
- rowVal[8] = Integer.toString(java.sql.DatabaseMetaData.typeSearchable)
- .getBytes();
- // Searchable
- rowVal[9] = s2b("false"); // Unsignable
- rowVal[10] = s2b("false"); // Fixed Prec Scale
- rowVal[11] = s2b("false"); // Auto Increment
- rowVal[12] = s2b("CHAR"); // Locale Type Name
- rowVal[13] = s2b("0"); // Minimum Scale
- rowVal[14] = s2b("0"); // Maximum Scale
- rowVal[15] = s2b("0"); // SQL Data Type (not used)
- rowVal[16] = s2b("0"); // SQL DATETIME SUB (not used)
- rowVal[17] = s2b("10"); // NUM_PREC_RADIX (2 or 10)
- tuples.add(rowVal);
- /*
- * MySQL Type: NUMERIC (silently converted to DECIMAL)
- * JDBC Type: NUMERIC
- */
- rowVal = new byte[18][];
- rowVal[0] = s2b("NUMERIC");
- rowVal[1] = Integer.toString(java.sql.Types.NUMERIC).getBytes();
- // JDBC Data type
- rowVal[2] = s2b("17"); // Precision
- rowVal[3] = s2b(""); // Literal Prefix
- rowVal[4] = s2b(""); // Literal Suffix
- rowVal[5] = s2b("[(M[,D])] [ZEROFILL]"); // Create Params
- rowVal[6] = Integer.toString(java.sql.DatabaseMetaData.typeNullable)
- .getBytes();
- // Nullable
- rowVal[7] = s2b("false"); // Case Sensitive
- rowVal[8] = Integer.toString(java.sql.DatabaseMetaData.typeSearchable)
- .getBytes();
- // Searchable
- rowVal[9] = s2b("false"); // Unsignable
- rowVal[10] = s2b("false"); // Fixed Prec Scale
- rowVal[11] = s2b("true"); // Auto Increment
- rowVal[12] = s2b("NUMERIC"); // Locale Type Name
- rowVal[13] = s2b("308"); // Minimum Scale
- rowVal[14] = s2b("308"); // Maximum Scale
- rowVal[15] = s2b("0"); // SQL Data Type (not used)
- rowVal[16] = s2b("0"); // SQL DATETIME SUB (not used)
- rowVal[17] = s2b("10"); // NUM_PREC_RADIX (2 or 10)
- tuples.add(rowVal);
- /*
- * MySQL Type: DECIMAL
- * JDBC Type: DECIMAL
- */
- rowVal = new byte[18][];
- rowVal[0] = s2b("DECIMAL");
- rowVal[1] = Integer.toString(java.sql.Types.DECIMAL).getBytes();
- // JDBC Data type
- rowVal[2] = s2b("17"); // Precision
- rowVal[3] = s2b(""); // Literal Prefix
- rowVal[4] = s2b(""); // Literal Suffix
- rowVal[5] = s2b("[(M[,D])] [ZEROFILL]"); // Create Params
- rowVal[6] = Integer.toString(java.sql.DatabaseMetaData.typeNullable)
- .getBytes();
- // Nullable
- rowVal[7] = s2b("false"); // Case Sensitive
- rowVal[8] = Integer.toString(java.sql.DatabaseMetaData.typeSearchable)
- .getBytes();
- // Searchable
- rowVal[9] = s2b("false"); // Unsignable
- rowVal[10] = s2b("false"); // Fixed Prec Scale
- rowVal[11] = s2b("true"); // Auto Increment
- rowVal[12] = s2b("DECIMAL"); // Locale Type Name
- rowVal[13] = s2b("-308"); // Minimum Scale
- rowVal[14] = s2b("308"); // Maximum Scale
- rowVal[15] = s2b("0"); // SQL Data Type (not used)
- rowVal[16] = s2b("0"); // SQL DATETIME SUB (not used)
- rowVal[17] = s2b("10"); // NUM_PREC_RADIX (2 or 10)
- tuples.add(rowVal);
- /*
- * MySQL Type: INTEGER
- * JDBC Type: INTEGER
- */
- rowVal = new byte[18][];
- rowVal[0] = s2b("INTEGER");
- rowVal[1] = Integer.toString(java.sql.Types.INTEGER).getBytes();
- // JDBC Data type
- rowVal[2] = s2b("10"); // Precision
- rowVal[3] = s2b(""); // Literal Prefix
- rowVal[4] = s2b(""); // Literal Suffix
- rowVal[5] = s2b("[(M)] [UNSIGNED] [ZEROFILL]"); // Create Params
- rowVal[6] = Integer.toString(java.sql.DatabaseMetaData.typeNullable)
- .getBytes();
- // Nullable
- rowVal[7] = s2b("false"); // Case Sensitive
- rowVal[8] = Integer.toString(java.sql.DatabaseMetaData.typeSearchable)
- .getBytes();
- // Searchable
- rowVal[9] = s2b("true"); // Unsignable
- rowVal[10] = s2b("false"); // Fixed Prec Scale
- rowVal[11] = s2b("true"); // Auto Increment
- rowVal[12] = s2b("INTEGER"); // Locale Type Name
- rowVal[13] = s2b("0"); // Minimum Scale
- rowVal[14] = s2b("0"); // Maximum Scale
- rowVal[15] = s2b("0"); // SQL Data Type (not used)
- rowVal[16] = s2b("0"); // SQL DATETIME SUB (not used)
- rowVal[17] = s2b("10"); // NUM_PREC_RADIX (2 or 10)
- tuples.add(rowVal);
- /*
- * MySQL Type: INT
- * JDBC Type: INTEGER
- */
- rowVal = new byte[18][];
- rowVal[0] = s2b("INT");
- rowVal[1] = Integer.toString(java.sql.Types.INTEGER).getBytes();
- // JDBC Data type
- rowVal[2] = s2b("10"); // Precision
- rowVal[3] = s2b(""); // Literal Prefix
- rowVal[4] = s2b(""); // Literal Suffix
- rowVal[5] = s2b("[(M)] [UNSIGNED] [ZEROFILL]"); // Create Params
- rowVal[6] = Integer.toString(java.sql.DatabaseMetaData.typeNullable)
- .getBytes();
- // Nullable
- rowVal[7] = s2b("false"); // Case Sensitive
- rowVal[8] = Integer.toString(java.sql.DatabaseMetaData.typeSearchable)
- .getBytes();
- // Searchable
- rowVal[9] = s2b("true"); // Unsignable
- rowVal[10] = s2b("false"); // Fixed Prec Scale
- rowVal[11] = s2b("true"); // Auto Increment
- rowVal[12] = s2b("INT"); // Locale Type Name
- rowVal[13] = s2b("0"); // Minimum Scale
- rowVal[14] = s2b("0"); // Maximum Scale
- rowVal[15] = s2b("0"); // SQL Data Type (not used)
- rowVal[16] = s2b("0"); // SQL DATETIME SUB (not used)
- rowVal[17] = s2b("10"); // NUM_PREC_RADIX (2 or 10)
- tuples.add(rowVal);
- /*
- * MySQL Type: MEDIUMINT
- * JDBC Type: INTEGER
- */
- rowVal = new byte[18][];
- rowVal[0] = s2b("MEDIUMINT");
- rowVal[1] = Integer.toString(java.sql.Types.INTEGER).getBytes();
- // JDBC Data type
- rowVal[2] = s2b("7"); // Precision
- rowVal[3] = s2b(""); // Literal Prefix
- rowVal[4] = s2b(""); // Literal Suffix
- rowVal[5] = s2b("[(M)] [UNSIGNED] [ZEROFILL]"); // Create Params
- rowVal[6] = Integer.toString(java.sql.DatabaseMetaData.typeNullable)
- .getBytes();
- // Nullable
- rowVal[7] = s2b("false"); // Case Sensitive
- rowVal[8] = Integer.toString(java.sql.DatabaseMetaData.typeSearchable)
- .getBytes();
- // Searchable
- rowVal[9] = s2b("true"); // Unsignable
- rowVal[10] = s2b("false"); // Fixed Prec Scale
- rowVal[11] = s2b("true"); // Auto Increment
- rowVal[12] = s2b("MEDIUMINT"); // Locale Type Name
- rowVal[13] = s2b("0"); // Minimum Scale
- rowVal[14] = s2b("0"); // Maximum Scale
- rowVal[15] = s2b("0"); // SQL Data Type (not used)
- rowVal[16] = s2b("0"); // SQL DATETIME SUB (not used)
- rowVal[17] = s2b("10"); // NUM_PREC_RADIX (2 or 10)
- tuples.add(rowVal);
- /*
- * MySQL Type: SMALLINT
- * JDBC Type: SMALLINT
- */
- rowVal = new byte[18][];
- rowVal[0] = s2b("SMALLINT");
- rowVal[1] = Integer.toString(java.sql.Types.SMALLINT).getBytes();
- // JDBC Data type
- rowVal[2] = s2b("5"); // Precision
- rowVal[3] = s2b(""); // Literal Prefix
- rowVal[4] = s2b(""); // Literal Suffix
- rowVal[5] = s2b("[(M)] [UNSIGNED] [ZEROFILL]"); // Create Params
- rowVal[6] = Integer.toString(java.sql.DatabaseMetaData.typeNullable)
- .getBytes();
- // Nullable
- rowVal[7] = s2b("false"); // Case Sensitive
- rowVal[8] = Integer.toString(java.sql.DatabaseMetaData.typeSearchable)
- .getBytes();
- // Searchable
- rowVal[9] = s2b("true"); // Unsignable
- rowVal[10] = s2b("false"); // Fixed Prec Scale
- rowVal[11] = s2b("true"); // Auto Increment
- rowVal[12] = s2b("SMALLINT"); // Locale Type Name
- rowVal[13] = s2b("0"); // Minimum Scale
- rowVal[14] = s2b("0"); // Maximum Scale
- rowVal[15] = s2b("0"); // SQL Data Type (not used)
- rowVal[16] = s2b("0"); // SQL DATETIME SUB (not used)
- rowVal[17] = s2b("10"); // NUM_PREC_RADIX (2 or 10)
- tuples.add(rowVal);
- /*
- * MySQL Type: DOUBLE
- * JDBC Type: FLOAT (is really an alias for DOUBLE from JDBC's perspective)
- */
- rowVal = new byte[18][];
- rowVal[0] = s2b("DOUBLE");
- rowVal[1] = Integer.toString(java.sql.Types.FLOAT).getBytes();
- // JDBC Data type
- rowVal[2] = s2b("17"); // Precision
- rowVal[3] = s2b(""); // Literal Prefix
- rowVal[4] = s2b(""); // Literal Suffix
- rowVal[5] = s2b("[(M,D)] [ZEROFILL]"); // Create Params
- rowVal[6] = Integer.toString(java.sql.DatabaseMetaData.typeNullable)
- .getBytes();
- // Nullable
- rowVal[7] = s2b("false"); // Case Sensitive
- rowVal[8] = Integer.toString(java.sql.DatabaseMetaData.typeSearchable)
- .getBytes();
- // Searchable
- rowVal[9] = s2b("false"); // Unsignable
- rowVal[10] = s2b("false"); // Fixed Prec Scale
- rowVal[11] = s2b("true"); // Auto Increment
- rowVal[12] = s2b("DOUBLE"); // Locale Type Name
- rowVal[13] = s2b("-308"); // Minimum Scale
- rowVal[14] = s2b("308"); // Maximum Scale
- rowVal[15] = s2b("0"); // SQL Data Type (not used)
- rowVal[16] = s2b("0"); // SQL DATETIME SUB (not used)
- rowVal[17] = s2b("10"); // NUM_PREC_RADIX (2 or 10)
- tuples.add(rowVal);
- /*
- * MySQL Type: FLOAT
- * JDBC Type: REAL (this is the SINGLE PERCISION floating point type)
- */
- rowVal = new byte[18][];
- rowVal[0] = s2b("FLOAT");
- rowVal[1] = Integer.toString(java.sql.Types.REAL).getBytes();
- // JDBC Data type
- rowVal[2] = s2b("10"); // Precision
- rowVal[3] = s2b(""); // Literal Prefix
- rowVal[4] = s2b(""); // Literal Suffix
- rowVal[5] = s2b("[(M,D)] [ZEROFILL]"); // Create Params
- rowVal[6] = Integer.toString(java.sql.DatabaseMetaData.typeNullable)
- .getBytes();
- // Nullable
- rowVal[7] = s2b("false"); // Case Sensitive
- rowVal[8] = Integer.toString(java.sql.DatabaseMetaData.typeSearchable)
- .getBytes();
- // Searchable
- rowVal[9] = s2b("false"); // Unsignable
- rowVal[10] = s2b("false"); // Fixed Prec Scale
- rowVal[11] = s2b("true"); // Auto Increment
- rowVal[12] = s2b("FLOAT"); // Locale Type Name
- rowVal[13] = s2b("-38"); // Minimum Scale
- rowVal[14] = s2b("38"); // Maximum Scale
- rowVal[15] = s2b("0"); // SQL Data Type (not used)
- rowVal[16] = s2b("0"); // SQL DATETIME SUB (not used)
- rowVal[17] = s2b("10"); // NUM_PREC_RADIX (2 or 10)
- tuples.add(rowVal);
- /*
- * MySQL Type: DOUBLE
- * JDBC Type: DOUBLE
- */
- rowVal = new byte[18][];
- rowVal[0] = s2b("DOUBLE");
- rowVal[1] = Integer.toString(java.sql.Types.DOUBLE).getBytes();
- // JDBC Data type
- rowVal[2] = s2b("17"); // Precision
- rowVal[3] = s2b(""); // Literal Prefix
- rowVal[4] = s2b(""); // Literal Suffix
- rowVal[5] = s2b("[(M,D)] [ZEROFILL]"); // Create Params
- rowVal[6] = Integer.toString(java.sql.DatabaseMetaData.typeNullable)
- .getBytes();
- // Nullable
- rowVal[7] = s2b("false"); // Case Sensitive
- rowVal[8] = Integer.toString(java.sql.DatabaseMetaData.typeSearchable)
- .getBytes();
- // Searchable
- rowVal[9] = s2b("false"); // Unsignable
- rowVal[10] = s2b("false"); // Fixed Prec Scale
- rowVal[11] = s2b("true"); // Auto Increment
- rowVal[12] = s2b("DOUBLE"); // Locale Type Name
- rowVal[13] = s2b("-308"); // Minimum Scale
- rowVal[14] = s2b("308"); // Maximum Scale
- rowVal[15] = s2b("0"); // SQL Data Type (not used)
- rowVal[16] = s2b("0"); // SQL DATETIME SUB (not used)
- rowVal[17] = s2b("10"); // NUM_PREC_RADIX (2 or 10)
- tuples.add(rowVal);
- /*
- * MySQL Type: DOUBLE PRECISION
- * JDBC Type: DOUBLE
- */
- rowVal = new byte[18][];
- rowVal[0] = s2b("DOUBLE PRECISION");
- rowVal[1] = Integer.toString(java.sql.Types.DOUBLE).getBytes();
- // JDBC Data type
- rowVal[2] = s2b("17"); // Precision
- rowVal[3] = s2b(""); // Literal Prefix
- rowVal[4] = s2b(""); // Literal Suffix
- rowVal[5] = s2b("[(M,D)] [ZEROFILL]"); // Create Params
- rowVal[6] = Integer.toString(java.sql.DatabaseMetaData.typeNullable)
- .getBytes();
- // Nullable
- rowVal[7] = s2b("false"); // Case Sensitive
- rowVal[8] = Integer.toString(java.sql.DatabaseMetaData.typeSearchable)
- .getBytes();
- // Searchable
- rowVal[9] = s2b("false"); // Unsignable
- rowVal[10] = s2b("false"); // Fixed Prec Scale
- rowVal[11] = s2b("true"); // Auto Increment
- rowVal[12] = s2b("DOUBLE PRECISION"); // Locale Type Name
- rowVal[13] = s2b("-308"); // Minimum Scale
- rowVal[14] = s2b("308"); // Maximum Scale
- rowVal[15] = s2b("0"); // SQL Data Type (not used)
- rowVal[16] = s2b("0"); // SQL DATETIME SUB (not used)
- rowVal[17] = s2b("10"); // NUM_PREC_RADIX (2 or 10)
- tuples.add(rowVal);
- /*
- * MySQL Type: REAL (does not map to Types.REAL)
- * JDBC Type: DOUBLE
- */
- rowVal = new byte[18][];
- rowVal[0] = s2b("REAL");
- rowVal[1] = Integer.toString(java.sql.Types.DOUBLE).getBytes();
- // JDBC Data type
- rowVal[2] = s2b("17"); // Precision
- rowVal[3] = s2b(""); // Literal Prefix
- rowVal[4] = s2b(""); // Literal Suffix
- rowVal[5] = s2b("[(M,D)] [ZEROFILL]"); // Create Params
- rowVal[6] = Integer.toString(java.sql.DatabaseMetaData.typeNullable)
- .getBytes();
- // Nullable
- rowVal[7] = s2b("false"); // Case Sensitive
- rowVal[8] = Integer.toString(java.sql.DatabaseMetaData.typeSearchable)
- .getBytes();
- // Searchable
- rowVal[9] = s2b("false"); // Unsignable
- rowVal[10] = s2b("false"); // Fixed Prec Scale
- rowVal[11] = s2b("true"); // Auto Increment
- rowVal[12] = s2b("REAL"); // Locale Type Name
- rowVal[13] = s2b("-308"); // Minimum Scale
- rowVal[14] = s2b("308"); // Maximum Scale
- rowVal[15] = s2b("0"); // SQL Data Type (not used)
- rowVal[16] = s2b("0"); // SQL DATETIME SUB (not used)
- rowVal[17] = s2b("10"); // NUM_PREC_RADIX (2 or 10)
- tuples.add(rowVal);
- /*
- * MySQL Type: VARCHAR
- * JDBC Type: VARCHAR
- */
- rowVal = new byte[18][];
- rowVal[0] = s2b("VARCHAR");
- rowVal[1] = Integer.toString(java.sql.Types.VARCHAR).getBytes();
- // JDBC Data type
- rowVal[2] = s2b("255"); // Precision
- rowVal[3] = s2b("'"); // Literal Prefix
- rowVal[4] = s2b("'"); // Literal Suffix
- rowVal[5] = s2b("(M)"); // Create Params
- rowVal[6] = Integer.toString(java.sql.DatabaseMetaData.typeNullable)
- .getBytes();
- // Nullable
- rowVal[7] = s2b("false"); // Case Sensitive
- rowVal[8] = Integer.toString(java.sql.DatabaseMetaData.typeSearchable)
- .getBytes();
- // Searchable
- rowVal[9] = s2b("false"); // Unsignable
- rowVal[10] = s2b("false"); // Fixed Prec Scale
- rowVal[11] = s2b("false"); // Auto Increment
- rowVal[12] = s2b("VARCHAR"); // Locale Type Name
- rowVal[13] = s2b("0"); // Minimum Scale
- rowVal[14] = s2b("0"); // Maximum Scale
- rowVal[15] = s2b("0"); // SQL Data Type (not used)
- rowVal[16] = s2b("0"); // SQL DATETIME SUB (not used)
- rowVal[17] = s2b("10"); // NUM_PREC_RADIX (2 or 10)
- tuples.add(rowVal);
- /*
- * MySQL Type: ENUM
- * JDBC Type: VARCHAR
- */
- rowVal = new byte[18][];
- rowVal[0] = s2b("ENUM");
- rowVal[1] = Integer.toString(java.sql.Types.VARCHAR).getBytes();
- // JDBC Data type
- rowVal[2] = s2b("65535"); // Precision
- rowVal[3] = s2b("'"); // Literal Prefix
- rowVal[4] = s2b("'"); // Literal Suffix
- rowVal[5] = s2b(""); // Create Params
- rowVal[6] = Integer.toString(java.sql.DatabaseMetaData.typeNullable)
- .getBytes();
- // Nullable
- rowVal[7] = s2b("false"); // Case Sensitive
- rowVal[8] = Integer.toString(java.sql.DatabaseMetaData.typeSearchable)
- .getBytes();
- // Searchable
- rowVal[9] = s2b("false"); // Unsignable
- rowVal[10] = s2b("false"); // Fixed Prec Scale
- rowVal[11] = s2b("false"); // Auto Increment
- rowVal[12] = s2b("ENUM"); // Locale Type Name
- rowVal[13] = s2b("0"); // Minimum Scale
- rowVal[14] = s2b("0"); // Maximum Scale
- rowVal[15] = s2b("0"); // SQL Data Type (not used)
- rowVal[16] = s2b("0"); // SQL DATETIME SUB (not used)
- rowVal[17] = s2b("10"); // NUM_PREC_RADIX (2 or 10)
- tuples.add(rowVal);
- /*
- * MySQL Type: SET
- * JDBC Type: VARCHAR
- */
- rowVal = new byte[18][];
- rowVal[0] = s2b("SET");
- rowVal[1] = Integer.toString(java.sql.Types.VARCHAR).getBytes();
- // JDBC Data type
- rowVal[2] = s2b("64"); // Precision
- rowVal[3] = s2b("'"); // Literal Prefix
- rowVal[4] = s2b("'"); // Literal Suffix
- rowVal[5] = s2b(""); // Create Params
- rowVal[6] = Integer.toString(java.sql.DatabaseMetaData.typeNullable)
- .getBytes();
- // Nullable
- rowVal[7] = s2b("false"); // Case Sensitive
- rowVal[8] = Integer.toString(java.sql.DatabaseMetaData.typeSearchable)
- .getBytes();
- // Searchable
- rowVal[9] = s2b("false"); // Unsignable
- rowVal[10] = s2b("false"); // Fixed Prec Scale
- rowVal[11] = s2b("false"); // Auto Increment
- rowVal[12] = s2b("SET"); // Locale Type Name
- rowVal[13] = s2b("0"); // Minimum Scale
- rowVal[14] = s2b("0"); // Maximum Scale
- rowVal[15] = s2b("0"); // SQL Data Type (not used)
- rowVal[16] = s2b("0"); // SQL DATETIME SUB (not used)
- rowVal[17] = s2b("10"); // NUM_PREC_RADIX (2 or 10)
- tuples.add(rowVal);
- /*
- * MySQL Type: DATE
- * JDBC Type: DATE
- */
- rowVal = new byte[18][];
- rowVal[0] = s2b("DATE");
- rowVal[1] = Integer.toString(java.sql.Types.DATE).getBytes();
- // JDBC Data type
- rowVal[2] = s2b("0"); // Precision
- rowVal[3] = s2b("'"); // Literal Prefix
- rowVal[4] = s2b("'"); // Literal Suffix
- rowVal[5] = s2b(""); // Create Params
- rowVal[6] = Integer.toString(java.sql.DatabaseMetaData.typeNullable)
- .getBytes();
- // Nullable
- rowVal[7] = s2b("false"); // Case Sensitive
- rowVal[8] = Integer.toString(java.sql.DatabaseMetaData.typeSearchable)
- .getBytes();
- // Searchable
- rowVal[9] = s2b("false"); // Unsignable
- rowVal[10] = s2b("false"); // Fixed Prec Scale
- rowVal[11] = s2b("false"); // Auto Increment
- rowVal[12] = s2b("DATE"); // Locale Type Name
- rowVal[13] = s2b("0"); // Minimum Scale
- rowVal[14] = s2b("0"); // Maximum Scale
- rowVal[15] = s2b("0"); // SQL Data Type (not used)
- rowVal[16] = s2b("0"); // SQL DATETIME SUB (not used)
- rowVal[17] = s2b("10"); // NUM_PREC_RADIX (2 or 10)
- tuples.add(rowVal);
- /*
- * MySQL Type: TIME
- * JDBC Type: TIME
- */
- rowVal = new byte[18][];
- rowVal[0] = s2b("TIME");
- rowVal[1] = Integer.toString(java.sql.Types.TIME).getBytes();
- // JDBC Data type
- rowVal[2] = s2b("0"); // Precision
- rowVal[3] = s2b("'"); // Literal Prefix
- rowVal[4] = s2b("'"); // Literal Suffix
- rowVal[5] = s2b(""); // Create Params
- rowVal[6] = Integer.toString(java.sql.DatabaseMetaData.typeNullable)
- .getBytes();
- // Nullable
- rowVal[7] = s2b("false"); // Case Sensitive
- rowVal[8] = Integer.toString(java.sql.DatabaseMetaData.typeSearchable)
- .getBytes();
- // Searchable
- rowVal[9] = s2b("false"); // Unsignable
- rowVal[10] = s2b("false"); // Fixed Prec Scale
- rowVal[11] = s2b("false"); // Auto Increment
- rowVal[12] = s2b("TIME"); // Locale Type Name
- rowVal[13] = s2b("0"); // Minimum Scale
- rowVal[14] = s2b("0"); // Maximum Scale
- rowVal[15] = s2b("0"); // SQL Data Type (not used)
- rowVal[16] = s2b("0"); // SQL DATETIME SUB (not used)
- rowVal[17] = s2b("10"); // NUM_PREC_RADIX (2 or 10)
- tuples.add(rowVal);
- /*
- * MySQL Type: DATETIME
- * JDBC Type: TIMESTAMP
- */
- rowVal = new byte[18][];
- rowVal[0] = s2b("DATETIME");
- rowVal[1] = Integer.toString(java.sql.Types.TIMESTAMP).getBytes();
- // JDBC Data type
- rowVal[2] = s2b("0"); // Precision
- rowVal[3] = s2b("'"); // Literal Prefix
- rowVal[4] = s2b("'"); // Literal Suffix
- rowVal[5] = s2b(""); // Create Params
- rowVal[6] = Integer.toString(java.sql.DatabaseMetaData.typeNullable)
- .getBytes();
- // Nullable
- rowVal[7] = s2b("false"); // Case Sensitive
- rowVal[8] = Integer.toString(java.sql.DatabaseMetaData.typeSearchable)
- .getBytes();
- // Searchable
- rowVal[9] = s2b("false"); // Unsignable
- rowVal[10] = s2b("false"); // Fixed Prec Scale
- rowVal[11] = s2b("false"); // Auto Increment
- rowVal[12] = s2b("DATETIME"); // Locale Type Name
- rowVal[13] = s2b("0"); // Minimum Scale
- rowVal[14] = s2b("0"); // Maximum Scale
- rowVal[15] = s2b("0"); // SQL Data Type (not used)
- rowVal[16] = s2b("0"); // SQL DATETIME SUB (not used)
- rowVal[17] = s2b("10"); // NUM_PREC_RADIX (2 or 10)
- tuples.add(rowVal);
- /*
- * MySQL Type: TIMESTAMP
- * JDBC Type: TIMESTAMP
- */
- rowVal = new byte[18][];
- rowVal[0] = s2b("TIMESTAMP");
- rowVal[1] = Integer.toString(java.sql.Types.TIMESTAMP).getBytes();
- // JDBC Data type
- rowVal[2] = s2b("0"); // Precision
- rowVal[3] = s2b("'"); // Literal Prefix
- rowVal[4] = s2b("'"); // Literal Suffix
- rowVal[5] = s2b("[(M)]"); // Create Params
- rowVal[6] = Integer.toString(java.sql.DatabaseMetaData.typeNullable)
- .getBytes();
- // Nullable
- rowVal[7] = s2b("false"); // Case Sensitive
- rowVal[8] = Integer.toString(java.sql.DatabaseMetaData.typeSearchable)
- .getBytes();
- // Searchable
- rowVal[9] = s2b("false"); // Unsignable
- rowVal[10] = s2b("false"); // Fixed Prec Scale
- rowVal[11] = s2b("false"); // Auto Increment
- rowVal[12] = s2b("TIMESTAMP"); // Locale Type Name
- rowVal[13] = s2b("0"); // Minimum Scale
- rowVal[14] = s2b("0"); // Maximum Scale
- rowVal[15] = s2b("0"); // SQL Data Type (not used)
- rowVal[16] = s2b("0"); // SQL DATETIME SUB (not used)
- rowVal[17] = s2b("10"); // NUM_PREC_RADIX (2 or 10)
- tuples.add(rowVal);
- return buildResultSet(fields, tuples);
- }
- /**
- * JDBC 2.0 Get a description of the user-defined types defined in a
- * particular schema. Schema specific UDTs may have type JAVA_OBJECT,
- * STRUCT, or DISTINCT.
- *
- * <P>
- * Only types matching the catalog, schema, type name and type criteria
- * are returned. They are ordered by DATA_TYPE, TYPE_SCHEM and
- * TYPE_NAME. The type name parameter may be a fully qualified name. In
- * this case, the catalog and schemaPattern parameters are ignored.
- * </p>
- *
- * <P>
- * Each type description has the following columns:
- *
- * <OL>
- * <li>
- * <B>TYPE_CAT</B> String => the type's catalog (may be null)
- * </li>
- * <li>
- * <B>TYPE_SCHEM</B> String => type's schema (may be null)
- * </li>
- * <li>
- * <B>TYPE_NAME</B> String => type name
- * </li>
- * <li>
- * <B>CLASS_NAME</B> String => Java class name
- * </li>
- * <li>
- * <B>DATA_TYPE</B> String => type value defined in java.sql.Types. One
- * of JAVA_OBJECT, STRUCT, or DISTINCT
- * </li>
- * <li>
- * <B>REMARKS</B> String => explanatory comment on the type
- * </li>
- * </ol>
- * </p>
- *
- * <P>
- * <B>Note:</B> If the driver does not support UDTs then an empty result
- * set is returned.
- * </p>
- *
- * @param catalog a catalog name; "" retrieves those without a catalog;
- * null means drop catalog name from the selection criteria
- * @param schemaPattern a schema name pattern; "" retrieves those without a
- * schema
- * @param typeNamePattern a type name pattern; may be a fully qualified
- * name
- * @param types a list of user-named types to include (JAVA_OBJECT, STRUCT,
- * or DISTINCT); null returns all types
- *
- * @return ResultSet - each row is a type description
- *
- * @exception SQLException if a database-access error occurs.
- */
- public java.sql.ResultSet getUDTs(String catalog, String schemaPattern,
- String typeNamePattern, int[] types) throws SQLException {
- Field[] fields = new Field[6];
- fields[0] = new Field("", "TYPE_CAT", Types.VARCHAR, 32);
- fields[1] = new Field("", "TYPE_SCHEM", Types.VARCHAR, 32);
- fields[2] = new Field("", "TYPE_NAME", Types.VARCHAR, 32);
- fields[3] = new Field("", "CLASS_NAME", Types.VARCHAR, 32);
- fields[4] = new Field("", "DATA_TYPE", Types.VARCHAR, 32);
- fields[5] = new Field("", "REMARKS", Types.VARCHAR, 32);
- ArrayList tuples = new ArrayList();
- return buildResultSet(fields, tuples);
- }
- /**
- * What's the url for this database?
- *
- * @return the url or null if it can't be generated
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public String getURL() throws java.sql.SQLException {
- return this.conn.getURL();
- }
- /**
- * What's our user name as known to the database?
- *
- * @return our database user name
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public String getUserName() throws java.sql.SQLException {
- if (this.conn.useHostsInPrivileges()) {
- Statement stmt = null;
- ResultSet rs = null;
- try {
- stmt = this.conn.createStatement();
- if (stmt.getMaxRows() != 0) {
- stmt.setMaxRows(0);
- }
- rs = stmt.executeQuery("SELECT USER()");
- rs.next();
- return rs.getString(1);
- } finally {
- if (rs != null) {
- try {
- rs.close();
- } catch (Exception ex) {
- AssertionFailedException.shouldNotHappen(ex);
- }
- rs = null;
- }
- if (stmt != null) {
- try {
- stmt.close();
- } catch (Exception ex) {
- AssertionFailedException.shouldNotHappen(ex);
- }
- stmt = null;
- }
- }
- } else {
- return this.conn.getUser();
- }
- }
- /**
- * Get a description of a table's columns that are automatically updated
- * when any value in a row is updated. They are unordered.
- *
- * <P>
- * Each column description has the following columns:
- *
- * <OL>
- * <li>
- * <B>SCOPE</B> short => is not used
- * </li>
- * <li>
- * <B>COLUMN_NAME</B> String => column name
- * </li>
- * <li>
- * <B>DATA_TYPE</B> short => SQL data type from java.sql.Types
- * </li>
- * <li>
- * <B>TYPE_NAME</B> String => Data source dependent type name
- * </li>
- * <li>
- * <B>COLUMN_SIZE</B> int => precision
- * </li>
- * <li>
- * <B>BUFFER_LENGTH</B> int => length of column value in bytes
- * </li>
- * <li>
- * <B>DECIMAL_DIGITS</B> short => scale
- * </li>
- * <li>
- * <B>PSEUDO_COLUMN</B> short => is this a pseudo column like an Oracle
- * ROWID
- *
- * <UL>
- * <li>
- * versionColumnUnknown - may or may not be pseudo column
- * </li>
- * <li>
- * versionColumnNotPseudo - is NOT a pseudo column
- * </li>
- * <li>
- * versionColumnPseudo - is a pseudo column
- * </li>
- * </ul>
- *
- * </li>
- * </ol>
- * </p>
- *
- * @param catalog a catalog name; "" retrieves those without a catalog
- * @param schema a schema name; "" retrieves those without a schema
- * @param table a table name
- *
- * @return ResultSet each row is a column description
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public java.sql.ResultSet getVersionColumns(String catalog, String schema,
- String table) throws java.sql.SQLException {
- Field[] fields = new Field[8];
- fields[0] = new Field("", "SCOPE", Types.SMALLINT, 5);
- fields[1] = new Field("", "COLUMN_NAME", Types.CHAR, 32);
- fields[2] = new Field("", "DATA_TYPE", Types.SMALLINT, 5);
- fields[3] = new Field("", "TYPE_NAME", Types.CHAR, 16);
- fields[4] = new Field("", "COLUMN_SIZE", Types.CHAR, 16);
- fields[5] = new Field("", "BUFFER_LENGTH", Types.CHAR, 16);
- fields[6] = new Field("", "DECIMAL_DIGITS", Types.CHAR, 16);
- fields[7] = new Field("", "PSEUDO_COLUMN", Types.SMALLINT, 5);
- return buildResultSet(fields, new ArrayList());
- // do TIMESTAMP columns count?
- }
- /**
- * Can all the procedures returned by getProcedures be called by the
- * current user?
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean allProceduresAreCallable() throws java.sql.SQLException {
- return false;
- }
- /**
- * Can all the tables returned by getTable be SELECTed by the current user?
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean allTablesAreSelectable() throws java.sql.SQLException {
- return false;
- }
- /**
- * Does a data definition statement within a transaction force the
- * transaction to commit?
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean dataDefinitionCausesTransactionCommit()
- throws java.sql.SQLException {
- return true;
- }
- /**
- * Is a data definition statement within a transaction ignored?
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean dataDefinitionIgnoredInTransactions()
- throws java.sql.SQLException {
- return false;
- }
- /**
- * JDBC 2.0 Determine whether or not a visible row delete can be detected
- * by calling ResultSet.rowDeleted(). If deletesAreDetected() returns
- * false, then deleted rows are removed from the result set.
- *
- * @param type set type, i.e. ResultSet.TYPE_XXX
- *
- * @return true if changes are detected by the resultset type
- *
- * @exception SQLException if a database-access error occurs.
- */
- public boolean deletesAreDetected(int type) throws SQLException {
- return false;
- }
- /**
- * Did getMaxRowSize() include LONGVARCHAR and LONGVARBINARY blobs?
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean doesMaxRowSizeIncludeBlobs() throws java.sql.SQLException {
- return true;
- }
- /**
- * Extracts foreign key info for one table.
- *
- * @param rows the list of rows to add to
- * @param rs the result set from 'SHOW CREATE TABLE'
- * @param catalog the database name
- *
- * @return the list of rows with new rows added
- *
- * @throws SQLException if a database access error occurs
- */
- public List extractForeignKeyForTable(ArrayList rows,
- java.sql.ResultSet rs, String catalog) throws SQLException {
- byte[][] row = new byte[3][];
- row[0] = rs.getBytes(1);
- row[1] = s2b(SUPPORTS_FK);
- String createTableString = rs.getString(2);
- StringTokenizer lineTokenizer = new StringTokenizer(createTableString,
- "n");
- StringBuffer commentBuf = new StringBuffer("comment; ");
- boolean firstTime = true;
- while (lineTokenizer.hasMoreTokens()) {
- String line = lineTokenizer.nextToken().trim();
- String constraintName = null;
- if (StringUtils.startsWithIgnoreCase(line, "CONSTRAINT")) {
- boolean usingBackTicks = true;
- int beginPos = line.indexOf("`");
- if (beginPos == -1) {
- beginPos = line.indexOf(""");
- usingBackTicks = false;
- }
- if (beginPos != -1) {
- int endPos = -1;
- if (usingBackTicks) {
- endPos = line.indexOf("`", beginPos + 1);
- } else {
- endPos = line.indexOf(""", beginPos + 1);
- }
- if (endPos != -1) {
- constraintName = line.substring(beginPos + 1, endPos);
- line = line.substring(endPos + 1, line.length()).trim();
- }
- }
- }
- if (line.startsWith("FOREIGN KEY")) {
- if (line.endsWith(",")) {
- line = line.substring(0, line.length() - 1);
- }
- // Remove all back-ticks
- int lineLength = line.length();
- StringBuffer lineBuf = new StringBuffer(lineLength);
- for (int i = 0; i < lineLength; i++) {
- char c = line.charAt(i);
- if (c != '`') {
- lineBuf.append(c);
- }
- }
- line = lineBuf.toString();
- StringTokenizer keyTokens = new StringTokenizer(line, "()",
- false);
- keyTokens.nextToken(); // eat 'FOREIGN KEY'
- String localColumnNamesString = keyTokens.nextToken();
- String referCatalogTableString = keyTokens.nextToken();
- StringTokenizer referSchemaTable = new StringTokenizer(referCatalogTableString
- .trim(), " .");
- String referColumnNamesString = keyTokens.nextToken();
- referSchemaTable.nextToken(); //discard the REFERENCES token
- int numTokensLeft = referSchemaTable.countTokens();
- String referCatalog = null;
- String referTable = null;
- if (numTokensLeft == 2) {
- // some versions of MySQL don't report the database name
- referCatalog = referSchemaTable.nextToken();
- referTable = referSchemaTable.nextToken();
- } else {
- referTable = referSchemaTable.nextToken();
- referCatalog = catalog;
- }
- if (!firstTime) {
- commentBuf.append("; ");
- } else {
- firstTime = false;
- }
- if (constraintName != null) {
- commentBuf.append(constraintName);
- } else {
- commentBuf.append("not_available");
- }
- commentBuf.append("(");
- commentBuf.append(localColumnNamesString);
- commentBuf.append(") REFER ");
- commentBuf.append(referCatalog);
- commentBuf.append("/");
- commentBuf.append(referTable);
- commentBuf.append("(");
- commentBuf.append(referColumnNamesString);
- commentBuf.append(")");
- int lastParenIndex = line.lastIndexOf(")");
- if (lastParenIndex != (line.length() - 1)) {
- String cascadeOptions = cascadeOptions = line.substring(lastParenIndex
- + 1);
- commentBuf.append(" ");
- commentBuf.append(cascadeOptions);
- }
- }
- }
- row[2] = s2b(commentBuf.toString());
- rows.add(row);
- return rows;
- }
- /**
- * Creates a result set similar enough to 'SHOW TABLE STATUS' to allow the
- * same code to work on extracting the foreign key data
- *
- * @param conn the database connection to use
- * @param metadata the DatabaseMetaData instance calling this method
- * @param catalog the database name to extract foreign key info for
- * @param tableName the table to extract foreign key info for
- *
- * @return A result set that has the structure of 'show table status'
- *
- * @throws SQLException if a database access error occurs.
- */
- public ResultSet extractForeignKeyFromCreateTable(
- java.sql.Connection conn, java.sql.DatabaseMetaData metadata,
- String catalog, String tableName) throws SQLException {
- ArrayList tableList = new ArrayList();
- java.sql.ResultSet rs = null;
- java.sql.Statement stmt = null;
- if (tableName != null) {
- tableList.add(tableName);
- } else {
- try {
- rs = metadata.getTables(catalog, "", "%",
- new String[] { "TABLE" });
- while (rs.next()) {
- tableList.add(rs.getString("TABLE_NAME"));
- }
- } finally {
- if (rs != null) {
- rs.close();
- }
- rs = null;
- }
- }
- ArrayList rows = new ArrayList();
- Field[] fields = new Field[3];
- fields[0] = new Field("", "Name", Types.CHAR, Integer.MAX_VALUE);
- fields[1] = new Field("", "Type", Types.CHAR, 255);
- fields[2] = new Field("", "Comment", Types.CHAR, Integer.MAX_VALUE);
- int numTables = tableList.size();
- try {
- stmt = conn.createStatement();
- if (stmt.getMaxRows() != 0) {
- stmt.setMaxRows(0);
- }
- for (int i = 0; i < numTables; i++) {
- String tableToExtract = (String) tableList.get(i);
- String query = new StringBuffer("SHOW CREATE TABLE ").append(
- "`").append(catalog).append("`.`").append(tableToExtract)
- .append("`")
- .toString();
- rs = stmt.executeQuery(query);
- while (rs.next()) {
- extractForeignKeyForTable(rows, rs, catalog);
- }
- }
- } finally {
- if (rs != null) {
- rs.close();
- }
- rs = null;
- if (stmt != null) {
- stmt.close();
- }
- stmt = null;
- }
- return buildResultSet(fields, rows);
- }
- /**
- * JDBC 2.0 Determine whether or not a visible row insert can be detected
- * by calling ResultSet.rowInserted().
- *
- * @param type set type, i.e. ResultSet.TYPE_XXX
- *
- * @return true if changes are detected by the resultset type
- *
- * @exception SQLException if a database-access error occurs.
- */
- public boolean insertsAreDetected(int type) throws SQLException {
- return false;
- }
- /**
- * @see DatabaseMetaData#locatorsUpdateCopy()
- */
- public boolean locatorsUpdateCopy() throws SQLException {
- return true;
- }
- /**
- * Are concatenations between NULL and non-NULL values NULL? A JDBC
- * compliant driver always returns true.
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean nullPlusNonNullIsNull() throws java.sql.SQLException {
- return true;
- }
- /**
- * Are NULL values sorted at the end regardless of sort order?
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean nullsAreSortedAtEnd() throws java.sql.SQLException {
- return false;
- }
- /**
- * Are NULL values sorted at the start regardless of sort order?
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean nullsAreSortedAtStart() throws java.sql.SQLException {
- if (this.conn.getIO().versionMeetsMinimum(4, 0, 2)
- && !this.conn.getIO().versionMeetsMinimum(4, 0, 11)) {
- return true;
- } else {
- return false;
- }
- }
- /**
- * Are NULL values sorted high?
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean nullsAreSortedHigh() throws java.sql.SQLException {
- return false;
- }
- /**
- * Are NULL values sorted low?
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean nullsAreSortedLow() throws java.sql.SQLException {
- return !nullsAreSortedHigh();
- }
- /**
- * DOCUMENT ME!
- *
- * @param type DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- *
- * @throws SQLException DOCUMENT ME!
- */
- public boolean othersDeletesAreVisible(int type) throws SQLException {
- return false;
- }
- /**
- * DOCUMENT ME!
- *
- * @param type DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- *
- * @throws SQLException DOCUMENT ME!
- */
- public boolean othersInsertsAreVisible(int type) throws SQLException {
- return false;
- }
- /**
- * JDBC 2.0 Determine whether changes made by others are visible.
- *
- * @param type set type, i.e. ResultSet.TYPE_XXX
- *
- * @return true if changes are visible for the result set type
- *
- * @exception SQLException if a database-access error occurs.
- */
- public boolean othersUpdatesAreVisible(int type) throws SQLException {
- return false;
- }
- /**
- * DOCUMENT ME!
- *
- * @param type DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- *
- * @throws SQLException DOCUMENT ME!
- */
- public boolean ownDeletesAreVisible(int type) throws SQLException {
- return false;
- }
- /**
- * DOCUMENT ME!
- *
- * @param type DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- *
- * @throws SQLException DOCUMENT ME!
- */
- public boolean ownInsertsAreVisible(int type) throws SQLException {
- return false;
- }
- /**
- * JDBC 2.0 Determine whether a result set's own changes visible.
- *
- * @param type set type, i.e. ResultSet.TYPE_XXX
- *
- * @return true if changes are visible for the result set type
- *
- * @exception SQLException if a database-access error occurs.
- */
- public boolean ownUpdatesAreVisible(int type) throws SQLException {
- return false;
- }
- /**
- * Does the database store mixed case unquoted SQL identifiers in lower
- * case?
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean storesLowerCaseIdentifiers() throws java.sql.SQLException {
- return false;
- }
- /**
- * Does the database store mixed case quoted SQL identifiers in lower case?
- * A JDBC compliant driver will always return false.
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean storesLowerCaseQuotedIdentifiers()
- throws java.sql.SQLException {
- return false;
- }
- /**
- * Does the database store mixed case unquoted SQL identifiers in mixed
- * case?
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean storesMixedCaseIdentifiers() throws java.sql.SQLException {
- return true;
- }
- /**
- * Does the database store mixed case quoted SQL identifiers in mixed case?
- * A JDBC compliant driver will always return false.
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean storesMixedCaseQuotedIdentifiers()
- throws java.sql.SQLException {
- return false;
- }
- /**
- * Does the database store mixed case unquoted SQL identifiers in upper
- * case?
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean storesUpperCaseIdentifiers() throws java.sql.SQLException {
- return false;
- }
- /**
- * Does the database store mixed case quoted SQL identifiers in upper case?
- * A JDBC compliant driver will always return true.
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean storesUpperCaseQuotedIdentifiers()
- throws java.sql.SQLException {
- return false;
- }
- /**
- * Is the ANSI92 entry level SQL grammar supported? All JDBC compliant
- * drivers must return true.
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean supportsANSI92EntryLevelSQL() throws java.sql.SQLException {
- return true;
- }
- /**
- * Is the ANSI92 full SQL grammar supported?
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean supportsANSI92FullSQL() throws java.sql.SQLException {
- return false;
- }
- /**
- * Is the ANSI92 intermediate SQL grammar supported?
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean supportsANSI92IntermediateSQL() throws java.sql.SQLException {
- return false;
- }
- /**
- * Is "ALTER TABLE" with add column supported?
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean supportsAlterTableWithAddColumn()
- throws java.sql.SQLException {
- return true;
- }
- /**
- * Is "ALTER TABLE" with drop column supported?
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean supportsAlterTableWithDropColumn()
- throws java.sql.SQLException {
- return true;
- }
- /**
- * JDBC 2.0 Return true if the driver supports batch updates, else return
- * false.
- *
- * @return DOCUMENT ME!
- *
- * @throws SQLException DOCUMENT ME!
- */
- public boolean supportsBatchUpdates() throws SQLException {
- return true;
- }
- /**
- * Can a catalog name be used in a data manipulation statement?
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean supportsCatalogsInDataManipulation()
- throws java.sql.SQLException {
- // Servers before 3.22 could not do this
- return this.conn.getIO().versionMeetsMinimum(3, 3, 22);
- }
- /**
- * Can a catalog name be used in a index definition statement?
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean supportsCatalogsInIndexDefinitions()
- throws java.sql.SQLException {
- return false;
- }
- /**
- * Can a catalog name be used in a privilege definition statement?
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean supportsCatalogsInPrivilegeDefinitions()
- throws java.sql.SQLException {
- return false;
- }
- /**
- * Can a catalog name be used in a procedure call statement?
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean supportsCatalogsInProcedureCalls()
- throws java.sql.SQLException {
- return false;
- }
- /**
- * Can a catalog name be used in a table definition statement?
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean supportsCatalogsInTableDefinitions()
- throws java.sql.SQLException {
- return false;
- }
- /**
- * Is column aliasing supported?
- *
- * <P>
- * If so, the SQL AS clause can be used to provide names for computed
- * columns or to provide alias names for columns as required. A JDBC
- * compliant driver always returns true.
- * </p>
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean supportsColumnAliasing() throws java.sql.SQLException {
- return true;
- }
- /**
- * Is the CONVERT function between SQL types supported?
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean supportsConvert() throws java.sql.SQLException {
- return true;
- }
- /**
- * Is CONVERT between the given SQL types supported?
- *
- * @param fromType the type to convert from
- * @param toType the type to convert to
- *
- * @return true if so
- *
- * @throws java.sql.SQLException if an error occurs
- *
- * @see Types
- */
- public boolean supportsConvert(int fromType, int toType)
- throws java.sql.SQLException {
- switch (fromType) {
- /* The char/binary types can be converted
- * to pretty much anything.
- */
- case java.sql.Types.CHAR:
- case java.sql.Types.VARCHAR:
- case java.sql.Types.LONGVARCHAR:
- case java.sql.Types.BINARY:
- case java.sql.Types.VARBINARY:
- case java.sql.Types.LONGVARBINARY:
- switch (toType) {
- case java.sql.Types.DECIMAL:
- case java.sql.Types.NUMERIC:
- case java.sql.Types.REAL:
- case java.sql.Types.TINYINT:
- case java.sql.Types.SMALLINT:
- case java.sql.Types.INTEGER:
- case java.sql.Types.BIGINT:
- case java.sql.Types.FLOAT:
- case java.sql.Types.DOUBLE:
- case java.sql.Types.CHAR:
- case java.sql.Types.VARCHAR:
- case java.sql.Types.LONGVARCHAR:
- case java.sql.Types.BINARY:
- case java.sql.Types.VARBINARY:
- case java.sql.Types.LONGVARBINARY:
- case java.sql.Types.OTHER:
- case java.sql.Types.DATE:
- case java.sql.Types.TIME:
- case java.sql.Types.TIMESTAMP:
- return true;
- default:
- return false;
- }
- /* We don't handle the BIT type
- * yet.
- */
- case java.sql.Types.BIT:
- return false;
- /* The numeric types. Basically they can convert
- * among themselves, and with char/binary types.
- */
- case java.sql.Types.DECIMAL:
- case java.sql.Types.NUMERIC:
- case java.sql.Types.REAL:
- case java.sql.Types.TINYINT:
- case java.sql.Types.SMALLINT:
- case java.sql.Types.INTEGER:
- case java.sql.Types.BIGINT:
- case java.sql.Types.FLOAT:
- case java.sql.Types.DOUBLE:
- switch (toType) {
- case java.sql.Types.DECIMAL:
- case java.sql.Types.NUMERIC:
- case java.sql.Types.REAL:
- case java.sql.Types.TINYINT:
- case java.sql.Types.SMALLINT:
- case java.sql.Types.INTEGER:
- case java.sql.Types.BIGINT:
- case java.sql.Types.FLOAT:
- case java.sql.Types.DOUBLE:
- case java.sql.Types.CHAR:
- case java.sql.Types.VARCHAR:
- case java.sql.Types.LONGVARCHAR:
- case java.sql.Types.BINARY:
- case java.sql.Types.VARBINARY:
- case java.sql.Types.LONGVARBINARY:
- return true;
- default:
- return false;
- }
- /* MySQL doesn't support a NULL type. */
- case java.sql.Types.NULL:
- return false;
- /* With this driver, this will always be a serialized
- * object, so the char/binary types will work.
- */
- case java.sql.Types.OTHER:
- switch (toType) {
- case java.sql.Types.CHAR:
- case java.sql.Types.VARCHAR:
- case java.sql.Types.LONGVARCHAR:
- case java.sql.Types.BINARY:
- case java.sql.Types.VARBINARY:
- case java.sql.Types.LONGVARBINARY:
- return true;
- default:
- return false;
- }
- /* Dates can be converted to char/binary types. */
- case java.sql.Types.DATE:
- switch (toType) {
- case java.sql.Types.CHAR:
- case java.sql.Types.VARCHAR:
- case java.sql.Types.LONGVARCHAR:
- case java.sql.Types.BINARY:
- case java.sql.Types.VARBINARY:
- case java.sql.Types.LONGVARBINARY:
- return true;
- default:
- return false;
- }
- /* Time can be converted to char/binary types */
- case java.sql.Types.TIME:
- switch (toType) {
- case java.sql.Types.CHAR:
- case java.sql.Types.VARCHAR:
- case java.sql.Types.LONGVARCHAR:
- case java.sql.Types.BINARY:
- case java.sql.Types.VARBINARY:
- case java.sql.Types.LONGVARBINARY:
- return true;
- default:
- return false;
- }
- /* Timestamp can be converted to char/binary types
- * and date/time types (with loss of precision).
- */
- case java.sql.Types.TIMESTAMP:
- switch (toType) {
- case java.sql.Types.CHAR:
- case java.sql.Types.VARCHAR:
- case java.sql.Types.LONGVARCHAR:
- case java.sql.Types.BINARY:
- case java.sql.Types.VARBINARY:
- case java.sql.Types.LONGVARBINARY:
- case java.sql.Types.TIME:
- case java.sql.Types.DATE:
- return true;
- default:
- return false;
- }
- /* We shouldn't get here! */
- default:
- return false; // not sure
- }
- }
- /**
- * Is the ODBC Core SQL grammar supported?
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean supportsCoreSQLGrammar() throws java.sql.SQLException {
- return true;
- }
- /**
- * Are correlated subqueries supported? A JDBC compliant driver always
- * returns true.
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean supportsCorrelatedSubqueries() throws java.sql.SQLException {
- return false;
- }
- /**
- * Are both data definition and data manipulation statements within a
- * transaction supported?
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean supportsDataDefinitionAndDataManipulationTransactions()
- throws java.sql.SQLException {
- return false;
- }
- /**
- * Are only data manipulation statements within a transaction supported?
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean supportsDataManipulationTransactionsOnly()
- throws java.sql.SQLException {
- return false;
- }
- /**
- * If table correlation names are supported, are they restricted to be
- * different from the names of the tables? A JDBC compliant driver always
- * returns true.
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean supportsDifferentTableCorrelationNames()
- throws java.sql.SQLException {
- return true;
- }
- /**
- * Are expressions in "ORDER BY" lists supported?
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean supportsExpressionsInOrderBy() throws java.sql.SQLException {
- return true;
- }
- /**
- * Is the ODBC Extended SQL grammar supported?
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean supportsExtendedSQLGrammar() throws java.sql.SQLException {
- return false;
- }
- /**
- * Are full nested outer joins supported?
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean supportsFullOuterJoins() throws java.sql.SQLException {
- return false;
- }
- /**
- * JDBC 3.0
- *
- * @return DOCUMENT ME!
- */
- public boolean supportsGetGeneratedKeys() {
- return true;
- }
- /**
- * Is some form of "GROUP BY" clause supported?
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean supportsGroupBy() throws java.sql.SQLException {
- return true;
- }
- /**
- * Can a "GROUP BY" clause add columns not in the SELECT provided it
- * specifies all the columns in the SELECT?
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean supportsGroupByBeyondSelect() throws java.sql.SQLException {
- return true;
- }
- /**
- * Can a "GROUP BY" clause use columns not in the SELECT?
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean supportsGroupByUnrelated() throws java.sql.SQLException {
- return false;
- }
- /**
- * Is the SQL Integrity Enhancement Facility supported?
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean supportsIntegrityEnhancementFacility()
- throws java.sql.SQLException {
- return false;
- }
- /**
- * Is the escape character in "LIKE" clauses supported? A JDBC compliant
- * driver always returns true.
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean supportsLikeEscapeClause() throws java.sql.SQLException {
- return true;
- }
- /**
- * Is there limited support for outer joins? (This will be true if
- * supportFullOuterJoins is true.)
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean supportsLimitedOuterJoins() throws java.sql.SQLException {
- return true;
- }
- /**
- * Is the ODBC Minimum SQL grammar supported? All JDBC compliant drivers
- * must return true.
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean supportsMinimumSQLGrammar() throws java.sql.SQLException {
- return true;
- }
- /**
- * Does the database support mixed case unquoted SQL identifiers?
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean supportsMixedCaseIdentifiers() throws java.sql.SQLException {
- return false;
- }
- /**
- * Does the database support mixed case quoted SQL identifiers? A JDBC
- * compliant driver will always return true.
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean supportsMixedCaseQuotedIdentifiers()
- throws java.sql.SQLException {
- return false;
- }
- /**
- * @see DatabaseMetaData#supportsMultipleOpenResults()
- */
- public boolean supportsMultipleOpenResults() throws SQLException {
- return false;
- }
- /**
- * Are multiple ResultSets from a single execute supported?
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean supportsMultipleResultSets() throws java.sql.SQLException {
- return false;
- }
- /**
- * Can we have multiple transactions open at once (on different
- * connections)?
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean supportsMultipleTransactions() throws java.sql.SQLException {
- return true;
- }
- /**
- * @see DatabaseMetaData#supportsNamedParameters()
- */
- public boolean supportsNamedParameters() throws SQLException {
- return false;
- }
- /**
- * Can columns be defined as non-nullable? A JDBC compliant driver always
- * returns true.
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean supportsNonNullableColumns() throws java.sql.SQLException {
- return true;
- }
- /**
- * Can cursors remain open across commits?
- *
- * @return true if so
- *
- * @throws java.sql.SQLException if a database access error occurs
- *
- * @see Connection#disableAutoClose
- */
- public boolean supportsOpenCursorsAcrossCommit()
- throws java.sql.SQLException {
- return false;
- }
- /**
- * Can cursors remain open across rollbacks?
- *
- * @return true if so
- *
- * @throws java.sql.SQLException if an error occurs
- *
- * @see Connection#disableAutoClose
- */
- public boolean supportsOpenCursorsAcrossRollback()
- throws java.sql.SQLException {
- return false;
- }
- /**
- * Can statements remain open across commits?
- *
- * @return true if so
- *
- * @throws java.sql.SQLException if an error occurs
- *
- * @see Connection#disableAutoClose
- */
- public boolean supportsOpenStatementsAcrossCommit()
- throws java.sql.SQLException {
- return false;
- }
- /**
- * Can statements remain open across rollbacks?
- *
- * @return true if so
- *
- * @throws java.sql.SQLException if an error occurs
- *
- * @see Connection#disableAutoClose
- */
- public boolean supportsOpenStatementsAcrossRollback()
- throws java.sql.SQLException {
- return false;
- }
- /**
- * Can an "ORDER BY" clause use columns not in the SELECT?
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean supportsOrderByUnrelated() throws java.sql.SQLException {
- return false;
- }
- /**
- * Is some form of outer join supported?
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean supportsOuterJoins() throws java.sql.SQLException {
- return true;
- }
- /**
- * Is positioned DELETE supported?
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean supportsPositionedDelete() throws java.sql.SQLException {
- return false;
- }
- /**
- * Is positioned UPDATE supported?
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean supportsPositionedUpdate() throws java.sql.SQLException {
- return false;
- }
- /**
- * JDBC 2.0 Does the database support the concurrency type in combination
- * with the given result set type?
- *
- * @param type defined in java.sql.ResultSet
- * @param concurrency type defined in java.sql.ResultSet
- *
- * @return true if so
- *
- * @exception SQLException if a database-access error occurs.
- *
- * @see Connection
- */
- public boolean supportsResultSetConcurrency(int type, int concurrency)
- throws SQLException {
- return ((type == ResultSet.TYPE_SCROLL_INSENSITIVE)
- && ((concurrency == ResultSet.CONCUR_READ_ONLY)
- || (concurrency == ResultSet.CONCUR_UPDATABLE)));
- }
- /**
- * @see DatabaseMetaData#supportsResultSetHoldability(int)
- */
- public boolean supportsResultSetHoldability(int holdability)
- throws SQLException {
- return (holdability == ResultSet.HOLD_CURSORS_OVER_COMMIT);
- }
- /**
- * JDBC 2.0 Does the database support the given result set type?
- *
- * @param type defined in java.sql.ResultSet
- *
- * @return true if so
- *
- * @exception SQLException if a database-access error occurs.
- *
- * @see Connection
- */
- public boolean supportsResultSetType(int type) throws SQLException {
- return (type == ResultSet.TYPE_SCROLL_INSENSITIVE);
- }
- /**
- * @see DatabaseMetaData#supportsSavepoints()
- */
- public boolean supportsSavepoints() throws SQLException {
- return false;
- }
- /**
- * Can a schema name be used in a data manipulation statement?
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean supportsSchemasInDataManipulation()
- throws java.sql.SQLException {
- return false;
- }
- /**
- * Can a schema name be used in an index definition statement?
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean supportsSchemasInIndexDefinitions()
- throws java.sql.SQLException {
- return false;
- }
- /**
- * Can a schema name be used in a privilege definition statement?
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean supportsSchemasInPrivilegeDefinitions()
- throws java.sql.SQLException {
- return false;
- }
- /**
- * Can a schema name be used in a procedure call statement?
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean supportsSchemasInProcedureCalls()
- throws java.sql.SQLException {
- return false;
- }
- /**
- * Can a schema name be used in a table definition statement?
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean supportsSchemasInTableDefinitions()
- throws java.sql.SQLException {
- return false;
- }
- /**
- * Is SELECT for UPDATE supported?
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean supportsSelectForUpdate() throws java.sql.SQLException {
- return false;
- }
- /**
- * @see DatabaseMetaData#supportsStatementPooling()
- */
- public boolean supportsStatementPooling() throws SQLException {
- return false;
- }
- /**
- * Are stored procedure calls using the stored procedure escape syntax
- * supported?
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean supportsStoredProcedures() throws java.sql.SQLException {
- return false;
- }
- /**
- * Are subqueries in comparison expressions supported? A JDBC compliant
- * driver always returns true.
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean supportsSubqueriesInComparisons()
- throws java.sql.SQLException {
- return this.conn.getIO().versionMeetsMinimum(4, 1, 0);
- }
- /**
- * Are subqueries in exists expressions supported? A JDBC compliant driver
- * always returns true.
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean supportsSubqueriesInExists() throws java.sql.SQLException {
- return this.conn.getIO().versionMeetsMinimum(4, 1, 0);
- }
- /**
- * Are subqueries in "in" statements supported? A JDBC compliant driver
- * always returns true.
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean supportsSubqueriesInIns() throws java.sql.SQLException {
- return this.conn.getIO().versionMeetsMinimum(4, 1, 0);
- }
- /**
- * Are subqueries in quantified expressions supported? A JDBC compliant
- * driver always returns true.
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean supportsSubqueriesInQuantifieds()
- throws java.sql.SQLException {
- return this.conn.getIO().versionMeetsMinimum(4, 1, 0);
- }
- /**
- * Are table correlation names supported? A JDBC compliant driver always
- * returns true.
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean supportsTableCorrelationNames() throws java.sql.SQLException {
- return true;
- }
- /**
- * Does the database support the given transaction isolation level?
- *
- * @param level the values are defined in java.sql.Connection
- *
- * @return true if so
- *
- * @throws java.sql.SQLException if a database access error occurs
- *
- * @see Connection
- */
- public boolean supportsTransactionIsolationLevel(int level)
- throws java.sql.SQLException {
- if (this.conn.supportsIsolationLevel()) {
- switch (level) {
- case java.sql.Connection.TRANSACTION_READ_COMMITTED:
- case java.sql.Connection.TRANSACTION_READ_UNCOMMITTED:
- case java.sql.Connection.TRANSACTION_REPEATABLE_READ:
- case java.sql.Connection.TRANSACTION_SERIALIZABLE:
- return true;
- default:
- return false;
- }
- } else {
- return false;
- }
- }
- /**
- * Are transactions supported? If not, commit is a noop and the isolation
- * level is TRANSACTION_NONE.
- *
- * @return true if transactions are supported
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean supportsTransactions() throws java.sql.SQLException {
- return this.conn.supportsTransactions();
- }
- /**
- * Is SQL UNION supported? A JDBC compliant driver always returns true.
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean supportsUnion() throws java.sql.SQLException {
- return this.conn.getIO().versionMeetsMinimum(4, 0, 0);
- }
- /**
- * Is SQL UNION ALL supported? A JDBC compliant driver always returns true.
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean supportsUnionAll() throws java.sql.SQLException {
- return this.conn.getIO().versionMeetsMinimum(4, 0, 0);
- }
- /**
- * JDBC 2.0 Determine whether or not a visible row update can be detected
- * by calling ResultSet.rowUpdated().
- *
- * @param type set type, i.e. ResultSet.TYPE_XXX
- *
- * @return true if changes are detected by the resultset type
- *
- * @exception SQLException if a database-access error occurs.
- */
- public boolean updatesAreDetected(int type) throws SQLException {
- return false;
- }
- /**
- * Does the database use a file for each table?
- *
- * @return true if the database uses a local file for each table
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean usesLocalFilePerTable() throws java.sql.SQLException {
- return false;
- }
- /**
- * Does the database store tables in a local file?
- *
- * @return true if so
- *
- * @throws java.sql.SQLException DOCUMENT ME!
- */
- public boolean usesLocalFiles() throws java.sql.SQLException {
- return false;
- }
- /**
- * Parses the cascade option string and returns the DBMD constant that
- * represents it (for deletes)
- *
- * @param cascadeOptions the comment from 'SHOW TABLE STATUS'
- *
- * @return the DBMD constant that represents the cascade option
- */
- private int getCascadeDeleteOption(String cascadeOptions) {
- int onDeletePos = cascadeOptions.indexOf("ON DELETE");
- if (onDeletePos != -1) {
- String deleteOptions = cascadeOptions.substring(onDeletePos,
- cascadeOptions.length());
- if (deleteOptions.startsWith("ON DELETE CASCADE")) {
- return DatabaseMetaData.importedKeyCascade;
- } else if (deleteOptions.startsWith("ON DELETE SET NULL")) {
- return DatabaseMetaData.importedKeySetNull;
- } else if (deleteOptions.startsWith("ON DELETE RESTRICT")) {
- return DatabaseMetaData.importedKeyRestrict;
- } else if (deleteOptions.startsWith("ON DELETE NO ACTION")) {
- return DatabaseMetaData.importedKeyNoAction;
- }
- }
- return DatabaseMetaData.importedKeyNoAction;
- }
- /**
- * Parses the cascade option string and returns the DBMD constant that
- * represents it (for Updates)
- *
- * @param cascadeOptions the comment from 'SHOW TABLE STATUS'
- *
- * @return the DBMD constant that represents the cascade option
- */
- private int getCascadeUpdateOption(String cascadeOptions) {
- int onUpdatePos = cascadeOptions.indexOf("ON UPDATE");
- if (onUpdatePos != -1) {
- String updateOptions = cascadeOptions.substring(onUpdatePos,
- cascadeOptions.length());
- if (updateOptions.startsWith("ON UPDATE CASCADE")) {
- return DatabaseMetaData.importedKeyCascade;
- } else if (updateOptions.startsWith("ON UPDATE SET NULL")) {
- return DatabaseMetaData.importedKeySetNull;
- } else if (updateOptions.startsWith("ON UPDATE RESTRICT")) {
- return DatabaseMetaData.importedKeyRestrict;
- } else if (updateOptions.startsWith("ON UPDATE NO ACTION")) {
- return DatabaseMetaData.importedKeyNoAction;
- }
- }
- return DatabaseMetaData.importedKeyNoAction;
- }
- /**
- * Adds to the tuples list the exported keys of exportingTable based on the
- * keysComment from the 'show table status' sql command. KeysComment is
- * that part of the comment field that follows the "InnoDB free ...;"
- * prefix.
- *
- * @param catalog the database to use
- * @param exportingTable the table keys are being exported from
- * @param keysComment the comment from 'show table status'
- * @param tuples the rows to add results to
- * @param fkTableName the foreign key table name
- *
- * @throws SQLException if a database access error occurs
- */
- private void getExportKeyResults(String catalog, String exportingTable,
- String keysComment, List tuples, String fkTableName)
- throws SQLException {
- getResultsImpl(catalog, exportingTable, keysComment, tuples,
- fkTableName, true);
- }
- /**
- * Returns the DELETE and UPDATE foreign key actions from the given 'SHOW
- * TABLE STATUS' string, with the DELETE action being the first item in
- * the array, and the UPDATE action being the second.
- *
- * @param commentString the comment from 'SHOW TABLE STATUS'
- *
- * @return int[] [0] = delete action, [1] = update action
- */
- private int[] getForeignKeyActions(String commentString) {
- int[] actions = new int[] {
- DatabaseMetaData.importedKeyNoAction,
- DatabaseMetaData.importedKeyNoAction
- };
- int lastParenIndex = commentString.lastIndexOf(")");
- if (lastParenIndex != (commentString.length() - 1)) {
- String cascadeOptions = commentString.substring(lastParenIndex + 1)
- .trim().toUpperCase();
- actions[0] = getCascadeDeleteOption(cascadeOptions);
- actions[1] = getCascadeUpdateOption(cascadeOptions);
- }
- return actions;
- }
- /**
- * Populates the tuples list with the imported keys of importingTable based
- * on the keysComment from the 'show table status' sql command.
- * KeysComment is that part of the comment field that follows the "InnoDB
- * free ...;" prefix.
- *
- * @param catalog the database to use
- * @param importingTable the table keys are being imported to
- * @param keysComment the comment from 'show table status'
- * @param tuples the rows to add results to
- *
- * @throws SQLException if a database access error occurs
- */
- private void getImportKeyResults(String catalog, String importingTable,
- String keysComment, List tuples) throws SQLException {
- getResultsImpl(catalog, importingTable, keysComment, tuples, null, false);
- }
- private void getResultsImpl(String catalog, String table,
- String keysComment, List tuples, String fkTableName, boolean isExport)
- throws SQLException {
- // keys will equal something like this:
- // (parent_service_id child_service_id) REFER ds/subservices(parent_service_id child_service_id)
- // parse of the string into three phases:
- // 1: parse the opening parentheses to determine how many results there will be
- // 2: read in the schema name/table name
- // 3: parse the closing parentheses
- int firstLeftParenIndex = keysComment.indexOf('(');
- String constraintName = keysComment.substring(0, firstLeftParenIndex)
- .trim();
- keysComment = keysComment.substring(firstLeftParenIndex,
- keysComment.length());
- StringTokenizer keyTokens = new StringTokenizer(keysComment.trim(),
- "()", false);
- String localColumnNamesString = keyTokens.nextToken();
- StringTokenizer localColumnNames = new StringTokenizer(localColumnNamesString,
- " ,");
- String referCatalogTableString = keyTokens.nextToken();
- StringTokenizer referSchemaTable = new StringTokenizer(referCatalogTableString,
- " /");
- String referColumnNamesString = keyTokens.nextToken();
- StringTokenizer referColumnNames = new StringTokenizer(referColumnNamesString,
- " ,");
- referSchemaTable.nextToken(); //discard the REFER token
- String referCatalog = referSchemaTable.nextToken();
- String referTable = referSchemaTable.nextToken();
- if (isExport && !referTable.equals(table)) {
- return;
- }
- if (localColumnNames.countTokens() != referColumnNames.countTokens()) {
- throw new SQLException("Error parsing foriegn keys definition",
- SQLError.SQL_STATE_GENERAL_ERROR);
- }
- int keySeqIndex = 1;
- byte[] connectionCatalogAsBytes = null;
- if (catalog == null) {
- connectionCatalogAsBytes = s2b(this.conn.getCatalog());
- } else {
- connectionCatalogAsBytes = s2b(catalog);
- }
- while (localColumnNames.hasMoreTokens()) {
- byte[][] tuple = new byte[14][];
- String localColumnName = localColumnNames.nextToken();
- String referColumnName = referColumnNames.nextToken();
- tuple[FKTABLE_CAT] = connectionCatalogAsBytes;
- tuple[FKTABLE_SCHEM] = null;
- tuple[FKTABLE_NAME] = s2b((isExport) ? fkTableName : table);
- tuple[FKCOLUMN_NAME] = s2b(localColumnName);
- tuple[PKTABLE_CAT] = s2b(referCatalog);
- tuple[PKTABLE_SCHEM] = null;
- tuple[PKTABLE_NAME] = s2b((isExport) ? table : referTable);
- tuple[PKCOLUMN_NAME] = s2b(referColumnName);
- tuple[KEY_SEQ] = s2b(Integer.toString(keySeqIndex++));
- int[] actions = getForeignKeyActions(keysComment);
- tuple[UPDATE_RULE] = s2b(Integer.toString(actions[1]));
- tuple[DELETE_RULE] = s2b(Integer.toString(actions[0]));
- tuple[FK_NAME] = s2b(constraintName);
- tuple[PK_NAME] = null; //not available from show table status
- tuple[DEFERRABILITY] = s2b(Integer.toString(
- java.sql.DatabaseMetaData.importedKeyNotDeferrable));
- tuples.add(tuple);
- }
- }
- private String getTableNameWithCase(String table) {
- String tableNameWithCase = (this.conn.lowerCaseTableNames()
- ? table.toLowerCase() : table);
- return tableNameWithCase;
- }
- private java.sql.ResultSet buildResultSet(com.mysql.jdbc.Field[] fields,
- java.util.ArrayList rows) throws SQLException {
- int fieldsLength = fields.length;
- for (int i = 0; i < fieldsLength; i++) {
- fields[i].setConnection(this.conn);
- }
- return new com.mysql.jdbc.ResultSet(this.conn.getCatalog(), fields,
- new RowDataStatic(rows), this.conn);
- }
- /**
- * Converts the given string to bytes, using the connection's character
- * encoding, or if not available, the JVM default encoding.
- *
- * @param s DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
- private byte[] s2b(String s) {
- if ((this.conn != null) && this.conn.useUnicode()) {
- try {
- String encoding = this.conn.getEncoding();
- if (encoding == null) {
- return s.getBytes();
- } else {
- SingleByteCharsetConverter converter = this.conn.getCharsetConverter(encoding);
- if (converter != null) {
- return converter.toBytes(s);
- } else {
- return s.getBytes(encoding);
- }
- }
- } catch (java.io.UnsupportedEncodingException E) {
- return s.getBytes();
- }
- } else {
- return s.getBytes();
- }
- }
- }