Source Code Cross Referenced for DatabaseMetaData.java in  » Database-JDBC-Connection-Pool » octopus » com » internetcds » jdbc » tds » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database JDBC Connection Pool » octopus » com.internetcds.jdbc.tds 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        //
0002:        // Copyright 1998 CDS Networks, Inc., Medford Oregon
0003:        //
0004:        // All rights reserved.
0005:        //
0006:        // Redistribution and use in source and binary forms, with or without
0007:        // modification, are permitted provided that the following conditions are met:
0008:        // 1. Redistributions of source code must retain the above copyright
0009:        //    notice, this list of conditions and the following disclaimer.
0010:        // 2. Redistributions in binary form must reproduce the above copyright
0011:        //    notice, this list of conditions and the following disclaimer in the
0012:        //    documentation and/or other materials provided with the distribution.
0013:        // 3. All advertising materials mentioning features or use of this software
0014:        //    must display the following acknowledgement:
0015:        //      This product includes software developed by CDS Networks, Inc.
0016:        // 4. The name of CDS Networks, Inc.  may not be used to endorse or promote
0017:        //    products derived from this software without specific prior
0018:        //    written permission.
0019:        //
0020:        // THIS SOFTWARE IS PROVIDED BY CDS NETWORKS, INC. ``AS IS'' AND
0021:        // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0022:        // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0023:        // ARE DISCLAIMED.  IN NO EVENT SHALL CDS NETWORKS, INC. BE LIABLE
0024:        // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
0025:        // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
0026:        // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
0027:        // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
0028:        // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
0029:        // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
0030:        // SUCH DAMAGE.
0031:        //
0032:
0033:        package com.internetcds.jdbc.tds;
0034:
0035:        import java.sql.*;
0036:
0037:        /**
0038:         * This class provides information about the database as a whole.
0039:         *
0040:         * <P>Many of the methods here return lists of information in ResultSets.
0041:         * You can use the normal ResultSet methods such as getString and getInt
0042:         * to retrieve the data from these ResultSets.  If a given form of
0043:         * metadata is not available, these methods should throw a SQLException.
0044:         *
0045:         * <P>Some of these methods take arguments that are String patterns.  These
0046:         * arguments all have names such as fooPattern.  Within a pattern String, "%"
0047:         * means match any substring of 0 or more characters, and "_" means match
0048:         * any one character. Only metadata entries matching the search pattern
0049:         * are returned. If a search pattern argument is set to a null ref, it means
0050:         * that argument's criteria should be dropped from the search.
0051:         *
0052:         * <P>A SQLException will be thrown if a driver does not support a meta
0053:         * data method.  In the case of methods that return a ResultSet,
0054:         * either a ResultSet (which may be empty) is returned or a
0055:         * SQLException is thrown.
0056:         *
0057:         * @author Craig Spannring
0058:         * @author The FreeTDS project
0059:         * @version  $Id: DatabaseMetaData.java,v 1.1 2007-10-19 13:23:55 sinisa Exp $
0060:         *
0061:         */
0062:        public class DatabaseMetaData implements  java.sql.DatabaseMetaData {
0063:            public static final String cvsVersion = "$Id: DatabaseMetaData.java,v 1.1 2007-10-19 13:23:55 sinisa Exp $";
0064:
0065:            final boolean verbose = true;
0066:
0067:            /**
0068:             * PROCEDURE_TYPE - May return a result.
0069:             */
0070:            final int procedureResultUnknown = 0;
0071:            /**
0072:             * PROCEDURE_TYPE - Does not return a result.
0073:             */
0074:            final int procedureNoResult = 1;
0075:            /**
0076:             * PROCEDURE_TYPE - Returns a result.
0077:             */
0078:            final int procedureReturnsResult = 2;
0079:
0080:            /**
0081:             * COLUMN_TYPE - nobody knows.
0082:             */
0083:            final int procedureColumnUnknown = 0;
0084:
0085:            /**
0086:             * COLUMN_TYPE - IN parameter.
0087:             */
0088:            final int procedureColumnIn = 1;
0089:
0090:            /**
0091:             * COLUMN_TYPE - INOUT parameter.
0092:             */
0093:            final int procedureColumnInOut = 2;
0094:
0095:            /**
0096:             * COLUMN_TYPE - OUT parameter.
0097:             */
0098:            final int procedureColumnOut = 4;
0099:            /**
0100:             * COLUMN_TYPE - procedure return value.
0101:             */
0102:            final int procedureColumnReturn = 5;
0103:
0104:            /**
0105:             * COLUMN_TYPE - result column in ResultSet.
0106:             */
0107:            final int procedureColumnResult = 3;
0108:
0109:            /**
0110:             * TYPE NULLABLE - does not allow NULL values.
0111:             */
0112:            final int procedureNoNulls = 0;
0113:
0114:            /**
0115:             * TYPE NULLABLE - allows NULL values.
0116:             */
0117:            final int procedureNullable = 1;
0118:
0119:            /**
0120:             * TYPE NULLABLE - nullability unknown.
0121:             */
0122:            final int procedureNullableUnknown = 2;
0123:
0124:            /**
0125:             * COLUMN NULLABLE - might not allow NULL values.
0126:             */
0127:            final int columnNoNulls = 0;
0128:
0129:            /**
0130:             * COLUMN NULLABLE - definitely allows NULL values.
0131:             */
0132:            final int columnNullable = 1;
0133:
0134:            /**
0135:             * COLUMN NULLABLE - nullability unknown.
0136:             */
0137:            final int columnNullableUnknown = 2;
0138:
0139:            /**
0140:             * BEST ROW SCOPE - very temporary, while using row.
0141:             */
0142:            final int bestRowTemporary = 0;
0143:
0144:            /**
0145:             * BEST ROW SCOPE - valid for remainder of current transaction.
0146:             */
0147:            final int bestRowTransaction = 1;
0148:
0149:            /**
0150:             * BEST ROW SCOPE - valid for remainder of current session.
0151:             */
0152:            final int bestRowSession = 2;
0153:
0154:            /**
0155:             * BEST ROW PSEUDO_COLUMN - may or may not be pseudo column.
0156:             */
0157:            final int bestRowUnknown = 0;
0158:
0159:            /**
0160:             * BEST ROW PSEUDO_COLUMN - is NOT a pseudo column.
0161:             */
0162:            final int bestRowNotPseudo = 1;
0163:
0164:            /**
0165:             * BEST ROW PSEUDO_COLUMN - is a pseudo column.
0166:             */
0167:            final int bestRowPseudo = 2;
0168:
0169:            /**
0170:             * VERSION COLUMNS PSEUDO_COLUMN - may or may not be pseudo column.
0171:             */
0172:            final int versionColumnUnknown = 0;
0173:
0174:            /**
0175:             *  VERSION COLUMNS PSEUDO_COLUMN - is NOT a pseudo column.
0176:             */
0177:            final int versionColumnNotPseudo = 1;
0178:
0179:            /**
0180:             *  VERSION COLUMNS PSEUDO_COLUMN - is a pseudo column.
0181:             */
0182:            final int versionColumnPseudo = 2;
0183:
0184:            /**
0185:             * IMPORT KEY UPDATE_RULE and DELETE_RULE - for update, change
0186:             * imported key to agree with primary key update; for delete,
0187:             * delete rows that import a deleted key.
0188:             */
0189:            final int importedKeyCascade = 0;
0190:
0191:            /**
0192:             * IMPORT KEY UPDATE_RULE and DELETE_RULE - do not allow update or
0193:             * delete of primary key if it has been imported.
0194:             */
0195:            final int importedKeyRestrict = 1;
0196:
0197:            /**
0198:             * IMPORT KEY UPDATE_RULE and DELETE_RULE - change imported key to
0199:             * NULL if its primary key has been updated or deleted.
0200:             */
0201:            final int importedKeySetNull = 2;
0202:
0203:            /**
0204:             * IMPORT KEY UPDATE_RULE and DELETE_RULE - do not allow update or
0205:             * delete of primary key if it has been imported.
0206:             */
0207:            final int importedKeyNoAction = 3;
0208:
0209:            /**
0210:             * IMPORT KEY UPDATE_RULE and DELETE_RULE - change imported key to
0211:             * default values if its primary key has been updated or deleted.
0212:             */
0213:            final int importedKeySetDefault = 4;
0214:
0215:            /**
0216:             * IMPORT KEY DEFERRABILITY - see SQL92 for definition
0217:             */
0218:            final int importedKeyInitiallyDeferred = 5;
0219:
0220:            /**
0221:             * IMPORT KEY DEFERRABILITY - see SQL92 for definition
0222:             */
0223:            final int importedKeyInitiallyImmediate = 6;
0224:
0225:            /**
0226:             * IMPORT KEY DEFERRABILITY - see SQL92 for definition
0227:             */
0228:            final int importedKeyNotDeferrable = 7;
0229:
0230:            /**
0231:             * TYPE NULLABLE - does not allow NULL values.
0232:             */
0233:            final int typeNoNulls = 0;
0234:
0235:            /**
0236:             * TYPE NULLABLE - allows NULL values.
0237:             */
0238:            final int typeNullable = 1;
0239:
0240:            /**
0241:             * TYPE NULLABLE - nullability unknown.
0242:             */
0243:            final int typeNullableUnknown = 2;
0244:
0245:            /**
0246:             * TYPE INFO SEARCHABLE - No support.
0247:             */
0248:            final int typePredNone = 0;
0249:
0250:            /**
0251:             * TYPE INFO SEARCHABLE - Only supported with WHERE .. LIKE.
0252:             */
0253:            final int typePredChar = 1;
0254:
0255:            /**
0256:             * TYPE INFO SEARCHABLE -  Supported except for WHERE .. LIKE.
0257:             */
0258:            final int typePredBasic = 2;
0259:
0260:            /**
0261:             * TYPE INFO SEARCHABLE - Supported for all WHERE ...
0262:             */
0263:            final int typeSearchable = 3;
0264:
0265:            /**
0266:             * INDEX INFO TYPE - this identifies table statistics that are
0267:             * returned in conjuction with a table's index descriptions
0268:             */
0269:            final short tableIndexStatistic = 0;
0270:
0271:            /**
0272:             * INDEX INFO TYPE - this identifies a clustered index
0273:             */
0274:            final short tableIndexClustered = 1;
0275:
0276:            /**
0277:             * INDEX INFO TYPE - this identifies a hashed index
0278:             */
0279:            final short tableIndexHashed = 2;
0280:
0281:            /**
0282:             * INDEX INFO TYPE - this identifies some other form of index
0283:             */
0284:            final short tableIndexOther = 3;
0285:
0286:            //
0287:            // now for the internal data needed by this implemention.
0288:            //
0289:            Tds tds;
0290:
0291:            java.sql.Connection connection;
0292:
0293:            private void debugPrintln(String s) {
0294:                if (verbose) {
0295:                    System.out.println(s);
0296:                }
0297:            }
0298:
0299:            private void debugPrint(String s) {
0300:                if (verbose) {
0301:                    System.out.print(s);
0302:                }
0303:            }
0304:
0305:            private void NotImplemented() throws SQLException {
0306:                try {
0307:                    throw new SQLException("Not implemented");
0308:                } catch (SQLException e) {
0309:                    e.printStackTrace();
0310:                }
0311:                throw new SQLException("Not implemented");
0312:            }
0313:
0314:            public DatabaseMetaData(Object connection_, Tds tds_) {
0315:                connection = (java.sql.Connection) connection_;
0316:                tds = tds_;
0317:            }
0318:
0319:            //----------------------------------------------------------------------
0320:            // First, a variety of minor information about the target database.
0321:
0322:            /**
0323:             * Can all the procedures returned by getProcedures be called by the
0324:             * current user?
0325:             *
0326:             * @return true if so
0327:             * @exception SQLException if a database-access error occurs.
0328:             */
0329:            public boolean allProceduresAreCallable() throws SQLException {
0330:                // XXX Need to check for Sybase
0331:
0332:                return true; // per "Programming ODBC for SQLServer" Appendix A
0333:            }
0334:
0335:            /**
0336:             * Can all the tables returned by getTable be SELECTed by the
0337:             * current user?
0338:             *
0339:             * @return true if so
0340:             * @exception SQLException if a database-access error occurs.
0341:             */
0342:            public boolean allTablesAreSelectable() throws SQLException {
0343:                // XXX Need to check for Sybase
0344:
0345:                // XXX This is dependent on the way we are implementing getTables()
0346:                // it may change in the future.
0347:                return false;
0348:            }
0349:
0350:            /**
0351:             * Does a data definition statement within a transaction force the
0352:             * transaction to commit?
0353:             *
0354:             * @return true if so
0355:             * @exception SQLException if a database-access error occurs.
0356:             */
0357:            public boolean dataDefinitionCausesTransactionCommit()
0358:                    throws SQLException {
0359:                NotImplemented();
0360:                return false;
0361:            }
0362:
0363:            /**
0364:             * Is a data definition statement within a transaction ignored?
0365:             *
0366:             * @return true if so
0367:             * @exception SQLException if a database-access error occurs.
0368:             */
0369:            public boolean dataDefinitionIgnoredInTransactions()
0370:                    throws SQLException {
0371:                NotImplemented();
0372:                return false;
0373:            }
0374:
0375:            /**
0376:             * Did getMaxRowSize() include LONGVARCHAR and LONGVARBINARY
0377:             * blobs?
0378:             *
0379:             * @return true if so
0380:             * @exception SQLException if a database-access error occurs.
0381:             */
0382:            public boolean doesMaxRowSizeIncludeBlobs() throws SQLException {
0383:                return false;
0384:            }
0385:
0386:            /**
0387:             * Get a description of a table's optimal set of columns that
0388:             * uniquely identifies a row. They are ordered by SCOPE.
0389:             *
0390:             * <P>Each column description has the following columns:
0391:             *  <OL>
0392:             *   <LI><B>SCOPE</B> short => actual scope of result
0393:             *      <UL>
0394:             *      <LI> bestRowTemporary - very temporary, while using row
0395:             *      <LI> bestRowTransaction - valid for remainder of current transaction
0396:             *      <LI> bestRowSession - valid for remainder of current session
0397:             *      </UL>
0398:             *   <LI><B>COLUMN_NAME</B> String => column name
0399:             *   <LI><B>DATA_TYPE</B> short => SQL data type from java.sql.Types
0400:             *   <LI><B>TYPE_NAME</B> String => Data source dependent type name
0401:             *   <LI><B>COLUMN_SIZE</B> int => precision
0402:             *   <LI><B>BUFFER_LENGTH</B> int => not used
0403:             *   <LI><B>DECIMAL_DIGITS</B> short  => scale
0404:             *   <LI><B>PSEUDO_COLUMN</B> short => is this a pseudo column
0405:             *      like an Oracle ROWID
0406:             *      <UL>
0407:             *      <LI> bestRowUnknown - may or may not be pseudo column
0408:             *      <LI> bestRowNotPseudo - is NOT a pseudo column
0409:             *      <LI> bestRowPseudo - is a pseudo column
0410:             *      </UL>
0411:             *  </OL>
0412:             *
0413:             * @param catalog a catalog name; "" retrieves those without a
0414:             * catalog; null means drop catalog name from the selection criteria
0415:             * @param schema a schema name; "" retrieves those without a schema
0416:             * @param table a table name
0417:             * @param scope the scope of interest; use same values as SCOPE
0418:             * @param nullable include columns that are nullable?
0419:             * @return ResultSet - each row is a column description
0420:             * @exception SQLException if a database-access error occurs.
0421:             */
0422:            public java.sql.ResultSet getBestRowIdentifier(String catalog,
0423:                    String schema, String table, int scope, boolean nullable)
0424:                    throws SQLException {
0425:                debugPrintln("Inside getBestRowIdentifier with catalog=|"
0426:                        + catalog + "|, schema=|" + schema + "|, table=|"
0427:                        + table + "|, " + " scope=" + scope + ", nullable="
0428:                        + nullable);
0429:
0430:                NotImplemented();
0431:                return null;
0432:            }
0433:
0434:            /**
0435:             * Get the catalog names available in this database.  The results
0436:             * are ordered by catalog name.
0437:             *
0438:             * <P>The catalog column is:
0439:             *  <OL>
0440:             *   <LI><B>TABLE_CAT</B> String => catalog name
0441:             *  </OL>
0442:             *
0443:             * @return ResultSet - each row has a single String column that is a
0444:             * catalog name
0445:             * @exception SQLException if a database-access error occurs.
0446:             */
0447:            public java.sql.ResultSet getCatalogs() throws SQLException {
0448:                // XXX We should really clean up all these temporary tables.
0449:                String tmpName = "#t#" + UniqueId.getUniqueId();
0450:                final String sql = " create table "
0451:                        + tmpName
0452:                        + "                                   "
0453:                        + " (                                                              "
0454:                        + "    q  char(30) not null,                                       "
0455:                        + "    o  char(30) null,                                           "
0456:                        + "    n  char(30) null,                                           "
0457:                        + "    t  char(30) null,                                           "
0458:                        + "    r  varchar(255) null                                        "
0459:                        + " )                                                              "
0460:                        + "                                                                "
0461:                        + " insert into "
0462:                        + tmpName
0463:                        + " EXEC sp_tables ' ', ' ', '%', null "
0464:                        + "                                                                "
0465:                        + " select q from " + tmpName
0466:                        + "                                  " + "";
0467:                java.sql.Statement stmt = connection.createStatement();
0468:                java.sql.ResultSet rs;
0469:
0470:                if (stmt.execute(sql)) {
0471:                    throw new SQLException("Internal error.  Confused");
0472:                }
0473:
0474:                // Eat the data returned by the 'create table'
0475:                if (null != (rs = stmt.getResultSet())) {
0476:                    throw new SQLException("Internal error.  Confused");
0477:                }
0478:
0479:                // Eat the data returned by the 'insert'
0480:                if (null != (rs = stmt.getResultSet())) {
0481:                    // RMK 2000-06-11: test t0051 gets the result set here.
0482:
0483:                    // XXX we really need to figure out what the protocol is doing here.
0484:                    // It appears that sometimes it returns an immediate result set
0485:                    //and sometimes it doesn't.
0486:
0487:                    return rs;
0488:                }
0489:
0490:                // now get the result set
0491:                if (null == (rs = stmt.getResultSet())) {
0492:                    throw new SQLException("Internal error.  Confused");
0493:                }
0494:                return rs;
0495:            }
0496:
0497:            /**
0498:             * What's the separator between catalog and table name?
0499:             *
0500:             * @return the separator string
0501:             * @exception SQLException if a database-access error occurs.
0502:             */
0503:            public String getCatalogSeparator() throws SQLException {
0504:                return ".";
0505:            }
0506:
0507:            /**
0508:             * What's the database vendor's preferred term for "catalog"?
0509:             *
0510:             * @return the vendor term
0511:             * @exception SQLException if a database-access error occurs.
0512:             */
0513:            public String getCatalogTerm() throws SQLException {
0514:
0515:                return "database";
0516:            }
0517:
0518:            /**
0519:             * Get a description of the access rights for a table's columns.
0520:             *
0521:             * <P>Only privileges matching the column name criteria are
0522:             * returned.  They are ordered by COLUMN_NAME and PRIVILEGE.
0523:             *
0524:             * <P>Each privilige description has the following columns:
0525:             *  <OL>
0526:             *   <LI><B>TABLE_CAT</B> String => table catalog (may be null)
0527:             *   <LI><B>TABLE_SCHEM</B> String => table schema (may be null)
0528:             *   <LI><B>TABLE_NAME</B> String => table name
0529:             *   <LI><B>COLUMN_NAME</B> String => column name
0530:             *   <LI><B>GRANTOR</B> => grantor of access (may be null)
0531:             *   <LI><B>GRANTEE</B> String => grantee of access
0532:             *   <LI><B>PRIVILEGE</B> String => name of access (SELECT,
0533:             *      INSERT, UPDATE, REFRENCES, ...)
0534:             *   <LI><B>IS_GRANTABLE</B> String => "YES" if grantee is permitted
0535:             *      to grant to others; "NO" if not; null if unknown
0536:             *  </OL>
0537:             *
0538:             * @param catalog a catalog name; "" retrieves those without a
0539:             * catalog; null means drop catalog name from the selection criteria
0540:             * @param schema a schema name; "" retrieves those without a schema
0541:             * @param table a table name
0542:             * @param columnNamePattern a column name pattern
0543:             * @return ResultSet - each row is a column privilege description
0544:             * @exception SQLException if a database-access error occurs.
0545:             * @see #getSearchStringEscape
0546:             */
0547:            public java.sql.ResultSet getColumnPrivileges(String catalog,
0548:                    String schema, String table, String columnNamePattern)
0549:                    throws SQLException {
0550:                NotImplemented();
0551:                return null;
0552:            }
0553:
0554:            /**
0555:             * Get a description of table columns available in a catalog.
0556:             *
0557:             * <P>Only column descriptions matching the catalog, schema, table
0558:             * and column name criteria are returned.  They are ordered by
0559:             * TABLE_SCHEM, TABLE_NAME and ORDINAL_POSITION.
0560:             *
0561:             * <P>Each column description has the following columns:
0562:             *  <OL>
0563:             *   <LI><B>TABLE_CAT</B> String => table catalog (may be null)
0564:             *   <LI><B>TABLE_SCHEM</B> String => table schema (may be null)
0565:             *   <LI><B>TABLE_NAME</B> String => table name
0566:             *   <LI><B>COLUMN_NAME</B> String => column name
0567:             *   <LI><B>DATA_TYPE</B> short => SQL type from java.sql.Types
0568:             *   <LI><B>TYPE_NAME</B> String => Data source dependent type name
0569:             *   <LI><B>COLUMN_SIZE</B> int => column size.  For char or date
0570:             *       types this is the maximum number of characters, for numeric or
0571:             *       decimal types this is precision.
0572:             *   <LI><B>BUFFER_LENGTH</B> is not used.
0573:             *   <LI><B>DECIMAL_DIGITS</B> int => the number of fractional digits
0574:             *   <LI><B>NUM_PREC_RADIX</B> int => Radix (typically either 10 or 2)
0575:             *   <LI><B>NULLABLE</B> int => is NULL allowed?
0576:             *      <UL>
0577:             *      <LI> columnNoNulls - might not allow NULL values
0578:             *      <LI> columnNullable - definitely allows NULL values
0579:             *      <LI> columnNullableUnknown - nullability unknown
0580:             *      </UL>
0581:             *   <LI><B>REMARKS</B> String => comment describing column (may be null)
0582:             *   <LI><B>COLUMN_DEF</B> String => default value (may be null)
0583:             *   <LI><B>SQL_DATA_TYPE</B> int => unused
0584:             *   <LI><B>SQL_DATETIME_SUB</B> int => unused
0585:             *   <LI><B>CHAR_OCTET_LENGTH</B> int => for char types the
0586:             *       maximum number of bytes in the column
0587:             *   <LI><B>ORDINAL_POSITION</B> int => index of column in table
0588:             *      (starting at 1)
0589:             *   <LI><B>IS_NULLABLE</B> String => "NO" means column definitely
0590:             *      does not allow NULL values; "YES" means the column might
0591:             *      allow NULL values.  An empty string means nobody knows.
0592:             *  </OL>
0593:             *
0594:             * @param catalog a catalog name; "" retrieves those without a
0595:             * catalog; null means drop catalog name from the selection criteria
0596:             * @param schemaPattern a schema name pattern; "" retrieves those
0597:             * without a schema
0598:             * @param tableNamePattern a table name pattern
0599:             * @param columnNamePattern a column name pattern
0600:             * @return ResultSet - each row is a column description
0601:             * @exception SQLException if a database-access error occurs.
0602:             * @see #getSearchStringEscape
0603:             */
0604:            public java.sql.ResultSet getColumns(String catalog,
0605:                    String schemaPattern, String tableNamePattern,
0606:                    String columnNamePattern) throws SQLException {
0607:                debugPrintln("Inside of getColumn");
0608:                debugPrintln("  catalog is |" + catalog + "|");
0609:                debugPrintln("  schemaPattern is " + schemaPattern);
0610:                debugPrintln("  tableNamePattern is " + tableNamePattern);
0611:                debugPrintln("  columnNamePattern is " + columnNamePattern);
0612:
0613:                return getColumns_SQLServer65(catalog, schemaPattern,
0614:                        tableNamePattern, columnNamePattern);
0615:            }
0616:
0617:            private java.sql.ResultSet getColumns_SQLServer65(String catalog,
0618:                    String schemaPattern, String tableNamePattern,
0619:                    String columnNamePattern) throws SQLException {
0620:                int i;
0621:
0622:                String sql = null;
0623:                java.sql.Statement tmpTableStmt = connection.createStatement();
0624:                String catalogCriteria;
0625:
0626:                // XXX We need to come up with something better than a global temporary
0627:                // table.  It could cause problems if two people try to getColumns().
0628:                // (note- it is _unlikely_, not impossible)
0629:                String tmpTableName = "##t#" + UniqueId.getUniqueId();
0630:                String lookup = "#l#" + UniqueId.getUniqueId();
0631:
0632:                // create a temporary table
0633:                sql = "create table " + tmpTableName + " (           "
0634:                        + "    TABLE_CAT         char(32) null,          "
0635:                        + "    TABLE_SCHEM       char(32) null,          "
0636:                        + "    TABLE_NAME        char(32) null,          "
0637:                        + "    COLUMN_NAME       char(32) null,          "
0638:                        + "    DATA_TYPE         integer null,           "
0639:                        + "    TYPE_NAME         char(32) null,          "
0640:                        + "    COLUMN_SIZE       integer null,           "
0641:                        + "    BUFFER_LENGTH     integer null,           "
0642:                        + "    DECIMAL_DIGITS    integer null,           "
0643:                        + "    NUM_PREC_RADIX    integer null,           "
0644:                        + "    NULLABLE          integer null,           "
0645:                        + "    REMARKS           char(255) null,         "
0646:                        + "    COLUMN_DEF        char(255) null,         "
0647:                        + "    SQL_DATA_TYPE     integer null,           "
0648:                        + "    SQL_DATETIME_SUB  integer null,           "
0649:                        + "    CHAR_OCTET_LENGTH integer null,           "
0650:                        + "    ORDINAL_POSITION  integer null,           "
0651:                        + "    IS_NULLABLE       char(3))                " + "";
0652:                tmpTableStmt.execute(sql);
0653:
0654:                // Create a lookup table for mapping between native and jdbc types
0655:                sql = "create table " + lookup + " (       "
0656:                        + "   native_type integer primary key, "
0657:                        + "   jdbc_type   integer not null)    ";
0658:                tmpTableStmt.execute(sql);
0659:
0660:                sql = "insert into " + lookup + " values ( 31, 1111) " + // VOID
0661:                        "insert into " + lookup + " values ( 34, 1111) " + // IMAGE
0662:                        "insert into " + lookup + " values ( 35,   -1) " + // TEXT
0663:                        "insert into " + lookup + " values ( 37,   -3) " + // VARBINARY
0664:                        "insert into " + lookup + " values ( 38,    4) " + // INTN
0665:                        "insert into " + lookup + " values ( 39,   12) " + // VARCHAR
0666:                        "insert into " + lookup + " values ( 45,   -2) " + // BINARY
0667:                        "insert into " + lookup + " values ( 47,    1) " + // CHAR
0668:                        "insert into " + lookup + " values ( 48,   -6) " + // INT1
0669:                        "insert into " + lookup + " values ( 50,   -7) " + // BIT
0670:                        "insert into " + lookup + " values ( 52,    5) " + // INT2
0671:                        "insert into " + lookup + " values ( 56,    4) " + // INT4
0672:                        "insert into " + lookup + " values ( 58,   93) " + // DATETIME4
0673:                        "insert into " + lookup + " values ( 59,    7) " + // REAL
0674:                        "insert into " + lookup + " values ( 60, 1111) " + // MONEY
0675:                        "insert into " + lookup + " values ( 61,   93) " + // DATETIME
0676:                        "insert into " + lookup + " values ( 62,    8) " + // FLT8
0677:                        "insert into " + lookup + " values (106,    3) " + // DECIMAL
0678:                        "insert into " + lookup + " values (108,    2) " + // NUMERIC
0679:                        "insert into " + lookup + " values (109,    8) " + // FLTN
0680:                        "insert into " + lookup + " values (110, 1111) " + // MONEYN
0681:                        "insert into " + lookup + " values (111,   93) " + // DATETIMN
0682:                        "insert into " + lookup + " values (112, 1111) " + // MONEY4
0683:                        "";
0684:                tmpTableStmt.execute(sql);
0685:
0686:                // For each table in the system add its columns
0687:                // Note-  We have to do them one at a time in case
0688:                // there are databases we don't have access to.
0689:                java.sql.ResultSet rs = getTables(null, "%", "%", null);
0690:                while (rs.next()) {
0691:                    String cat = rs.getString(1);
0692:
0693:                    // XXX Security risk.  It 'might' be possible to create
0694:                    // a catalog name that when inserted into this sql statement could
0695:                    // do other commands.
0696:                    sql = "insert into  "
0697:                            + tmpTableName
0698:                            + "                "
0699:                            + "select                                           "
0700:                            + "   TABLE_CAT='"
0701:                            + cat
0702:                            + "',                      "
0703:                            + "   TABLE_SCHEM=USER_NAME(o.uid),                 "
0704:                            + "   TABLE_NAME=o.name,                            "
0705:                            + "   COLUMN_NAME=c.name,                           "
0706:                            + "   DATA_TYPE=l.jdbc_type,                        "
0707:                            + "   TYPE_NAME=t.name,                             "
0708:                            + "   COLUMN_SIZE=c.prec,                           "
0709:                            + "   BUFFER_LENGTH=0,                              "
0710:                            + "   DECIMAL_DIGITS=c.scale,                       "
0711:                            + "   NUM_PREC_RADIX=10,                            "
0712:                            + "   NULLABLE=convert(integer,                     "
0713:                            + "                    convert(bit, c.status&8)),   "
0714:                            + "   REMARKS=null,                                 "
0715:                            + "   COLUMN_DEF=null,                              "
0716:                            + "   SQL_DATATYPE=c.type,                          "
0717:                            + "   SQL_DATETIME_SUB=0,                           "
0718:                            + "   CHAR_OCTET_LENGTH=c.length,                   "
0719:                            + "   ORDINAL_POSITION=c.colid,                     "
0720:                            + "   IS_NULLABLE=                                  "
0721:                            + "      convert(char(3), rtrim(substring           "
0722:                            + "                             ('NO      YES',     "
0723:                            + "                             (c.status&8)+1,3))) "
0724:                            + "from                                             "
0725:                            + "   "
0726:                            + cat
0727:                            + ".dbo.sysobjects o,                 "
0728:                            + "   "
0729:                            + cat
0730:                            + ".dbo.syscolumns c,                 "
0731:                            + "   "
0732:                            + lookup
0733:                            + " l,                             "
0734:                            + "   systypes t                                    "
0735:                            + "where o.type in ('V', 'U') and o.id=c.id         "
0736:                            + "      and t.type=c.type                          "
0737:                            + "      and l.native_type=c.type                   "
0738:                            + "";
0739:                    // System.out.println("Executing \n" + sql + "\n");
0740:                    try {
0741:                        tmpTableStmt.executeUpdate(sql);
0742:                    } catch (SQLException e) {
0743:
0744:                    }
0745:                }
0746:                rs.close();
0747:
0748:                if (catalog == null) {
0749:                    catalog = "";
0750:                    catalogCriteria = " (TABLE_CAT like '%' or TABLE_CAT=?) ";
0751:                } else {
0752:                    catalogCriteria = " TABLE_CAT=? ";
0753:                }
0754:
0755:                sql = "select distinct * from " + tmpTableName
0756:                        + " where           " + catalogCriteria
0757:                        + " and                           "
0758:                        + " TABLE_SCHEM like ?  and  TABLE_NAME  like ?  and  "
0759:                        + " COLUMN_NAME like ?                                "
0760:                        + "order by TABLE_SCHEM, TABLE_NAME, ORDINAL_POSITION ";
0761:
0762:                System.out.println("The query is \n" + sql);
0763:
0764:                java.sql.PreparedStatement ps = connection
0765:                        .prepareStatement(sql);
0766:
0767:                ps.setString(1, catalog);
0768:                ps.setString(2, schemaPattern);
0769:                ps.setString(3, tableNamePattern);
0770:                ps.setString(4, columnNamePattern);
0771:                rs = ps.executeQuery();
0772:
0773:                // We need to do something about deleting the global temporary table
0774:                tmpTableStmt.close();
0775:
0776:                return rs;
0777:            }
0778:
0779:            /**
0780:             * Get a description of the foreign key columns in the foreign key
0781:             * table that reference the primary key columns of the primary key
0782:             * table (describe how one table imports another's key.) This
0783:             * should normally return a single foreign key/primary key pair
0784:             * (most tables only import a foreign key from a table once.)  They
0785:             * are ordered by FKTABLE_CAT, FKTABLE_SCHEM, FKTABLE_NAME, and
0786:             * KEY_SEQ.
0787:             *
0788:             * <P>Each foreign key column description has the following columns:
0789:             *  <OL>
0790:             *   <LI><B>PKTABLE_CAT</B> String => primary key table catalog (may be null)
0791:             *   <LI><B>PKTABLE_SCHEM</B> String => primary key table schema (may be null)
0792:             *   <LI><B>PKTABLE_NAME</B> String => primary key table name
0793:             *   <LI><B>PKCOLUMN_NAME</B> String => primary key column name
0794:             *   <LI><B>FKTABLE_CAT</B> String => foreign key table catalog (may be null)
0795:             *      being exported (may be null)
0796:             *   <LI><B>FKTABLE_SCHEM</B> String => foreign key table schema (may be null)
0797:             *      being exported (may be null)
0798:             *   <LI><B>FKTABLE_NAME</B> String => foreign key table name
0799:             *      being exported
0800:             *   <LI><B>FKCOLUMN_NAME</B> String => foreign key column name
0801:             *      being exported
0802:             *   <LI><B>KEY_SEQ</B> short => sequence number within foreign key
0803:             *   <LI><B>UPDATE_RULE</B> short => What happens to
0804:             *       foreign key when primary is updated:
0805:             *      <UL>
0806:             *      <LI> importedNoAction - do not allow update of primary
0807:             *               key if it has been imported
0808:             *      <LI> importedKeyCascade - change imported key to agree
0809:             *               with primary key update
0810:             *      <LI> importedKeySetNull - change imported key to NULL if
0811:             *               its primary key has been updated
0812:             *      <LI> importedKeySetDefault - change imported key to default values
0813:             *               if its primary key has been updated
0814:             *      <LI> importedKeyRestrict - same as importedKeyNoAction
0815:             *                                 (for ODBC 2.x compatibility)
0816:             *      </UL>
0817:             *   <LI><B>DELETE_RULE</B> short => What happens to
0818:             *      the foreign key when primary is deleted.
0819:             *      <UL>
0820:             *      <LI> importedKeyNoAction - do not allow delete of primary
0821:             *               key if it has been imported
0822:             *      <LI> importedKeyCascade - delete rows that import a deleted key
0823:             *      <LI> importedKeySetNull - change imported key to NULL if
0824:             *               its primary key has been deleted
0825:             *      <LI> importedKeyRestrict - same as importedKeyNoAction
0826:             *                                 (for ODBC 2.x compatibility)
0827:             *      <LI> importedKeySetDefault - change imported key to default if
0828:             *               its primary key has been deleted
0829:             *      </UL>
0830:             *   <LI><B>FK_NAME</B> String => foreign key name (may be null)
0831:             *   <LI><B>PK_NAME</B> String => primary key name (may be null)
0832:             *   <LI><B>DEFERRABILITY</B> short => can the evaluation of foreign key
0833:             *      constraints be deferred until commit
0834:             *      <UL>
0835:             *      <LI> importedKeyInitiallyDeferred - see SQL92 for definition
0836:             *      <LI> importedKeyInitiallyImmediate - see SQL92 for definition
0837:             *      <LI> importedKeyNotDeferrable - see SQL92 for definition
0838:             *      </UL>
0839:             *  </OL>
0840:             *
0841:             * @param primaryCatalog a catalog name; "" retrieves those without a
0842:             * catalog; null means drop catalog name from the selection criteria
0843:             * @param primarySchema a schema name pattern; "" retrieves those
0844:             * without a schema
0845:             * @param primaryTable the table name that exports the key
0846:             * @param foreignCatalog a catalog name; "" retrieves those without a
0847:             * catalog; null means drop catalog name from the selection criteria
0848:             * @param foreignSchema a schema name pattern; "" retrieves those
0849:             * without a schema
0850:             * @param foreignTable the table name that imports the key
0851:             * @return ResultSet - each row is a foreign key column description
0852:             * @exception SQLException if a database-access error occurs.
0853:             * @see #getImportedKeys
0854:             */
0855:            public java.sql.ResultSet getCrossReference(String primaryCatalog,
0856:                    String primarySchema, String primaryTable,
0857:                    String foreignCatalog, String foreignSchema,
0858:                    String foreignTable) throws SQLException {
0859:                NotImplemented();
0860:                return null;
0861:            }
0862:
0863:            /**
0864:             * What's the name of this database product?
0865:             *
0866:             * @return database product name
0867:             * @exception SQLException if a database-access error occurs.
0868:             */
0869:            public String getDatabaseProductName() throws SQLException {
0870:                return tds.getDatabaseProductName();
0871:            }
0872:
0873:            /**
0874:             * What's the version of this database product?
0875:             *
0876:             * @return database version
0877:             * @exception SQLException if a database-access error occurs.
0878:             */
0879:            public String getDatabaseProductVersion() throws SQLException {
0880:                return tds.getDatabaseProductVersion();
0881:            }
0882:
0883:            //----------------------------------------------------------------------
0884:
0885:            /**
0886:             * What's the database's default transaction isolation level?  The
0887:             * values are defined in java.sql.Connection.
0888:             *
0889:             * @return the default isolation level
0890:             * @exception SQLException if a database-access error occurs.
0891:             * @see Connection
0892:             */
0893:            public int getDefaultTransactionIsolation() throws SQLException {
0894:                // XXX need to check this for Sybase
0895:                return Connection.TRANSACTION_READ_COMMITTED;
0896:            }
0897:
0898:            /**
0899:             * What's this JDBC driver's major version number?
0900:             *
0901:             * @return JDBC driver major version
0902:             */
0903:            public int getDriverMajorVersion() {
0904:                return DriverVersion.getDriverMajorVersion();
0905:            }
0906:
0907:            /**
0908:             * What's this JDBC driver's minor version number?
0909:             *
0910:             * @return JDBC driver minor version number
0911:             */
0912:            public int getDriverMinorVersion() {
0913:                return DriverVersion.getDriverMinorVersion();
0914:            }
0915:
0916:            /**
0917:             * What's the name of this JDBC driver?
0918:             *
0919:             * @return JDBC driver name
0920:             * @exception SQLException if a database-access error occurs.
0921:             */
0922:            public String getDriverName() throws SQLException {
0923:                return "InternetCDS Type 4 JDBC driver for MS SQLServer";
0924:            }
0925:
0926:            /**
0927:             * What's the version of this JDBC driver?
0928:             *
0929:             * @return JDBC driver version
0930:             * @exception SQLException if a database-access error occurs.
0931:             */
0932:            public String getDriverVersion() throws SQLException {
0933:                return getDriverMajorVersion() + "." + getDriverMinorVersion();
0934:            }
0935:
0936:            /**
0937:             * Get a description of the foreign key columns that reference a
0938:             * table's primary key columns (the foreign keys exported by a
0939:             * table).  They are ordered by FKTABLE_CAT, FKTABLE_SCHEM,
0940:             * FKTABLE_NAME, and KEY_SEQ.
0941:             *
0942:             * <P>Each foreign key column description has the following columns:
0943:             *  <OL>
0944:             *   <LI><B>PKTABLE_CAT</B> String => primary key table catalog (may be null)
0945:             *   <LI><B>PKTABLE_SCHEM</B> String => primary key table schema (may be null)
0946:             *   <LI><B>PKTABLE_NAME</B> String => primary key table name
0947:             *   <LI><B>PKCOLUMN_NAME</B> String => primary key column name
0948:             *   <LI><B>FKTABLE_CAT</B> String => foreign key table catalog (may be null)
0949:             *      being exported (may be null)
0950:             *   <LI><B>FKTABLE_SCHEM</B> String => foreign key table schema (may be null)
0951:             *      being exported (may be null)
0952:             *   <LI><B>FKTABLE_NAME</B> String => foreign key table name
0953:             *      being exported
0954:             *   <LI><B>FKCOLUMN_NAME</B> String => foreign key column name
0955:             *      being exported
0956:             *   <LI><B>KEY_SEQ</B> short => sequence number within foreign key
0957:             *   <LI><B>UPDATE_RULE</B> short => What happens to
0958:             *       foreign key when primary is updated:
0959:             *      <UL>
0960:             *      <LI> importedNoAction - do not allow update of primary
0961:             *               key if it has been imported
0962:             *      <LI> importedKeyCascade - change imported key to agree
0963:             *               with primary key update
0964:             *      <LI> importedKeySetNull - change imported key to NULL if
0965:             *               its primary key has been updated
0966:             *      <LI> importedKeySetDefault - change imported key to default values
0967:             *               if its primary key has been updated
0968:             *      <LI> importedKeyRestrict - same as importedKeyNoAction
0969:             *                                 (for ODBC 2.x compatibility)
0970:             *      </UL>
0971:             *   <LI><B>DELETE_RULE</B> short => What happens to
0972:             *      the foreign key when primary is deleted.
0973:             *      <UL>
0974:             *      <LI> importedKeyNoAction - do not allow delete of primary
0975:             *               key if it has been imported
0976:             *      <LI> importedKeyCascade - delete rows that import a deleted key
0977:             *      <LI> importedKeySetNull - change imported key to NULL if
0978:             *               its primary key has been deleted
0979:             *      <LI> importedKeyRestrict - same as importedKeyNoAction
0980:             *                                 (for ODBC 2.x compatibility)
0981:             *      <LI> importedKeySetDefault - change imported key to default if
0982:             *               its primary key has been deleted
0983:             *      </UL>
0984:             *   <LI><B>FK_NAME</B> String => foreign key name (may be null)
0985:             *   <LI><B>PK_NAME</B> String => primary key name (may be null)
0986:             *   <LI><B>DEFERRABILITY</B> short => can the evaluation of foreign key
0987:             *      constraints be deferred until commit
0988:             *      <UL>
0989:             *      <LI> importedKeyInitiallyDeferred - see SQL92 for definition
0990:             *      <LI> importedKeyInitiallyImmediate - see SQL92 for definition
0991:             *      <LI> importedKeyNotDeferrable - see SQL92 for definition
0992:             *      </UL>
0993:             *  </OL>
0994:             *
0995:             * @param catalog a catalog name; "" retrieves those without a
0996:             * catalog; null means drop catalog name from the selection criteria
0997:             * @param schema a schema name pattern; "" retrieves those
0998:             * without a schema
0999:             * @param table a table name
1000:             * @return ResultSet - each row is a foreign key column description
1001:             * @exception SQLException if a database-access error occurs.
1002:             * @see #getImportedKeys
1003:             */
1004:            public java.sql.ResultSet getExportedKeys(String catalog,
1005:                    String schema, String table) throws SQLException {
1006:                NotImplemented();
1007:                return null;
1008:            }
1009:
1010:            /**
1011:             * Get all the "extra" characters that can be used in unquoted
1012:             * identifier names (those beyond a-z, A-Z, 0-9 and _).
1013:             *
1014:             * @return the string containing the extra characters
1015:             * @exception SQLException if a database-access error occurs.
1016:             */
1017:            public String getExtraNameCharacters() throws SQLException {
1018:                return "#$";
1019:            }
1020:
1021:            /**
1022:             * What's the string used to quote SQL identifiers?
1023:             * This returns a space " " if identifier quoting isn't supported.
1024:             *
1025:             * A JDBC-Compliant driver always uses a double quote character.
1026:             *
1027:             * @return the quoting string
1028:             * @exception SQLException if a database-access error occurs.
1029:             */
1030:            public String getIdentifierQuoteString() throws SQLException {
1031:                return "\"";
1032:            }
1033:
1034:            /**
1035:             * Get a description of the primary key columns that are
1036:             * referenced by a table's foreign key columns (the primary keys
1037:             * imported by a table).  They are ordered by PKTABLE_CAT,
1038:             * PKTABLE_SCHEM, PKTABLE_NAME, and KEY_SEQ.
1039:             *
1040:             * <P>Each primary key column description has the following columns:
1041:             *  <OL>
1042:             *   <LI><B>PKTABLE_CAT</B> String => primary key table catalog
1043:             *      being imported (may be null)
1044:             *   <LI><B>PKTABLE_SCHEM</B> String => primary key table schema
1045:             *      being imported (may be null)
1046:             *   <LI><B>PKTABLE_NAME</B> String => primary key table name
1047:             *      being imported
1048:             *   <LI><B>PKCOLUMN_NAME</B> String => primary key column name
1049:             *      being imported
1050:             *   <LI><B>FKTABLE_CAT</B> String => foreign key table catalog (may be null)
1051:             *   <LI><B>FKTABLE_SCHEM</B> String => foreign key table schema (may be null)
1052:             *   <LI><B>FKTABLE_NAME</B> String => foreign key table name
1053:             *   <LI><B>FKCOLUMN_NAME</B> String => foreign key column name
1054:             *   <LI><B>KEY_SEQ</B> short => sequence number within foreign key
1055:             *   <LI><B>UPDATE_RULE</B> short => What happens to
1056:             *       foreign key when primary is updated:
1057:             *      <UL>
1058:             *      <LI> importedNoAction - do not allow update of primary
1059:             *               key if it has been imported
1060:             *      <LI> importedKeyCascade - change imported key to agree
1061:             *               with primary key update
1062:             *      <LI> importedKeySetNull - change imported key to NULL if
1063:             *               its primary key has been updated
1064:             *      <LI> importedKeySetDefault - change imported key to default values
1065:             *               if its primary key has been updated
1066:             *      <LI> importedKeyRestrict - same as importedKeyNoAction
1067:             *                                 (for ODBC 2.x compatibility)
1068:             *      </UL>
1069:             *   <LI><B>DELETE_RULE</B> short => What happens to
1070:             *      the foreign key when primary is deleted.
1071:             *      <UL>
1072:             *      <LI> importedKeyNoAction - do not allow delete of primary
1073:             *               key if it has been imported
1074:             *      <LI> importedKeyCascade - delete rows that import a deleted key
1075:             *      <LI> importedKeySetNull - change imported key to NULL if
1076:             *               its primary key has been deleted
1077:             *      <LI> importedKeyRestrict - same as importedKeyNoAction
1078:             *                                 (for ODBC 2.x compatibility)
1079:             *      <LI> importedKeySetDefault - change imported key to default if
1080:             *               its primary key has been deleted
1081:             *      </UL>
1082:             *   <LI><B>FK_NAME</B> String => foreign key name (may be null)
1083:             *   <LI><B>PK_NAME</B> String => primary key name (may be null)
1084:             *   <LI><B>DEFERRABILITY</B> short => can the evaluation of foreign key
1085:             *      constraints be deferred until commit
1086:             *      <UL>
1087:             *      <LI> importedKeyInitiallyDeferred - see SQL92 for definition
1088:             *      <LI> importedKeyInitiallyImmediate - see SQL92 for definition
1089:             *      <LI> importedKeyNotDeferrable - see SQL92 for definition
1090:             *      </UL>
1091:             *  </OL>
1092:             *
1093:             * @param catalog a catalog name; "" retrieves those without a
1094:             * catalog; null means drop catalog name from the selection criteria
1095:             * @param schema a schema name pattern; "" retrieves those
1096:             * without a schema
1097:             * @param table a table name
1098:             * @return ResultSet - each row is a primary key column description
1099:             * @exception SQLException if a database-access error occurs.
1100:             * @see #getExportedKeys
1101:             */
1102:            public java.sql.ResultSet getImportedKeys(String catalog,
1103:                    String schema, String table) throws SQLException {
1104:                NotImplemented();
1105:                return null;
1106:            }
1107:
1108:            /**
1109:             * Get a description of a table's indices and statistics. They are
1110:             * ordered by NON_UNIQUE, TYPE, INDEX_NAME, and ORDINAL_POSITION.
1111:             *
1112:             * <P>Each index column description has the following columns:
1113:             *  <OL>
1114:             *   <LI><B>TABLE_CAT</B> String => table catalog (may be null)
1115:             *   <LI><B>TABLE_SCHEM</B> String => table schema (may be null)
1116:             *   <LI><B>TABLE_NAME</B> String => table name
1117:             *   <LI><B>NON_UNIQUE</B> boolean => Can index values be non-unique?
1118:             *      false when TYPE is tableIndexStatistic
1119:             *   <LI><B>INDEX_QUALIFIER</B> String => index catalog (may be null);
1120:             *      null when TYPE is tableIndexStatistic
1121:             *   <LI><B>INDEX_NAME</B> String => index name; null when TYPE is
1122:             *      tableIndexStatistic
1123:             *   <LI><B>TYPE</B> short => index type:
1124:             *      <UL>
1125:             *      <LI> tableIndexStatistic - this identifies table statistics that are
1126:             *           returned in conjuction with a table's index descriptions
1127:             *      <LI> tableIndexClustered - this is a clustered index
1128:             *      <LI> tableIndexHashed - this is a hashed index
1129:             *      <LI> tableIndexOther - this is some other style of index
1130:             *      </UL>
1131:             *   <LI><B>ORDINAL_POSITION</B> short => column sequence number
1132:             *      within index; zero when TYPE is tableIndexStatistic
1133:             *   <LI><B>COLUMN_NAME</B> String => column name; null when TYPE is
1134:             *      tableIndexStatistic
1135:             *   <LI><B>ASC_OR_DESC</B> String => column sort sequence, "A" => ascending,
1136:             *      "D" => descending, may be null if sort sequence is not supported;
1137:             *      null when TYPE is tableIndexStatistic
1138:             *   <LI><B>CARDINALITY</B> int => When TYPE is tableIndexStatistic, then
1139:             *      this is the number of rows in the table; otherwise, it is the
1140:             *      number of unique values in the index.
1141:             *   <LI><B>PAGES</B> int => When TYPE is  tableIndexStatisic then
1142:             *      this is the number of pages used for the table, otherwise it
1143:             *      is the number of pages used for the current index.
1144:             *   <LI><B>FILTER_CONDITION</B> String => Filter condition, if any.
1145:             *      (may be null)
1146:             *  </OL>
1147:             *
1148:             * @param catalog a catalog name; "" retrieves those without a
1149:             * catalog; null means drop catalog name from the selection criteria
1150:             * @param schema a schema name pattern; "" retrieves those without a schema
1151:             * @param table a table name
1152:             * @param unique when true, return only indices for unique values;
1153:             *     when false, return indices regardless of whether unique or not
1154:             * @param approximate when true, result is allowed to reflect approximate
1155:             *     or out of data values; when false, results are requested to be
1156:             *     accurate
1157:             * @return ResultSet - each row is an index column description
1158:             * @exception SQLException if a database-access error occurs.
1159:             */
1160:            public java.sql.ResultSet getIndexInfo(String catalog,
1161:                    String schema, String table, boolean unique,
1162:                    boolean approximate) throws SQLException {
1163:                NotImplemented();
1164:                return null;
1165:            }
1166:
1167:            //----------------------------------------------------------------------
1168:            // The following group of methods exposes various limitations
1169:            // based on the target database with the current driver.
1170:            // Unless otherwise specified, a result of zero means there is no
1171:            // limit, or the limit is not known.
1172:
1173:            /**
1174:             * How many hex characters can you have in an inline binary literal?
1175:             *
1176:             * @return max literal length
1177:             * @exception SQLException if a database-access error occurs.
1178:             */
1179:            public int getMaxBinaryLiteralLength() throws SQLException {
1180:                // XXX Need to check for Sybase and SQLServer 7.0
1181:
1182:                return 131072; // per "Programming ODBC for SQLServer" Appendix A
1183:            }
1184:
1185:            /**
1186:             * What's the maximum length of a catalog name?
1187:             *
1188:             * @return max name length in bytes
1189:             * @exception SQLException if a database-access error occurs.
1190:             */
1191:            public int getMaxCatalogNameLength() throws SQLException {
1192:                NotImplemented();
1193:                return 0;
1194:            }
1195:
1196:            /**
1197:             * What's the max length for a character literal?
1198:             *
1199:             * @return max literal length
1200:             * @exception SQLException if a database-access error occurs.
1201:             */
1202:            public int getMaxCharLiteralLength() throws SQLException {
1203:                // XXX Need to check for Sybase
1204:
1205:                return 131072; // per "Programming ODBC for SQLServer" Appendix A
1206:            }
1207:
1208:            /**
1209:             * What's the limit on column name length?
1210:             *
1211:             * @return max literal length
1212:             * @exception SQLException if a database-access error occurs.
1213:             */
1214:            public int getMaxColumnNameLength() throws SQLException {
1215:                // XXX Need to check for Sybase
1216:
1217:                return 30; // per "Programming ODBC for SQLServer" Appendix A
1218:            }
1219:
1220:            /**
1221:             * What's the maximum number of columns in a "GROUP BY" clause?
1222:             *
1223:             * @return max number of columns
1224:             * @exception SQLException if a database-access error occurs.
1225:             */
1226:            public int getMaxColumnsInGroupBy() throws SQLException {
1227:                // XXX Need to check for Sybase
1228:
1229:                return 16; // per "Programming ODBC for SQLServer" Appendix A
1230:            }
1231:
1232:            /**
1233:             * What's the maximum number of columns allowed in an index?
1234:             *
1235:             * @return max columns
1236:             * @exception SQLException if a database-access error occurs.
1237:             */
1238:            public int getMaxColumnsInIndex() throws SQLException {
1239:                // XXX need to find out if this is still true for SYBASE
1240:
1241:                // per SQL Server Books Online "Administrator's Companion",
1242:                // Part 1, Chapter 1.
1243:                return 16;
1244:            }
1245:
1246:            /**
1247:             * What's the maximum number of columns in an "ORDER BY" clause?
1248:             *
1249:             * @return max columns
1250:             * @exception SQLException if a database-access error occurs.
1251:             */
1252:            public int getMaxColumnsInOrderBy() throws SQLException {
1253:                // XXX Need to check for Sybase
1254:
1255:                return 16; // per "Programming ODBC for SQLServer" Appendix A
1256:            }
1257:
1258:            /**
1259:             * What's the maximum number of columns in a "SELECT" list?
1260:             *
1261:             * @return max columns
1262:             * @exception SQLException if a database-access error occurs.
1263:             */
1264:            public int getMaxColumnsInSelect() throws SQLException {
1265:                // XXX Need to check for Sybase
1266:
1267:                return 4000; // per "Programming ODBC for SQLServer" Appendix A
1268:            }
1269:
1270:            /**
1271:             * What's the maximum number of columns in a table?
1272:             *
1273:             * @return max columns
1274:             * @exception SQLException if a database-access error occurs.
1275:             */
1276:            public int getMaxColumnsInTable() throws SQLException {
1277:                // XXX How do we find this out for Sybase?
1278:                return 250; // per "Programming ODBC for SQLServer" Appendix A
1279:            }
1280:
1281:            /**
1282:             * How many active connections can we have at a time to this database?
1283:             *
1284:             * @return max connections
1285:             * @exception SQLException if a database-access error occurs.
1286:             */
1287:            public int getMaxConnections() throws SQLException {
1288:                // XXX need to find out if this is still true for SYBASE
1289:
1290:                // per SQL Server Books Online "Administrator's Companion",
1291:                // Part 1, Chapter 1.
1292:                return 32767;
1293:            }
1294:
1295:            /**
1296:             * What's the maximum cursor name length?
1297:             *
1298:             * @return max cursor name length in bytes
1299:             * @exception SQLException if a database-access error occurs.
1300:             */
1301:            public int getMaxCursorNameLength() throws SQLException {
1302:                // XXX Need to check for Sybase
1303:
1304:                return 30; // per "Programming ODBC for SQLServer" Appendix A
1305:            }
1306:
1307:            /**
1308:             * What's the maximum length of an index (in bytes)?
1309:             *
1310:             * @return max index length in bytes
1311:             * @exception SQLException if a database-access error occurs.
1312:             */
1313:            public int getMaxIndexLength() throws SQLException {
1314:                // XXX Need to check for Sybase
1315:
1316:                return 900; // per "Programming ODBC for SQLServer" Appendix A
1317:            }
1318:
1319:            /**
1320:             * What's the maximum length of a procedure name?
1321:             *
1322:             * @return max name length in bytes
1323:             * @exception SQLException if a database-access error occurs.
1324:             */
1325:            public int getMaxProcedureNameLength() throws SQLException {
1326:                // XXX Need to check for Sybase
1327:
1328:                return 36; // per "Programming ODBC for SQLServer" Appendix A
1329:            }
1330:
1331:            /**
1332:             * What's the maximum length of a single row?
1333:             *
1334:             * @return max row size in bytes
1335:             * @exception SQLException if a database-access error occurs.
1336:             */
1337:            public int getMaxRowSize() throws SQLException {
1338:                // XXX need to find out if this is still true for SYBASE
1339:
1340:                // per SQL Server Books Online "Administrator's Companion",
1341:                // Part 1, Chapter 1.
1342:                return 1962;
1343:            }
1344:
1345:            /**
1346:             * What's the maximum length allowed for a schema name?
1347:             *
1348:             * @return max name length in bytes
1349:             * @exception SQLException if a database-access error occurs.
1350:             */
1351:            public int getMaxSchemaNameLength() throws SQLException {
1352:                NotImplemented();
1353:                return 0;
1354:            }
1355:
1356:            /**
1357:             * What's the maximum length of a SQL statement?
1358:             *
1359:             * @return max length in bytes
1360:             * @exception SQLException if a database-access error occurs.
1361:             */
1362:            public int getMaxStatementLength() throws SQLException {
1363:                // XXX Need to check for Sybase
1364:
1365:                //      return 131072; // per "Programming ODBC for SQLServer" Appendix A
1366:                //sinisa
1367:                return 0x20000;
1368:            }
1369:
1370:            /**
1371:             * How many active statements can we have open at one time to this
1372:             * database?
1373:             *
1374:             * @return the maximum
1375:             * @exception SQLException if a database-access error occurs.
1376:             */
1377:            public int getMaxStatements() throws SQLException {
1378:                /*
1379:                NotImplemented(); 
1380:                return 0;
1381:                 */
1382:                //      return 128;
1383:                //sinisa
1384:                return 32767;
1385:            }
1386:
1387:            /**
1388:             * What's the maximum length of a table name?
1389:             *
1390:             * @return max name length in bytes
1391:             * @exception SQLException if a database-access error occurs.
1392:             */
1393:            public int getMaxTableNameLength() throws SQLException {
1394:                // XXX Need to check for Sybase
1395:
1396:                return 30; // per "Programming ODBC for SQLServer" Appendix A
1397:            }
1398:
1399:            /**
1400:             * What's the maximum number of tables in a SELECT?
1401:             *
1402:             * @return the maximum
1403:             * @exception SQLException if a database-access error occurs.
1404:             */
1405:            public int getMaxTablesInSelect() throws SQLException {
1406:                // XXX Need to check for Sybase
1407:
1408:                return 16; // per "Programming ODBC for SQLServer" Appendix A
1409:            }
1410:
1411:            /**
1412:             * What's the maximum length of a user name?
1413:             *
1414:             * @return max name length  in bytes
1415:             * @exception SQLException if a database-access error occurs.
1416:             */
1417:            public int getMaxUserNameLength() throws SQLException {
1418:                // XXX need to find out if this is still true for SYBASE
1419:                return 30;
1420:            }
1421:
1422:            /**
1423:             * Get a comma separated list of math functions.
1424:             *
1425:             * @return the list
1426:             * @exception SQLException if a database-access error occurs.
1427:             */
1428:            public String getNumericFunctions() throws SQLException {
1429:                // XXX need to find out if this is still true for SYBASE
1430:                return "ABS,ACOS,ASIN,ATAN,ATN2,CEILING,COS,COT,"
1431:                        + "DEGREES,EXP,FLOOR,LOG,LOG10,PI,POWER,RADIANS,"
1432:                        + "RAND,ROUND,SIGN,SIN,SQRT,TAN";
1433:            }
1434:
1435:            /**
1436:             * Get a description of a table's primary key columns.  They
1437:             * are ordered by COLUMN_NAME.
1438:             *
1439:             * <P>Each primary key column description has the following columns:
1440:             *  <OL>
1441:             *   <LI><B>TABLE_CAT</B> String => table catalog (may be null)
1442:             *   <LI><B>TABLE_SCHEM</B> String => table schema (may be null)
1443:             *   <LI><B>TABLE_NAME</B> String => table name
1444:             *   <LI><B>COLUMN_NAME</B> String => column name
1445:             *   <LI><B>KEY_SEQ</B> short => sequence number within primary key
1446:             *   <LI><B>PK_NAME</B> String => primary key name (may be null)
1447:             *  </OL>
1448:             *
1449:             * @param catalog a catalog name; "" retrieves those without a
1450:             * catalog; null means drop catalog name from the selection criteria
1451:             * @param schema a schema name pattern; "" retrieves those
1452:             * without a schema
1453:             * @param table a table name
1454:             * @return ResultSet - each row is a primary key column description
1455:             * @exception SQLException if a database-access error occurs.
1456:             */
1457:            public java.sql.ResultSet getPrimaryKeys(String catalog,
1458:                    String schema, String table) throws SQLException {
1459:                NotImplemented();
1460:                return null;
1461:            }
1462:
1463:            /**
1464:             * Get a description of a catalog's stored procedure parameters
1465:             * and result columns.
1466:             *
1467:             * <P>Only descriptions matching the schema, procedure and
1468:             * parameter name criteria are returned.  They are ordered by
1469:             * PROCEDURE_SCHEM and PROCEDURE_NAME. Within this, the return value,
1470:             * if any, is first. Next are the parameter descriptions in call
1471:             * order. The column descriptions follow in column number order.
1472:             *
1473:             * <P>Each row in the ResultSet is a parameter description or
1474:             * column description with the following fields:
1475:             *  <OL>
1476:             *   <LI><B>PROCEDURE_CAT</B> String => procedure catalog (may be null)
1477:             *   <LI><B>PROCEDURE_SCHEM</B> String => procedure schema (may be null)
1478:             *   <LI><B>PROCEDURE_NAME</B> String => procedure name
1479:             *   <LI><B>COLUMN_NAME</B> String => column/parameter name
1480:             *   <LI><B>COLUMN_TYPE</B> Short => kind of column/parameter:
1481:             *      <UL>
1482:             *      <LI> procedureColumnUnknown - nobody knows
1483:             *      <LI> procedureColumnIn - IN parameter
1484:             *      <LI> procedureColumnInOut - INOUT parameter
1485:             *      <LI> procedureColumnOut - OUT parameter
1486:             *      <LI> procedureColumnReturn - procedure return value
1487:             *      <LI> procedureColumnResult - result column in ResultSet
1488:             *      </UL>
1489:             *  <LI><B>DATA_TYPE</B> short => SQL type from java.sql.Types
1490:             *   <LI><B>TYPE_NAME</B> String => SQL type name
1491:             *   <LI><B>PRECISION</B> int => precision
1492:             *   <LI><B>LENGTH</B> int => length in bytes of data
1493:             *   <LI><B>SCALE</B> short => scale
1494:             *   <LI><B>RADIX</B> short => radix
1495:             *   <LI><B>NULLABLE</B> short => can it contain NULL?
1496:             *      <UL>
1497:             *      <LI> procedureNoNulls - does not allow NULL values
1498:             *      <LI> procedureNullable - allows NULL values
1499:             *      <LI> procedureNullableUnknown - nullability unknown
1500:             *      </UL>
1501:             *   <LI><B>REMARKS</B> String => comment describing parameter/column
1502:             *  </OL>
1503:             *
1504:             * <P><B>Note:</B> Some databases may not return the column
1505:             * descriptions for a procedure. Additional columns beyond
1506:             * REMARKS can be defined by the database.
1507:             *
1508:             * @param catalog a catalog name; "" retrieves those without a
1509:             * catalog; null means drop catalog name from the selection criteria
1510:             * @param schemaPattern a schema name pattern; "" retrieves those
1511:             * without a schema
1512:             * @param procedureNamePattern a procedure name pattern
1513:             * @param columnNamePattern a column name pattern
1514:             * @return ResultSet - each row is a stored procedure parameter or
1515:             *      column description
1516:             * @exception SQLException if a database-access error occurs.
1517:             * @see #getSearchStringEscape
1518:             */
1519:            public java.sql.ResultSet getProcedureColumns(String catalog,
1520:                    String schemaPattern, String procedureNamePattern,
1521:                    String columnNamePattern) throws SQLException {
1522:                NotImplemented();
1523:                return null;
1524:            }
1525:
1526:            /**
1527:             * Get a description of stored procedures available in a
1528:             * catalog.
1529:             *
1530:             * <P>Only procedure descriptions matching the schema and
1531:             * procedure name criteria are returned.  They are ordered by
1532:             * PROCEDURE_SCHEM, and PROCEDURE_NAME.
1533:             *
1534:             * <P>Each procedure description has the the following columns:
1535:             *  <OL>
1536:             *   <LI><B>PROCEDURE_CAT</B> String => procedure catalog (may be null)
1537:             *   <LI><B>PROCEDURE_SCHEM</B> String => procedure schema (may be null)
1538:             *   <LI><B>PROCEDURE_NAME</B> String => procedure name
1539:             *  <LI> reserved for future use
1540:             *  <LI> reserved for future use
1541:             *  <LI> reserved for future use
1542:             *   <LI><B>REMARKS</B> String => explanatory comment on the procedure
1543:             *   <LI><B>PROCEDURE_TYPE</B> short => kind of procedure:
1544:             *      <UL>
1545:             *      <LI> procedureResultUnknown - May return a result
1546:             *      <LI> procedureNoResult - Does not return a result
1547:             *      <LI> procedureReturnsResult - Returns a result
1548:             *      </UL>
1549:             *  </OL>
1550:             *
1551:             * @param catalog a catalog name; "" retrieves those without a
1552:             * catalog; null means drop catalog name from the selection criteria
1553:             * @param schemaPattern a schema name pattern; "" retrieves those
1554:             * without a schema
1555:             * @param procedureNamePattern a procedure name pattern
1556:             * @return ResultSet - each row is a procedure description
1557:             * @exception SQLException if a database-access error occurs.
1558:             * @see #getSearchStringEscape
1559:             */
1560:            public java.sql.ResultSet getProcedures(String catalog,
1561:                    String schemaPattern, String procedureNamePattern)
1562:                    throws SQLException {
1563:                debugPrintln("Inside of getProcedures");
1564:                debugPrintln("  catalog is |" + catalog + "|");
1565:                debugPrintln("  schemaPattern is " + schemaPattern);
1566:                debugPrintln("  procedurePattern is " + procedureNamePattern);
1567:
1568:                schemaPattern = schemaPattern.trim();
1569:
1570:                if (tds.getDatabaseProductName().indexOf("Microsoft") >= 0
1571:                        && tds.getDatabaseProductVersion().startsWith("7.")) {
1572:                    String query;
1573:
1574:                    query = ("select PROCEDURE_CAT=?, "
1575:                            + " PROCEDURE_SCHEM=substring(u.name, 1, 32), "
1576:                            + " PROCEDURE_NAME=substring(o.name, 1, 32), "
1577:                            + " '', '', '', " + " REMARKS='', PROCEDURE_TYPE="
1578:                            + java.sql.DatabaseMetaData.procedureResultUnknown + " from ");
1579:                    if (catalog != null && (!catalog.equals(""))) {
1580:                        // XXX need to make sure user doesn't pass in funky strings
1581:                        query = query + catalog + ".";
1582:                    }
1583:                    query = query + "dbo.sysobjects o,  ";
1584:
1585:                    if (catalog != null && (!catalog.equals(""))) {
1586:                        // XXX need to make sure user doesn't pass in funky strings
1587:                        query = query + catalog + ".";
1588:                    }
1589:                    query = query + "dbo.sysusers u ";
1590:
1591:                    query = query + " where o.uid=u.uid and xtype='P' ";
1592:                    query = query + " and u.name like ? "; // schema name
1593:                    query = query + " and o.name like ? "; // procedure name
1594:
1595:                    debugPrintln("Query is |" + query + "|");
1596:
1597:                    java.sql.PreparedStatement ps = connection
1598:                            .prepareStatement(query);
1599:
1600:                    debugPrintln("ps.setString(1, \"" + catalog + "\")");
1601:                    ps.setString(1, catalog);
1602:                    if (schemaPattern == null || schemaPattern.equals("")) {
1603:                        debugPrintln("ps.setString(2, \"%\");");
1604:                        ps.setString(2, "%");
1605:                    } else {
1606:                        debugPrintln("ps.setString(2, \"" + schemaPattern
1607:                                + "\")");
1608:                        ps.setString(2, schemaPattern);
1609:                    }
1610:                    if (procedureNamePattern == null
1611:                            || procedureNamePattern.equals("")) {
1612:                        debugPrintln("ps.setString(3, \"%\");");
1613:                        ps.setString(3, "%");
1614:                    } else {
1615:                        debugPrintln("ps.setString(3, \""
1616:                                + procedureNamePattern + "\")");
1617:                        ps.setString(3, procedureNamePattern);
1618:                    }
1619:
1620:                    java.sql.ResultSet rs = ps.executeQuery();
1621:
1622:                    return rs;
1623:                } else {
1624:                    NotImplemented();
1625:                    return null;
1626:                }
1627:            }
1628:
1629:            /**
1630:             * What's the database vendor's preferred term for "procedure"?
1631:             *
1632:             * @return the vendor term
1633:             * @exception SQLException if a database-access error occurs.
1634:             */
1635:            public String getProcedureTerm() throws SQLException {
1636:                // XXX Need to check for Sybase
1637:
1638:                // per "Programming ODBC for SQLServer" Appendix A
1639:                return "stored procedure";
1640:            }
1641:
1642:            /**
1643:             * Get the schema names available in this database.  The results
1644:             * are ordered by schema name.
1645:             *
1646:             * <P>The schema column is:
1647:             *  <OL>
1648:             *   <LI><B>TABLE_SCHEM</B> String => schema name
1649:             *  </OL>
1650:             *
1651:             * @return ResultSet - each row has a single String column that is a
1652:             * schema name
1653:             * @exception SQLException if a database-access error occurs.
1654:             */
1655:            public java.sql.ResultSet getSchemas() throws SQLException {
1656:                // XXX We should really clean up all these temporary tables.
1657:                String tmpName = "#t#" + UniqueId.getUniqueId();
1658:                final String sql = " create table "
1659:                        + tmpName
1660:                        + "                                   "
1661:                        + " (                                                              "
1662:                        + "    q  char(30) null,                                           "
1663:                        + "    o  char(30) not null,                                       "
1664:                        + "    n  char(30) null,                                           "
1665:                        + "    t  char(30) null,                                           "
1666:                        + "    r  varchar(255) null                                        "
1667:                        + " )                                                              "
1668:                        + "                                                                "
1669:                        + " insert into "
1670:                        + tmpName
1671:                        + " EXEC sp_tables ' ', '%', ' ', null "
1672:                        + "                                                                "
1673:                        + " select TABLE_SCHEM=o from " + tmpName
1674:                        + "                      " + "";
1675:                java.sql.Statement stmt = connection.createStatement();
1676:                java.sql.ResultSet rs;
1677:
1678:                if (stmt.execute(sql)) {
1679:                    throw new SQLException("Internal error.  "
1680:                            + "Unexpected result from stmt.execute(sql) "
1681:                            + "inside of getSchemas");
1682:                }
1683:
1684:                if (stmt.getMoreResults()) {
1685:                    throw new SQLException("Internal error.  "
1686:                            + "Was expecting an update count "
1687:                            + "inside of getSchemas");
1688:                } else {
1689:                    int updateCount = stmt.getUpdateCount();
1690:                }
1691:
1692:                if (!stmt.getMoreResults()) {
1693:                    throw new SQLException("Internal error.  "
1694:                            + "Was expecting an result set "
1695:                            + "inside of getSchemas");
1696:                } else {
1697:                    rs = stmt.getResultSet();
1698:                }
1699:
1700:                return rs;
1701:            }
1702:
1703:            /**
1704:             * What's the database vendor's preferred term for "schema"?
1705:             *
1706:             * @return the vendor term
1707:             * @exception SQLException if a database-access error occurs.
1708:             */
1709:            public String getSchemaTerm() throws SQLException {
1710:                // need to check this for Sybase
1711:                return "owner";
1712:            }
1713:
1714:            /**
1715:             * This is the string that can be used to escape '_' or '%' in
1716:             * the string pattern style catalog search parameters.
1717:             *
1718:             * <P>The '_' character represents any single character.
1719:             * <P>The '%' character represents any sequence of zero or
1720:             * more characters.
1721:             *
1722:             * @return the string used to escape wildcard characters
1723:             * @exception SQLException if a database-access error occurs.
1724:             */
1725:            public String getSearchStringEscape() throws SQLException {
1726:                // XXX Need to check for Sybase
1727:
1728:                return "\\"; // per "Programming ODBC for SQLServer" Appendix A
1729:            }
1730:
1731:            /**
1732:             * Get a comma separated list of all a database's SQL keywords
1733:             * that are NOT also SQL92 keywords.
1734:             *
1735:             * @return the list
1736:             * @exception SQLException if a database-access error occurs.
1737:             */
1738:            public String getSQLKeywords() throws SQLException {
1739:                NotImplemented();
1740:                return null;
1741:            }
1742:
1743:            /**
1744:             * Get a comma separated list of string functions.
1745:             *
1746:             * @return the list
1747:             * @exception SQLException if a database-access error occurs.
1748:             */
1749:            public String getStringFunctions() throws SQLException {
1750:                return "LTRIM,SOUNDEX,ASCII,PATINDEX,SPACE,CHAR,REPLICATE,"
1751:                        + "STR,CHARINDEX,REVERSE,STUFF,DIFFERENCE,RIGHT,"
1752:                        + "SUBSTRING,LOWER,RTRIM,UPPER";
1753:            }
1754:
1755:            /**
1756:             * Get a comma separated list of system functions.
1757:             *
1758:             * @return the list
1759:             * @exception SQLException if a database-access error occurs.
1760:             */
1761:            public String getSystemFunctions() throws SQLException {
1762:                return "COALESCE," + "COL_LENGTH," + "COL_NAME,"
1763:                        + "DATALENGTH," + "DB_ID," + "DB_NAME,"
1764:                        + "GETANSINULL," + "HOST_ID," + "HOST_NAME,"
1765:                        + "IDENT_INCR," + "IDENT_SEED," + "INDEX_COL,"
1766:                        + "ISNULL," + "NULLIF," + "OBJECT_ID," + "OBJECT_NAME,"
1767:                        + "STATS_DATE," + "SUSER_ID," + "SUSER_NAME,"
1768:                        + "USER_ID," + "USER_NAME";
1769:            }
1770:
1771:            /**
1772:             * Get a description of the access rights for each table available
1773:             * in a catalog. Note that a table privilege applies to one or
1774:             * more columns in the table. It would be wrong to assume that
1775:             * this priviledge applies to all columns (this may be true for
1776:             * some systems but is not true for all.)
1777:             *
1778:             * <P>Only privileges matching the schema and table name
1779:             * criteria are returned.  They are ordered by TABLE_SCHEM,
1780:             * TABLE_NAME, and PRIVILEGE.
1781:             *
1782:             * <P>Each privilige description has the following columns:
1783:             *  <OL>
1784:             *   <LI><B>TABLE_CAT</B> String => table catalog (may be null)
1785:             *   <LI><B>TABLE_SCHEM</B> String => table schema (may be null)
1786:             *   <LI><B>TABLE_NAME</B> String => table name
1787:             *   <LI><B>GRANTOR</B> => grantor of access (may be null)
1788:             *   <LI><B>GRANTEE</B> String => grantee of access
1789:             *   <LI><B>PRIVILEGE</B> String => name of access (SELECT,
1790:             *      INSERT, UPDATE, REFRENCES, ...)
1791:             *   <LI><B>IS_GRANTABLE</B> String => "YES" if grantee is permitted
1792:             *      to grant to others; "NO" if not; null if unknown
1793:             *  </OL>
1794:             *
1795:             * @param catalog a catalog name; "" retrieves those without a
1796:             * catalog; null means drop catalog name from the selection criteria
1797:             * @param schemaPattern a schema name pattern; "" retrieves those
1798:             * without a schema
1799:             * @param tableNamePattern a table name pattern
1800:             * @return ResultSet - each row is a table privilege description
1801:             * @exception SQLException if a database-access error occurs.
1802:             * @see #getSearchStringEscape
1803:             */
1804:            public java.sql.ResultSet getTablePrivileges(String catalog,
1805:                    String schemaPattern, String tableNamePattern)
1806:                    throws SQLException {
1807:                NotImplemented();
1808:                return null;
1809:            }
1810:
1811:            /**
1812:             * Get a description of tables available in a catalog.
1813:             *
1814:             * <P>Only table descriptions matching the catalog, schema, table
1815:             * name and type criteria are returned.  They are ordered by
1816:             * TABLE_TYPE, TABLE_SCHEM and TABLE_NAME.
1817:             *
1818:             * <P>Each table description has the following columns:
1819:             *  <OL>
1820:             *   <LI><B>TABLE_CAT</B> String => table catalog (may be null)
1821:             *   <LI><B>TABLE_SCHEM</B> String => table schema (may be null)
1822:             *   <LI><B>TABLE_NAME</B> String => table name
1823:             *   <LI><B>TABLE_TYPE</B> String => table type.  Typical types are "TABLE",
1824:             *                   "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY",
1825:             *                   "LOCAL TEMPORARY", "ALIAS", "SYNONYM".
1826:             *   <LI><B>REMARKS</B> String => explanatory comment on the table
1827:             *  </OL>
1828:             *
1829:             * <P><B>Note:</B> Some databases may not return information for
1830:             * all tables.
1831:             *
1832:             * @param catalog a catalog name; "" retrieves those without a
1833:             * catalog; null means drop catalog name from the selection criteria
1834:             * @param schemaPattern a schema name pattern; "" retrieves those
1835:             * without a schema
1836:             * @param tableNamePattern a table name pattern
1837:             * @param types a list of table types to include; null returns all types
1838:             * @return ResultSet - each row is a table description
1839:             * @exception SQLException if a database-access error occurs.
1840:             * @see #getSearchStringEscape
1841:             */
1842:            public java.sql.ResultSet getTables(String catalog,
1843:                    String schemaPattern, String tableNamePattern,
1844:                    String types[]) throws SQLException {
1845:                int paramIndex;
1846:                int i;
1847:
1848:                String sql = null;
1849:                java.sql.Statement tmpTableStmt = connection.createStatement();
1850:
1851:                // XXX We need to come up with something better than a global temporary
1852:                // table.  It could cause problems if two people try to getTables().
1853:                // (note- it is unlikely to cause any problems, but it is possible)
1854:                String tmpTableName = "##t#" + UniqueId.getUniqueId();
1855:                String catalogCriteria;
1856:                String schemaCriteria;
1857:                String tableCriteria;
1858:                String typesCriteria;
1859:
1860:                if (schemaPattern != null) {
1861:                    schemaPattern = schemaPattern.trim();
1862:                }
1863:                if (tableNamePattern != null) {
1864:                    tableNamePattern = tableNamePattern.trim();
1865:                }
1866:
1867:                debugPrintln("inside getTables");
1868:                debugPrintln("  catalog is |" + catalog + "|");
1869:                debugPrintln("  schemaPattern is |" + schemaPattern + "|");
1870:                debugPrintln("  tableNamePattern is |" + tableNamePattern + "|");
1871:                if (types == null) {
1872:                    System.out.println("types is null");
1873:                } else {
1874:                    for (i = 0; i < types.length; i++) {
1875:                        debugPrintln("  types[" + i + "] is |" + types[i]);
1876:                    }
1877:                }
1878:
1879:                // create a temporary table
1880:                sql = "create table " + tmpTableName + " ( "
1881:                        + "    cat    char(32) null,           "
1882:                        + "    schem  char(32) null,           "
1883:                        + "    name   char(32) null,           "
1884:                        + "    type   char(32) null,           "
1885:                        + "    rem    char(255) null)          ";
1886:                tmpTableStmt.execute(sql);
1887:
1888:                // For each database in the system add its tables
1889:                // Note-  We have to do them one at a time in case
1890:                // there are databases we don't have access to.
1891:                java.sql.ResultSet rs = getCatalogs();
1892:                while (rs.next()) {
1893:                    String cat = rs.getString(1);
1894:
1895:                    sql = "insert into "
1896:                            + tmpTableName
1897:                            + "                            "
1898:                            + "    select '"
1899:                            + cat
1900:                            + "', USER_NAME(uid), name,  type, null "
1901:                            + "        from "
1902:                            + cat
1903:                            + ".dbo.sysobjects                     "
1904:                            + "        where type in ('S', 'U', 'V')                       ";
1905:                    try {
1906:                        tmpTableStmt.executeUpdate(sql);
1907:                    } catch (SQLException e) {
1908:                        // We might not have access to certain tables.  Just ignore the 
1909:                        // error if this is the case.
1910:                    }
1911:                }
1912:                rs.close();
1913:
1914:                sql = "update " + tmpTableName + " "
1915:                        + "  set type='SYSTEM TABLE' where type='S'";
1916:                tmpTableStmt.executeUpdate(sql);
1917:
1918:                sql = "update " + tmpTableName + " "
1919:                        + "  set type='TABLE' where type='U'";
1920:                tmpTableStmt.executeUpdate(sql);
1921:
1922:                sql = "update " + tmpTableName + " "
1923:                        + "  set type='VIEW' where type='V'";
1924:                tmpTableStmt.executeUpdate(sql);
1925:
1926:                if (catalog == null) {
1927:                    catalog = "";
1928:                    catalogCriteria = " (cat like '%' or cat=?) ";
1929:                } else {
1930:                    catalogCriteria = " cat=? ";
1931:                }
1932:                if (schemaPattern == null) {
1933:                    schemaPattern = "%";
1934:                }
1935:                if (tableNamePattern == null) {
1936:                    tableNamePattern = "%";
1937:                }
1938:
1939:                sql = "select TABLE_CAT=cat, TABLE_SCHEM=schem, "
1940:                        + "     TABLE_NAME=name, TABLE_TYPE=type, "
1941:                        + "     REMARKS=rem                       " + " from "
1942:                        + tmpTableName + " where " + catalogCriteria + " and "
1943:                        + " schem like ?  and " + " name like ?   ";
1944:                if (types != null && types.length > 0) {
1945:                    sql = sql + " and ( type = ? ";
1946:
1947:                    for (i = 1; i < types.length; i++) {
1948:                        sql = sql + " or type=? ";
1949:                    }
1950:                    sql = sql + " )";
1951:                }
1952:
1953:                java.sql.PreparedStatement ps = connection
1954:                        .prepareStatement(sql);
1955:
1956:                ps.setString(1, catalog);
1957:                ps.setString(2, schemaPattern);
1958:                ps.setString(3, tableNamePattern);
1959:                for (i = 0; types != null && i < types.length; i++) {
1960:                    ps.setString(i + 4, types[i]);
1961:                }
1962:                rs = ps.executeQuery();
1963:
1964:                // We need to do something about deleting the global temporary table
1965:                tmpTableStmt.close();
1966:
1967:                return rs;
1968:            }
1969:
1970:            /**
1971:             * Get the table types available in this database.  The results
1972:             * are ordered by table type.
1973:             *
1974:             * <P>The table type is:
1975:             *  <OL>
1976:             *   <LI><B>TABLE_TYPE</B> String => table type.  Typical types are "TABLE",
1977:             *                   "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY",
1978:             *                   "LOCAL TEMPORARY", "ALIAS", "SYNONYM".
1979:             *  </OL>
1980:             *
1981:             * @return ResultSet - each row has a single String column that is a
1982:             * table type
1983:             * @exception SQLException if a database-access error occurs.
1984:             */
1985:            public java.sql.ResultSet getTableTypes() throws SQLException {
1986:                // XXX see if this is still true for Sybase
1987:                String sql = "select 'TABLE' TABLE_TYPE              "
1988:                        + "union select 'VIEW' TABLE_TYPE         "
1989:                        + "union select 'SYSTEM TABLE' TABLE_TYPE ";
1990:                java.sql.Statement stmt = connection.createStatement();
1991:                java.sql.ResultSet rs = stmt.executeQuery(sql);
1992:
1993:                return rs;
1994:            }
1995:
1996:            /**
1997:             * Get a comma separated list of time and date functions.
1998:             *
1999:             * @return the list
2000:             * @exception SQLException if a database-access error occurs.
2001:             */
2002:            public String getTimeDateFunctions() throws SQLException {
2003:                return "GETDATE,DATEPART,DATENAME,DATEDIFF,DATEADD";
2004:            }
2005:
2006:            /**
2007:             * Get a description of all the standard SQL types supported by
2008:             * this database. They are ordered by DATA_TYPE and then by how
2009:             * closely the data type maps to the corresponding JDBC SQL type.
2010:             *
2011:             * <P>Each type description has the following columns:
2012:             *  <OL>
2013:             *   <LI><B>TYPE_NAME</B> String => Type name
2014:             *   <LI><B>DATA_TYPE</B> short => SQL data type from java.sql.Types
2015:             *   <LI><B>PRECISION</B> int => maximum precision
2016:             *   <LI><B>LITERAL_PREFIX</B> String => prefix used to quote a literal
2017:             *      (may be null)
2018:             *   <LI><B>LITERAL_SUFFIX</B> String => suffix used to quote a literal
2019:             (may be null)
2020:             *   <LI><B>CREATE_PARAMS</B> String => parameters used in creating
2021:             *      the type (may be null)
2022:             *   <LI><B>NULLABLE</B> short => can you use NULL for this type?
2023:             *      <UL>
2024:             *      <LI> typeNoNulls - does not allow NULL values
2025:             *      <LI> typeNullable - allows NULL values
2026:             *      <LI> typeNullableUnknown - nullability unknown
2027:             *      </UL>
2028:             *   <LI><B>CASE_SENSITIVE</B> boolean=> is it case sensitive?
2029:             *   <LI><B>SEARCHABLE</B> short => can you use "WHERE" based on this type:
2030:             *      <UL>
2031:             *      <LI> typePredNone - No support
2032:             *      <LI> typePredChar - Only supported with WHERE .. LIKE
2033:             *      <LI> typePredBasic - Supported except for WHERE .. LIKE
2034:             *      <LI> typeSearchable - Supported for all WHERE ..
2035:             *      </UL>
2036:             *   <LI><B>UNSIGNED_ATTRIBUTE</B> boolean => is it unsigned?
2037:             *   <LI><B>FIXED_PREC_SCALE</B> boolean => can it be a money value?
2038:             *   <LI><B>AUTO_INCREMENT</B> boolean => can it be used for an
2039:             *      auto-increment value?
2040:             *   <LI><B>LOCAL_TYPE_NAME</B> String => localized version of type name
2041:             *      (may be null)
2042:             *   <LI><B>MINIMUM_SCALE</B> short => minimum scale supported
2043:             *   <LI><B>MAXIMUM_SCALE</B> short => maximum scale supported
2044:             *   <LI><B>SQL_DATA_TYPE</B> int => unused
2045:             *   <LI><B>SQL_DATETIME_SUB</B> int => unused
2046:             *   <LI><B>NUM_PREC_RADIX</B> int => usually 2 or 10
2047:             *  </OL>
2048:             *
2049:             * @return ResultSet - each row is a SQL type description
2050:             * @exception SQLException if a database-access error occurs.
2051:             */
2052:            public java.sql.ResultSet getTypeInfo() throws SQLException {
2053:                NotImplemented();
2054:                return null;
2055:            }
2056:
2057:            /**
2058:             * What's the url for this database?
2059:             *
2060:             * @return the url or null if it can't be generated
2061:             * @exception SQLException if a database-access error occurs.
2062:             */
2063:            public String getURL() throws SQLException {
2064:                return ((ConnectionHelper) connection).getUrl();
2065:            }
2066:
2067:            /**
2068:             * What's our user name as known to the database?
2069:             *
2070:             * @return our database user name
2071:             * @exception SQLException if a database-access error occurs.
2072:             */
2073:            public String getUserName() throws SQLException {
2074:                java.sql.Statement s = null;
2075:                java.sql.ResultSet rs = null;
2076:                String result = "";
2077:
2078:                try {
2079:                    s = connection.createStatement();
2080:                    // XXX Need to check this for Sybase
2081:                    rs = s.executeQuery("select USER_NAME()");
2082:
2083:                    if (!rs.next()) {
2084:                        throw new SQLException("Couldn't determine user name");
2085:                    }
2086:                    result = rs.getString(1);
2087:                } finally {
2088:                    if (rs != null) {
2089:                        rs.close();
2090:                    }
2091:                    if (s != null) {
2092:                        s.close();
2093:                    }
2094:                }
2095:                return result;
2096:            }
2097:
2098:            /**
2099:             * Get a description of a table's columns that are automatically
2100:             * updated when any value in a row is updated.  They are
2101:             * unordered.
2102:             *
2103:             * <P>Each column description has the following columns:
2104:             *  <OL>
2105:             *   <LI><B>SCOPE</B> short => is not used
2106:             *   <LI><B>COLUMN_NAME</B> String => column name
2107:             *   <LI><B>DATA_TYPE</B> short => SQL data type from java.sql.Types
2108:             *   <LI><B>TYPE_NAME</B> String => Data source dependent type name
2109:             *   <LI><B>COLUMN_SIZE</B> int => precision
2110:             *   <LI><B>BUFFER_LENGTH</B> int => length of column value in bytes
2111:             *   <LI><B>DECIMAL_DIGITS</B> short  => scale
2112:             *   <LI><B>PSEUDO_COLUMN</B> short => is this a pseudo column
2113:             *      like an Oracle ROWID
2114:             *      <UL>
2115:             *      <LI> versionColumnUnknown - may or may not be pseudo column
2116:             *      <LI> versionColumnNotPseudo - is NOT a pseudo column
2117:             *      <LI> versionColumnPseudo - is a pseudo column
2118:             *      </UL>
2119:             *  </OL>
2120:             *
2121:             * @param catalog a catalog name; "" retrieves those without a
2122:             * catalog; null means drop catalog name from the selection criteria
2123:             * @param schema a schema name; "" retrieves those without a schema
2124:             * @param table a table name
2125:             * @return ResultSet - each row is a column description
2126:             * @exception SQLException if a database-access error occurs.
2127:             */
2128:            public java.sql.ResultSet getVersionColumns(String catalog,
2129:                    String schema, String table) throws SQLException {
2130:                NotImplemented();
2131:                return null;
2132:            }
2133:
2134:            /**
2135:             * Does a catalog appear at the start of a qualified table name?
2136:             * (Otherwise it appears at the end)
2137:             *
2138:             * @return true if it appears at the start
2139:             * @exception SQLException if a database-access error occurs.
2140:             */
2141:            public boolean isCatalogAtStart() throws SQLException {
2142:                return true;
2143:            }
2144:
2145:            /**
2146:             * Is the database in read-only mode?
2147:             *
2148:             * @return true if so
2149:             * @exception SQLException if a database-access error occurs.
2150:             */
2151:            public boolean isReadOnly() throws SQLException {
2152:                NotImplemented();
2153:                return false;
2154:            }
2155:
2156:            /**
2157:             * Are concatenations between NULL and non-NULL values NULL?
2158:             *
2159:             * A JDBC-Compliant driver always returns true.
2160:             *
2161:             * @return true if so
2162:             * @exception SQLException if a database-access error occurs.
2163:             */
2164:            public boolean nullPlusNonNullIsNull() throws SQLException {
2165:                // XXX Need to check for Sybase.
2166:
2167:                // MS SQLServer seems to break with the SQL standard here.
2168:                // maybe there is an option to make null behavior comply
2169:                return false;
2170:            }
2171:
2172:            /**
2173:             * Are NULL values sorted at the end regardless of sort order?
2174:             *
2175:             * @return true if so
2176:             * @exception SQLException if a database-access error occurs.
2177:             */
2178:            public boolean nullsAreSortedAtEnd() throws SQLException {
2179:                // XXX Need to check for Sybase
2180:
2181:                // This contradicts "Programming ODBC for SQLServer" Appendix A
2182:                return false;
2183:            }
2184:
2185:            /**
2186:             * Are NULL values sorted at the start regardless of sort order?
2187:             *
2188:             * @return true if so
2189:             * @exception SQLException if a database-access error occurs.
2190:             */
2191:            public boolean nullsAreSortedAtStart() throws SQLException {
2192:                // XXX Need to check for Sybase
2193:
2194:                // This contradicts "Programming ODBC for SQLServer" Appendix A
2195:                return true;
2196:            }
2197:
2198:            /**
2199:             * Are NULL values sorted high?
2200:             *
2201:             * @return true if so
2202:             * @exception SQLException if a database-access error occurs.
2203:             */
2204:            public boolean nullsAreSortedHigh() throws SQLException {
2205:                // XXX Need to check for Sybase
2206:
2207:                // This contradicts "Programming ODBC for SQLServer" Appendix A
2208:                return false;
2209:            }
2210:
2211:            /**
2212:             * Are NULL values sorted low?
2213:             *
2214:             * @return true if so
2215:             * @exception SQLException if a database-access error occurs.
2216:             */
2217:            public boolean nullsAreSortedLow() throws SQLException {
2218:                // XXX Need to check for Sybase
2219:
2220:                // This contradicts "Programming ODBC for SQLServer" Appendix A
2221:                return false;
2222:            }
2223:
2224:            /**
2225:             * Does the database treat mixed case unquoted SQL identifiers as
2226:             * case insensitive and store them in lower case?
2227:             *
2228:             * @return true if so
2229:             * @exception SQLException if a database-access error occurs.
2230:             */
2231:            public boolean storesLowerCaseIdentifiers() throws SQLException {
2232:                // according to "Programming ODBC for SQLServer" Appendix A this
2233:                // depends on how the SQLServer was installed.
2234:                NotImplemented();
2235:                return false;
2236:            }
2237:
2238:            /**
2239:             * Does the database treat mixed case quoted SQL identifiers as
2240:             * case insensitive and store them in lower case?
2241:             *
2242:             * @return true if so
2243:             * @exception SQLException if a database-access error occurs.
2244:             */
2245:            public boolean storesLowerCaseQuotedIdentifiers()
2246:                    throws SQLException {
2247:                NotImplemented();
2248:                return false;
2249:            }
2250:
2251:            /**
2252:             * Does the database treat mixed case unquoted SQL identifiers as
2253:             * case insensitive and store them in mixed case?
2254:             *
2255:             * @return true if so
2256:             * @exception SQLException if a database-access error occurs.
2257:             */
2258:            public boolean storesMixedCaseIdentifiers() throws SQLException {
2259:                NotImplemented();
2260:                return false;
2261:            }
2262:
2263:            /**
2264:             * Does the database treat mixed case quoted SQL identifiers as
2265:             * case insensitive and store them in mixed case?
2266:             *
2267:             * @return true if so
2268:             * @exception SQLException if a database-access error occurs.
2269:             */
2270:            public boolean storesMixedCaseQuotedIdentifiers()
2271:                    throws SQLException {
2272:                NotImplemented();
2273:                return false;
2274:            }
2275:
2276:            /**
2277:             * Does the database treat mixed case unquoted SQL identifiers as
2278:             * case insensitive and store them in upper case?
2279:             *
2280:             * @return true if so
2281:             * @exception SQLException if a database-access error occurs.
2282:             */
2283:            public boolean storesUpperCaseIdentifiers() throws SQLException {
2284:                NotImplemented();
2285:                return false;
2286:            }
2287:
2288:            /**
2289:             * Does the database treat mixed case quoted SQL identifiers as
2290:             * case insensitive and store them in upper case?
2291:             *
2292:             * @return true if so
2293:             * @exception SQLException if a database-access error occurs.
2294:             */
2295:            public boolean storesUpperCaseQuotedIdentifiers()
2296:                    throws SQLException {
2297:                NotImplemented();
2298:                return false;
2299:            }
2300:
2301:            //--------------------------------------------------------------------
2302:            // Functions describing which features are supported.
2303:
2304:            /**
2305:             * Is "ALTER TABLE" with add column supported?
2306:             *
2307:             * @return true if so
2308:             * @exception SQLException if a database-access error occurs.
2309:             */
2310:            public boolean supportsAlterTableWithAddColumn()
2311:                    throws SQLException {
2312:                return true;
2313:            }
2314:
2315:            /**
2316:             * Is "ALTER TABLE" with drop column supported?
2317:             *
2318:             * @return true if so
2319:             * @exception SQLException if a database-access error occurs.
2320:             */
2321:            public boolean supportsAlterTableWithDropColumn()
2322:                    throws SQLException {
2323:                return false;
2324:            }
2325:
2326:            /**
2327:             * Is the ANSI92 entry level SQL grammar supported?
2328:             *
2329:             * All JDBC-Compliant drivers must return true.
2330:             *
2331:             * @return true if so
2332:             * @exception SQLException if a database-access error occurs.
2333:             */
2334:            public boolean supportsANSI92EntryLevelSQL() throws SQLException {
2335:                NotImplemented();
2336:                return false;
2337:            }
2338:
2339:            /**
2340:             * Is the ANSI92 full SQL grammar supported?
2341:             *
2342:             * @return true if so
2343:             * @exception SQLException if a database-access error occurs.
2344:             */
2345:            public boolean supportsANSI92FullSQL() throws SQLException {
2346:                NotImplemented();
2347:                return false;
2348:            }
2349:
2350:            /**
2351:             * Is the ANSI92 intermediate SQL grammar supported?
2352:             *
2353:             * @return true if so
2354:             * @exception SQLException if a database-access error occurs.
2355:             */
2356:            public boolean supportsANSI92IntermediateSQL() throws SQLException {
2357:                NotImplemented();
2358:                return false;
2359:            }
2360:
2361:            /**
2362:             * Can a catalog name be used in a data manipulation statement?
2363:             *
2364:             * @return true if so
2365:             * @exception SQLException if a database-access error occurs.
2366:             */
2367:            public boolean supportsCatalogsInDataManipulation()
2368:                    throws SQLException {
2369:                NotImplemented();
2370:                return false;
2371:            }
2372:
2373:            /**
2374:             * Can a catalog name be used in an index definition statement?
2375:             *
2376:             * @return true if so
2377:             * @exception SQLException if a database-access error occurs.
2378:             */
2379:            public boolean supportsCatalogsInIndexDefinitions()
2380:                    throws SQLException {
2381:                NotImplemented();
2382:                return false;
2383:            }
2384:
2385:            /**
2386:             * Can a catalog name be used in a privilege definition statement?
2387:             *
2388:             * @return true if so
2389:             * @exception SQLException if a database-access error occurs.
2390:             */
2391:            public boolean supportsCatalogsInPrivilegeDefinitions()
2392:                    throws SQLException {
2393:                NotImplemented();
2394:                return false;
2395:            }
2396:
2397:            /**
2398:             * Can a catalog name be used in a procedure call statement?
2399:             *
2400:             * @return true if so
2401:             * @exception SQLException if a database-access error occurs.
2402:             */
2403:            public boolean supportsCatalogsInProcedureCalls()
2404:                    throws SQLException {
2405:                NotImplemented();
2406:                return false;
2407:            }
2408:
2409:            /**
2410:             * Can a catalog name be used in a table definition statement?
2411:             *
2412:             * @return true if so
2413:             * @exception SQLException if a database-access error occurs.
2414:             */
2415:            public boolean supportsCatalogsInTableDefinitions()
2416:                    throws SQLException {
2417:                NotImplemented();
2418:                return false;
2419:            }
2420:
2421:            /**
2422:             * Is column aliasing supported?
2423:             *
2424:             * <P>If so, the SQL AS clause can be used to provide names for
2425:             * computed columns or to provide alias names for columns as
2426:             * required.
2427:             *
2428:             * A JDBC-Compliant driver always returns true.
2429:             *
2430:             * @return true if so
2431:             * @exception SQLException if a database-access error occurs.
2432:             */
2433:            public boolean supportsColumnAliasing() throws SQLException {
2434:                return true;
2435:            }
2436:
2437:            /**
2438:             * Is the CONVERT function between SQL types supported?
2439:             *
2440:             * @return true if so
2441:             * @exception SQLException if a database-access error occurs.
2442:             */
2443:            public boolean supportsConvert() throws SQLException {
2444:                return true;
2445:            }
2446:
2447:            /**
2448:             * Is CONVERT between the given SQL types supported?
2449:             *
2450:             * @param fromType the type to convert from
2451:             * @param toType the type to convert to
2452:             * @return true if so
2453:             * @exception SQLException if a database-access error occurs.
2454:             * @see Types
2455:             */
2456:            public boolean supportsConvert(int fromType, int toType)
2457:                    throws SQLException {
2458:                NotImplemented();
2459:                return false;
2460:            }
2461:
2462:            /**
2463:             * Is the ODBC Core SQL grammar supported?
2464:             *
2465:             * @return true if so
2466:             * @exception SQLException if a database-access error occurs.
2467:             */
2468:            public boolean supportsCoreSQLGrammar() throws SQLException {
2469:                NotImplemented();
2470:                return false;
2471:            }
2472:
2473:            /**
2474:             * Are correlated subqueries supported?
2475:             *
2476:             * A JDBC-Compliant driver always returns true.
2477:             *
2478:             * @return true if so
2479:             * @exception SQLException if a database-access error occurs.
2480:             */
2481:            public boolean supportsCorrelatedSubqueries() throws SQLException {
2482:                NotImplemented();
2483:                return false;
2484:            }
2485:
2486:            /**
2487:             * Are both data definition and data manipulation statements
2488:             * within a transaction supported?
2489:             *
2490:             * @return true if so
2491:             * @exception SQLException if a database-access error occurs.
2492:             */
2493:            public boolean supportsDataDefinitionAndDataManipulationTransactions()
2494:                    throws SQLException {
2495:                NotImplemented();
2496:                return false;
2497:            }
2498:
2499:            /**
2500:             * Are only data manipulation statements within a transaction
2501:             * supported?
2502:             *
2503:             * @return true if so
2504:             * @exception SQLException if a database-access error occurs.
2505:             */
2506:            public boolean supportsDataManipulationTransactionsOnly()
2507:                    throws SQLException {
2508:                NotImplemented();
2509:                return false;
2510:            }
2511:
2512:            /**
2513:             * If table correlation names are supported, are they restricted
2514:             * to be different from the names of the tables?
2515:             *
2516:             * @return true if so
2517:             * @exception SQLException if a database-access error occurs.
2518:             */
2519:            public boolean supportsDifferentTableCorrelationNames()
2520:                    throws SQLException {
2521:                NotImplemented();
2522:                return false;
2523:            }
2524:
2525:            /**
2526:             * Are expressions in "ORDER BY" lists supported?
2527:             *
2528:             * @return true if so
2529:             * @exception SQLException if a database-access error occurs.
2530:             */
2531:            public boolean supportsExpressionsInOrderBy() throws SQLException {
2532:                NotImplemented();
2533:                return false;
2534:            }
2535:
2536:            /**
2537:             * Is the ODBC Extended SQL grammar supported?
2538:             *
2539:             * @return true if so
2540:             * @exception SQLException if a database-access error occurs.
2541:             */
2542:            public boolean supportsExtendedSQLGrammar() throws SQLException {
2543:                NotImplemented();
2544:                return false;
2545:            }
2546:
2547:            /**
2548:             * Are full nested outer joins supported?
2549:             *
2550:             * @return true if so
2551:             * @exception SQLException if a database-access error occurs.
2552:             */
2553:            public boolean supportsFullOuterJoins() throws SQLException {
2554:                // XXX Need to check for Sybase
2555:
2556:                return true; // per "Programming ODBC for SQLServer" Appendix A
2557:            }
2558:
2559:            /**
2560:             * Is some form of "GROUP BY" clause supported?
2561:             *
2562:             * @return true if so
2563:             * @exception SQLException if a database-access error occurs.
2564:             */
2565:            public boolean supportsGroupBy() throws SQLException {
2566:                return true;
2567:            }
2568:
2569:            /**
2570:             * Can a "GROUP BY" clause add columns not in the SELECT
2571:             * provided it specifies all the columns in the SELECT?
2572:             *
2573:             * @return true if so
2574:             * @exception SQLException if a database-access error occurs.
2575:             */
2576:            public boolean supportsGroupByBeyondSelect() throws SQLException {
2577:                // XXX Need to check for Sybase
2578:
2579:                return true; // per "Programming ODBC for SQLServer" Appendix A
2580:            }
2581:
2582:            /**
2583:             * Can a "GROUP BY" clause use columns not in the SELECT?
2584:             *
2585:             * @return true if so
2586:             * @exception SQLException if a database-access error occurs.
2587:             */
2588:            public boolean supportsGroupByUnrelated() throws SQLException {
2589:                // XXX need to check this for Sybase
2590:                return true;
2591:            }
2592:
2593:            /**
2594:             * Is the SQL Integrity Enhancement Facility supported?
2595:             *
2596:             * @return true if so
2597:             * @exception SQLException if a database-access error occurs.
2598:             */
2599:            public boolean supportsIntegrityEnhancementFacility()
2600:                    throws SQLException {
2601:                NotImplemented();
2602:                return false;
2603:            }
2604:
2605:            /**
2606:             * Is the escape character in "LIKE" clauses supported?
2607:             *
2608:             * A JDBC-Compliant driver always returns true.
2609:             *
2610:             * @return true if so
2611:             * @exception SQLException if a database-access error occurs.
2612:             */
2613:            public boolean supportsLikeEscapeClause() throws SQLException {
2614:                // XXX Need to check for Sybase
2615:
2616:                return true; // per "Programming ODBC for SQLServer" Appendix A
2617:            }
2618:
2619:            /**
2620:             * Is there limited support for outer joins?  (This will be true
2621:             * if supportFullOuterJoins is true.)
2622:             *
2623:             * @return true if so
2624:             * @exception SQLException if a database-access error occurs.
2625:             */
2626:            public boolean supportsLimitedOuterJoins() throws SQLException {
2627:                return true;
2628:            }
2629:
2630:            /**
2631:             * Is the ODBC Minimum SQL grammar supported?
2632:             *
2633:             * All JDBC-Compliant drivers must return true.
2634:             *
2635:             * @return true if so
2636:             * @exception SQLException if a database-access error occurs.
2637:             */
2638:            public boolean supportsMinimumSQLGrammar() throws SQLException {
2639:                NotImplemented();
2640:                return false;
2641:            }
2642:
2643:            /**
2644:             * Does the database treat mixed case unquoted SQL identifiers as
2645:             * case sensitive and as a result store them in mixed case?
2646:             *
2647:             * A JDBC-Compliant driver will always return false.
2648:             *
2649:             * @return true if so
2650:             * @exception SQLException if a database-access error occurs.
2651:             */
2652:            public boolean supportsMixedCaseIdentifiers() throws SQLException {
2653:                NotImplemented();
2654:                return false;
2655:            }
2656:
2657:            /**
2658:             * Does the database treat mixed case quoted SQL identifiers as
2659:             * case sensitive and as a result store them in mixed case?
2660:             *
2661:             * A JDBC-Compliant driver will always return true.
2662:             *
2663:             * @return true if so
2664:             * @exception SQLException if a database-access error occurs.
2665:             */
2666:            public boolean supportsMixedCaseQuotedIdentifiers()
2667:                    throws SQLException {
2668:                NotImplemented();
2669:                return false;
2670:            }
2671:
2672:            /**
2673:             * Are multiple ResultSets from a single execute supported?
2674:             *
2675:             * @return true if so
2676:             * @exception SQLException if a database-access error occurs.
2677:             */
2678:            public boolean supportsMultipleResultSets() throws SQLException {
2679:                return true;
2680:            }
2681:
2682:            /**
2683:             * Can we have multiple transactions open at once (on different
2684:             * connections)?
2685:             *
2686:             * @return true if so
2687:             * @exception SQLException if a database-access error occurs.
2688:             */
2689:            public boolean supportsMultipleTransactions() throws SQLException {
2690:                return true;
2691:            }
2692:
2693:            /**
2694:             * Can columns be defined as non-nullable?
2695:             *
2696:             * A JDBC-Compliant driver always returns true.
2697:             *
2698:             * @return true if so
2699:             * @exception SQLException if a database-access error occurs.
2700:             */
2701:            public boolean supportsNonNullableColumns() throws SQLException {
2702:                return true;
2703:            }
2704:
2705:            /**
2706:             * Can cursors remain open across commits?
2707:             *
2708:             * @return true if cursors always remain open; false if they might not remain open
2709:             * @exception SQLException if a database-access error occurs.
2710:             */
2711:            public boolean supportsOpenCursorsAcrossCommit()
2712:                    throws SQLException {
2713:                NotImplemented();
2714:                return false;
2715:            }
2716:
2717:            /**
2718:             * Can cursors remain open across rollbacks?
2719:             *
2720:             * @return true if cursors always remain open; false if they might not remain open
2721:             * @exception SQLException if a database-access error occurs.
2722:             */
2723:            public boolean supportsOpenCursorsAcrossRollback()
2724:                    throws SQLException {
2725:                NotImplemented();
2726:                return false;
2727:            }
2728:
2729:            /**
2730:             * Can statements remain open across commits?
2731:             *
2732:             * @return true if statements always remain open; false if they might
2733:             * not remain open
2734:             * @exception SQLException if a database-access error occurs.
2735:             */
2736:            public boolean supportsOpenStatementsAcrossCommit()
2737:                    throws SQLException {
2738:                NotImplemented();
2739:                return false;
2740:            }
2741:
2742:            /**
2743:             * Can statements remain open across rollbacks?
2744:             *
2745:             * @return true if statements always remain open; false if they might
2746:             * not remain open
2747:             * @exception SQLException if a database-access error occurs.
2748:             */
2749:            public boolean supportsOpenStatementsAcrossRollback()
2750:                    throws SQLException {
2751:                NotImplemented();
2752:                return false;
2753:            }
2754:
2755:            /**
2756:             * Can an "ORDER BY" clause use columns not in the SELECT?
2757:             *
2758:             * @return true if so
2759:             * @exception SQLException if a database-access error occurs.
2760:             */
2761:            public boolean supportsOrderByUnrelated() throws SQLException {
2762:                // XXX need to verify for Sybase
2763:                return true;
2764:            }
2765:
2766:            /**
2767:             * Is some form of outer join supported?
2768:             *
2769:             * @return true if so
2770:             * @exception SQLException if a database-access error occurs.
2771:             */
2772:            public boolean supportsOuterJoins() throws SQLException {
2773:                return true;
2774:            }
2775:
2776:            /**
2777:             * Is positioned DELETE supported?
2778:             *
2779:             * @return true if so
2780:             * @exception SQLException if a database-access error occurs.
2781:             */
2782:            public boolean supportsPositionedDelete() throws SQLException {
2783:                // XXX Could we support it in the future?
2784:                return false;
2785:            }
2786:
2787:            /**
2788:             * Is positioned UPDATE supported?
2789:             *
2790:             * @return true if so
2791:             * @exception SQLException if a database-access error occurs.
2792:             */
2793:            public boolean supportsPositionedUpdate() throws SQLException {
2794:                // XXX Could we support it in the future?
2795:                return false;
2796:            }
2797:
2798:            /**
2799:             * Can a schema name be used in a data manipulation statement?
2800:             *
2801:             * @return true if so
2802:             * @exception SQLException if a database-access error occurs.
2803:             */
2804:            public boolean supportsSchemasInDataManipulation()
2805:                    throws SQLException {
2806:                NotImplemented();
2807:                return false;
2808:            }
2809:
2810:            /**
2811:             * Can a schema name be used in an index definition statement?
2812:             *
2813:             * @return true if so
2814:             * @exception SQLException if a database-access error occurs.
2815:             */
2816:            public boolean supportsSchemasInIndexDefinitions()
2817:                    throws SQLException {
2818:                NotImplemented();
2819:                return false;
2820:            }
2821:
2822:            /**
2823:             * Can a schema name be used in a privilege definition statement?
2824:             *
2825:             * @return true if so
2826:             * @exception SQLException if a database-access error occurs.
2827:             */
2828:            public boolean supportsSchemasInPrivilegeDefinitions()
2829:                    throws SQLException {
2830:                NotImplemented();
2831:                return false;
2832:            }
2833:
2834:            /**
2835:             * Can a schema name be used in a procedure call statement?
2836:             *
2837:             * @return true if so
2838:             * @exception SQLException if a database-access error occurs.
2839:             */
2840:            public boolean supportsSchemasInProcedureCalls()
2841:                    throws SQLException {
2842:                NotImplemented();
2843:                return false;
2844:            }
2845:
2846:            /**
2847:             * Can a schema name be used in a table definition statement?
2848:             *
2849:             * @return true if so
2850:             * @exception SQLException if a database-access error occurs.
2851:             */
2852:            public boolean supportsSchemasInTableDefinitions()
2853:                    throws SQLException {
2854:                NotImplemented();
2855:                return false;
2856:            }
2857:
2858:            /**
2859:             * Is SELECT for UPDATE supported?
2860:             *
2861:             * @return true if so
2862:             * @exception SQLException if a database-access error occurs.
2863:             */
2864:            public boolean supportsSelectForUpdate() throws SQLException {
2865:                NotImplemented();
2866:                return false;
2867:            }
2868:
2869:            /**
2870:             * Are stored procedure calls using the stored procedure escape
2871:             * syntax supported?
2872:             *
2873:             * @return true if so
2874:             * @exception SQLException if a database-access error occurs.
2875:             */
2876:            public boolean supportsStoredProcedures() throws SQLException {
2877:                NotImplemented();
2878:                return false;
2879:            }
2880:
2881:            /**
2882:             * Are subqueries in comparison expressions supported?
2883:             *
2884:             * A JDBC-Compliant driver always returns true.
2885:             *
2886:             * @return true if so
2887:             * @exception SQLException if a database-access error occurs.
2888:             */
2889:            public boolean supportsSubqueriesInComparisons()
2890:                    throws SQLException {
2891:                return true;
2892:            }
2893:
2894:            /**
2895:             * Are subqueries in 'exists' expressions supported?
2896:             *
2897:             * A JDBC-Compliant driver always returns true.
2898:             *
2899:             * @return true if so
2900:             * @exception SQLException if a database-access error occurs.
2901:             */
2902:            public boolean supportsSubqueriesInExists() throws SQLException {
2903:                return true;
2904:            }
2905:
2906:            /**
2907:             * Are subqueries in 'in' statements supported?
2908:             *
2909:             * A JDBC-Compliant driver always returns true.
2910:             *
2911:             * @return true if so
2912:             * @exception SQLException if a database-access error occurs.
2913:             */
2914:            public boolean supportsSubqueriesInIns() throws SQLException {
2915:                return true;
2916:            }
2917:
2918:            /**
2919:             * Are subqueries in quantified expressions supported?
2920:             *
2921:             * A JDBC-Compliant driver always returns true.
2922:             *
2923:             * @return true if so
2924:             * @exception SQLException if a database-access error occurs.
2925:             */
2926:            public boolean supportsSubqueriesInQuantifieds()
2927:                    throws SQLException {
2928:                NotImplemented();
2929:                return false;
2930:            }
2931:
2932:            /**
2933:             * Are table correlation names supported?
2934:             *
2935:             * A JDBC-Compliant driver always returns true.
2936:             *
2937:             * @return true if so
2938:             * @exception SQLException if a database-access error occurs.
2939:             */
2940:            public boolean supportsTableCorrelationNames() throws SQLException {
2941:                return true;
2942:            }
2943:
2944:            /**
2945:             * Does the database support the given transaction isolation level?
2946:             *
2947:             * @param level the values are defined in java.sql.Connection
2948:             * @return true if so
2949:             * @exception SQLException if a database-access error occurs.
2950:             * @see Connection
2951:             */
2952:            public boolean supportsTransactionIsolationLevel(int level)
2953:                    throws SQLException {
2954:                return true;
2955:            }
2956:
2957:            /**
2958:             * Are transactions supported? If not, commit is a noop and the
2959:             * isolation level is TRANSACTION_NONE.
2960:             *
2961:             * @return true if transactions are supported
2962:             * @exception SQLException if a database-access error occurs.
2963:             */
2964:            public boolean supportsTransactions() throws SQLException {
2965:                return true;
2966:            }
2967:
2968:            /**
2969:             * Is SQL UNION supported?
2970:             *
2971:             * @return true if so
2972:             * @exception SQLException if a database-access error occurs.
2973:             */
2974:            public boolean supportsUnion() throws SQLException {
2975:                return true;
2976:            }
2977:
2978:            /**
2979:             * Is SQL UNION ALL supported?
2980:             *
2981:             * @return true if so
2982:             * @exception SQLException if a database-access error occurs.
2983:             */
2984:            public boolean supportsUnionAll() throws SQLException {
2985:                return true;
2986:            }
2987:
2988:            /**
2989:             * Does the database use a file for each table?
2990:             *
2991:             * @return true if the database uses a local file for each table
2992:             * @exception SQLException if a database-access error occurs.
2993:             */
2994:            public boolean usesLocalFilePerTable() throws SQLException {
2995:                return false;
2996:            }
2997:
2998:            /**
2999:             * Does the database store tables in a local file?
3000:             *
3001:             * @return true if so
3002:             * @exception SQLException if a database-access error occurs.
3003:             */
3004:            public boolean usesLocalFiles() throws SQLException {
3005:                return false;
3006:            }
3007:
3008:            //--------------------------JDBC 2.0-----------------------------
3009:
3010:            /**
3011:             * JDBC 2.0
3012:             *
3013:             * Does the database support the given result set type?
3014:             *
3015:             * @param type defined in <code>java.sql.ResultSet</code>
3016:             * @return <code>true</code> if so; <code>false</code> otherwise 
3017:             * @exception SQLException if a database access error occurs
3018:             * @see Connection
3019:             */
3020:            public boolean supportsResultSetType(int type) throws SQLException {
3021:                NotImplemented();
3022:                return false;
3023:            }
3024:
3025:            /**
3026:             * JDBC 2.0
3027:             *
3028:             * Does the database support the concurrency type in combination
3029:             * with the given result set type?
3030:             *
3031:             * @param type defined in <code>java.sql.ResultSet</code>
3032:             * @param concurrency type defined in <code>java.sql.ResultSet</code>
3033:             * @return <code>true</code> if so; <code>false</code> otherwise 
3034:             * @exception SQLException if a database access error occurs
3035:             * @see Connection
3036:             */
3037:            public boolean supportsResultSetConcurrency(int type,
3038:                    int concurrency) throws SQLException {
3039:                NotImplemented();
3040:                return false;
3041:            }
3042:
3043:            /**
3044:             * JDBC 2.0
3045:             *
3046:             * Indicates whether a result set's own updates are visible.
3047:             *
3048:             * @param result set type, i.e. ResultSet.TYPE_XXX
3049:             * @return <code>true</code> if updates are visible for the result set type;
3050:             *        <code>false</code> otherwise
3051:             * @exception SQLException if a database access error occurs
3052:             */
3053:            public boolean ownUpdatesAreVisible(int type) throws SQLException {
3054:                NotImplemented();
3055:                return false;
3056:            }
3057:
3058:            /**
3059:             * JDBC 2.0
3060:             *
3061:             * Indicates whether a result set's own deletes are visible.
3062:             *
3063:             * @param result set type, i.e. ResultSet.TYPE_XXX
3064:             * @return <code>true</code> if deletes are visible for the result set type;
3065:             *        <code>false</code> otherwise
3066:             * @exception SQLException if a database access error occurs
3067:             */
3068:            public boolean ownDeletesAreVisible(int type) throws SQLException {
3069:                NotImplemented();
3070:                return false;
3071:            }
3072:
3073:            /**
3074:             * JDBC 2.0
3075:             *
3076:             * Indicates whether a result set's own inserts are visible.
3077:             *
3078:             * @param result set type, i.e. ResultSet.TYPE_XXX
3079:             * @return <code>true</code> if inserts are visible for the result set type;
3080:             *        <code>false</code> otherwise
3081:             * @exception SQLException if a database access error occurs
3082:             */
3083:            public boolean ownInsertsAreVisible(int type) throws SQLException {
3084:                NotImplemented();
3085:                return false;
3086:            }
3087:
3088:            /**
3089:             * JDBC 2.0
3090:             *
3091:             * Indicates whether updates made by others are visible.
3092:             *
3093:             * @param result set type, i.e. ResultSet.TYPE_XXX
3094:             * @return <code>true</code> if updates made by others
3095:             * are visible for the result set type;
3096:             *        <code>false</code> otherwise
3097:             * @exception SQLException if a database access error occurs
3098:             */
3099:            public boolean othersUpdatesAreVisible(int type)
3100:                    throws SQLException {
3101:                NotImplemented();
3102:                return false;
3103:            }
3104:
3105:            /**
3106:             * JDBC 2.0
3107:             *
3108:             * Indicates whether deletes made by others are visible.
3109:             *
3110:             * @param result set type, i.e. ResultSet.TYPE_XXX
3111:             * @return <code>true</code> if deletes made by others
3112:             * are visible for the result set type;
3113:             *        <code>false</code> otherwise
3114:             * @exception SQLException if a database access error occurs
3115:             */
3116:            public boolean othersDeletesAreVisible(int type)
3117:                    throws SQLException {
3118:                NotImplemented();
3119:                return false;
3120:            }
3121:
3122:            /**
3123:             * JDBC 2.0
3124:             *
3125:             * Indicates whether inserts made by others are visible.
3126:             *
3127:             * @param result set type, i.e. ResultSet.TYPE_XXX
3128:             * @return true if updates are visible for the result set type
3129:             * @return <code>true</code> if inserts made by others
3130:             * are visible for the result set type;
3131:             *        <code>false</code> otherwise
3132:             * @exception SQLException if a database access error occurs
3133:             */
3134:            public boolean othersInsertsAreVisible(int type)
3135:                    throws SQLException {
3136:                NotImplemented();
3137:                return false;
3138:            }
3139:
3140:            /**
3141:             * JDBC 2.0
3142:             *
3143:             * Indicates whether or not a visible row update can be detected by 
3144:             * calling the method <code>ResultSet.rowUpdated</code>.
3145:             *
3146:             * @param result set type, i.e. ResultSet.TYPE_XXX
3147:             * @return <code>true</code> if changes are detected by the result set type;
3148:             *         <code>false</code> otherwise
3149:             * @exception SQLException if a database access error occurs
3150:             */
3151:            public boolean updatesAreDetected(int type) throws SQLException {
3152:                NotImplemented();
3153:                return false;
3154:            }
3155:
3156:            /**
3157:             * JDBC 2.0
3158:             *
3159:             * Indicates whether or not a visible row delete can be detected by 
3160:             * calling ResultSet.rowDeleted().  If deletesAreDetected()
3161:             * returns false, then deleted rows are removed from the result set.
3162:             *
3163:             * @param result set type, i.e. ResultSet.TYPE_XXX
3164:             * @return true if changes are detected by the resultset type
3165:             * @exception SQLException if a database access error occurs
3166:             */
3167:            public boolean deletesAreDetected(int type) throws SQLException {
3168:                NotImplemented();
3169:                return false;
3170:            }
3171:
3172:            /**
3173:             * JDBC 2.0
3174:             *
3175:             * Indicates whether or not a visible row insert can be detected
3176:             * by calling ResultSet.rowInserted().
3177:             *
3178:             * @param result set type, i.e. ResultSet.TYPE_XXX
3179:             * @return true if changes are detected by the resultset type
3180:             * @exception SQLException if a database access error occurs
3181:             */
3182:            public boolean insertsAreDetected(int type) throws SQLException {
3183:                NotImplemented();
3184:                return false;
3185:            }
3186:
3187:            /**
3188:             * JDBC 2.0
3189:             *
3190:             * Indicates whether the driver supports batch updates.
3191:             * @return true if the driver supports batch updates; false otherwise
3192:             */
3193:            public boolean supportsBatchUpdates() throws SQLException {
3194:                NotImplemented();
3195:                return false;
3196:            }
3197:
3198:            /**
3199:             * JDBC 2.0
3200:             *
3201:             * Gets a description of the user-defined types defined in a particular
3202:             * schema.  Schema-specific UDTs may have type JAVA_OBJECT, STRUCT, 
3203:             * or DISTINCT.
3204:             *
3205:             * <P>Only types matching the catalog, schema, type name and type  
3206:             * criteria are returned.  They are ordered by DATA_TYPE, TYPE_SCHEM 
3207:             * and TYPE_NAME.  The type name parameter may be a fully-qualified 
3208:             * name.  In this case, the catalog and schemaPattern parameters are
3209:             * ignored.
3210:             *
3211:             * <P>Each type description has the following columns:
3212:             *  <OL>
3213:             *   <LI><B>TYPE_CAT</B> String => the type's catalog (may be null)
3214:             *   <LI><B>TYPE_SCHEM</B> String => type's schema (may be null)
3215:             *   <LI><B>TYPE_NAME</B> String => type name
3216:             *   <LI><B>CLASS_NAME</B> String => Java class name
3217:             *   <LI><B>DATA_TYPE</B> String => type value defined in java.sql.Types.  
3218:             *  One of JAVA_OBJECT, STRUCT, or DISTINCT
3219:             *   <LI><B>REMARKS</B> String => explanatory comment on the type
3220:             *  </OL>
3221:             *
3222:             * <P><B>Note:</B> If the driver does not support UDTs, an empty
3223:             * result set is returned.
3224:             *
3225:             * @param catalog a catalog name; "" retrieves those without a
3226:             * catalog; null means drop catalog name from the selection criteria
3227:             * @param schemaPattern a schema name pattern; "" retrieves those
3228:             * without a schema
3229:             * @param typeNamePattern a type name pattern; may be a fully-qualified
3230:             * name
3231:             * @param types a list of user-named types to include (JAVA_OBJECT, 
3232:             * STRUCT, or DISTINCT); null returns all types 
3233:             * @return ResultSet - each row is a type description
3234:             * @exception SQLException if a database access error occurs
3235:             */
3236:            public java.sql.ResultSet getUDTs(String catalog,
3237:                    String schemaPattern, String typeNamePattern, int[] types)
3238:                    throws SQLException {
3239:                NotImplemented();
3240:                return null;
3241:            }
3242:
3243:            /**
3244:             * JDBC 2.0
3245:             * Retrieves the connection that produced this metadata object.
3246:             *
3247:             * @return the connection that produced this metadata object
3248:             */
3249:            public java.sql.Connection getConnection() throws SQLException {
3250:                return connection;
3251:            }
3252:
3253:            public boolean supportsSavepoints() throws SQLException {
3254:                throw new UnsupportedOperationException(
3255:                        "ResultSet.updateArray(String,java.sql.Array) unsupported");
3256:            }
3257:
3258:            public boolean supportsNamedParameters() throws SQLException {
3259:                throw new UnsupportedOperationException(
3260:                        "ResultSet.updateArray(String,java.sql.Array) unsupported");
3261:            }
3262:
3263:            public boolean supportsMultipleOpenResults() throws SQLException {
3264:                throw new UnsupportedOperationException(
3265:                        "ResultSet.updateArray(String,java.sql.Array) unsupported");
3266:            }
3267:
3268:            public boolean supportsGetGeneratedKeys() throws SQLException {
3269:                throw new UnsupportedOperationException(
3270:                        "ResultSet.updateArray(String,java.sql.Array) unsupported");
3271:            }
3272:
3273:            public ResultSet getSuperTypes(java.lang.String str1,
3274:                    java.lang.String str2, java.lang.String str3)
3275:                    throws SQLException {
3276:                throw new UnsupportedOperationException(
3277:                        "ResultSet.updateArray(String,java.sql.Array) unsupported");
3278:            }
3279:
3280:            public ResultSet getSuperTables(java.lang.String str1,
3281:                    java.lang.String str2, java.lang.String str3)
3282:                    throws SQLException {
3283:                throw new UnsupportedOperationException(
3284:                        "ResultSet.updateArray(String,java.sql.Array) unsupported");
3285:            }
3286:
3287:            public ResultSet getAttributes(java.lang.String str1,
3288:                    java.lang.String str2, java.lang.String str3, String str4)
3289:                    throws SQLException {
3290:                throw new UnsupportedOperationException(
3291:                        "ResultSet.updateArray(String,java.sql.Array) unsupported");
3292:            }
3293:
3294:            public boolean supportsResultSetHoldability(int x)
3295:                    throws SQLException {
3296:                throw new UnsupportedOperationException(
3297:                        "ResultSet.updateArray(String,java.sql.Array) unsupported");
3298:            }
3299:
3300:            public boolean supportsResultSetHoldability() throws SQLException {
3301:                throw new UnsupportedOperationException(
3302:                        "ResultSet.updateArray(String,java.sql.Array) unsupported");
3303:            }
3304:
3305:            public int getResultSetHoldability() throws SQLException {
3306:                throw new UnsupportedOperationException(
3307:                        "ResultSet.updateArray(String,java.sql.Array) unsupported");
3308:            }
3309:
3310:            public int getDatabaseMajorVersion() throws SQLException {
3311:                throw new UnsupportedOperationException(
3312:                        "ResultSet.updateArray(String,java.sql.Array) unsupported");
3313:            }
3314:
3315:            public int getDatabaseMinorVersion() throws SQLException {
3316:                throw new UnsupportedOperationException(
3317:                        "ResultSet.updateArray(String,java.sql.Array) unsupported");
3318:            }
3319:
3320:            public int getJDBCMajorVersion() throws SQLException {
3321:                throw new UnsupportedOperationException(
3322:                        "ResultSet.updateArray(String,java.sql.Array) unsupported");
3323:            }
3324:
3325:            public int getJDBCMinorVersion() throws SQLException {
3326:                throw new UnsupportedOperationException(
3327:                        "ResultSet.updateArray(String,java.sql.Array) unsupported");
3328:            }
3329:
3330:            public int getSQLStateType() throws SQLException {
3331:                throw new UnsupportedOperationException(
3332:                        "ResultSet.updateArray(String,java.sql.Array) unsupported");
3333:            }
3334:
3335:            public boolean locatorsUpdateCopy() throws SQLException {
3336:                throw new UnsupportedOperationException(
3337:                        "ResultSet.updateArray(String,java.sql.Array) unsupported");
3338:            }
3339:
3340:            public boolean supportsStatementPooling() throws SQLException {
3341:                throw new UnsupportedOperationException(
3342:                        "ResultSet.updateArray(String,java.sql.Array) unsupported");
3343:            }
3344:
3345:            public static void main(String args[])
3346:                    throws java.lang.ClassNotFoundException,
3347:                    java.sql.SQLException, java.lang.IllegalAccessException,
3348:                    java.lang.InstantiationException {
3349:                String url = "jdbc:freetds://kap/jdbctest";
3350:                String user = "testuser";
3351:                String password = "password";
3352:
3353:                Class.forName("com.internetcds.jdbc.tds.Driver").newInstance();
3354:                java.sql.Connection cx = DriverManager.getConnection(url, user,
3355:                        password);
3356:                java.sql.DatabaseMetaData m = cx.getMetaData();
3357:                java.sql.ResultSet rs;
3358:
3359:                System.out.println("Connected to " + url + " as " + user);
3360:
3361:                System.out.println("url is " + m.getURL());
3362:                System.out.println("username is " + m.getUserName());
3363:
3364:                System.out.println(m.getDriverName());
3365:
3366:                System.out.println("Getting columns");
3367:                rs = m.getColumns(null, "%", "%", "%");
3368:                System.out.println("Got columns");
3369:                while (rs.next()) {
3370:                    System.out.println("TABLE_CAT:         "
3371:                            + rs.getString("TABLE_CAT") + "\n"
3372:                            + "TABLE_SCHEM:       "
3373:                            + rs.getString("TABLE_SCHEM") + "\n"
3374:                            + "TABLE_NAME:        "
3375:                            + rs.getString("TABLE_NAME") + "\n"
3376:                            + "COLUMN_NAME:       "
3377:                            + rs.getString("COLUMN_NAME") + "\n"
3378:                            + "DATA_TYPE:         " + rs.getString("DATA_TYPE")
3379:                            + "\n" + "TYPE_NAME:         "
3380:                            + rs.getString("TYPE_NAME") + "\n"
3381:                            + "COLUMN_SIZE:       "
3382:                            + rs.getString("COLUMN_SIZE") + "\n"
3383:                            + "BUFFER_LENGTH:     "
3384:                            + rs.getString("BUFFER_LENGTH") + "\n"
3385:                            + "DECIMAL_DIGITS:    "
3386:                            + rs.getString("DECIMAL_DIGITS") + "\n"
3387:                            + "NUM_PREC_RADIX:    "
3388:                            + rs.getString("NUM_PREC_RADIX") + "\n"
3389:                            + "NULLABLE:          " + rs.getString("NULLABLE")
3390:                            + "\n" + "REMARKS:           "
3391:                            + rs.getString("REMARKS") + "\n"
3392:                            + "COLUMN_DEF:        "
3393:                            + rs.getString("COLUMN_DEF") + "\n"
3394:                            + "SQL_DATA_TYPE:     "
3395:                            + rs.getString("SQL_DATA_TYPE") + "\n"
3396:                            + "SQL_DATETIME_SUB:  "
3397:                            + rs.getString("SQL_DATETIME_SUB") + "\n"
3398:                            + "CHAR_OCTET_LENGTH: "
3399:                            + rs.getString("CHAR_OCTET_LENGTH") + "\n"
3400:                            + "ORDINAL_POSITION:  "
3401:                            + rs.getString("ORDINAL_POSITION") + "\n"
3402:                            + "IS_NULLABLE:       "
3403:                            + rs.getString("IS_NULLABLE") + "\n" + "\n");
3404:                }
3405:                System.out.println("\n");
3406:                rs.close();
3407:
3408:                System.out.println("Catalog term- " + m.getCatalogTerm());
3409:                System.out.println("Catalog separator- "
3410:                        + m.getCatalogSeparator());
3411:                System.out.println("Catalog is "
3412:                        + (m.isCatalogAtStart() ? "" : "not ") + "at start");
3413:                System.out.println("Catalogs-");
3414:                rs = m.getCatalogs();
3415:                while (rs.next()) {
3416:                    System.out.println("  " + rs.getString(1));
3417:                }
3418:                System.out.println("\n");
3419:                rs.close();
3420:
3421:                System.out.println("Schema term- " + m.getSchemaTerm());
3422:                rs = m.getSchemas();
3423:                while (rs.next()) {
3424:                    System.out.println("  " + rs.getString(1));
3425:                }
3426:                System.out.println("\n");
3427:                rs.close();
3428:
3429:                System.out.println("Table types-");
3430:                rs = m.getTableTypes();
3431:                while (rs.next()) {
3432:                    System.out.println("  " + rs.getString(1));
3433:                }
3434:                System.out.println("\n");
3435:                rs.close();
3436:
3437:                System.out.println("Tables- ");
3438:                rs = m.getTables(null, "%", "%", null);
3439:                while (rs.next()) {
3440:                    System.out.println("  " + rs.getString(1) + "."
3441:                            + rs.getString(2) + "." + rs.getString(3) + "."
3442:                            + rs.getString(4) + "." + rs.getString(5) + "");
3443:                }
3444:                System.out.println("\n");
3445:                rs.close();
3446:
3447:                System.out.println("Tables for pubs- ");
3448:                String tables[] = { "SYSTEM TABLE", "VIEW" };
3449:                rs = m.getTables("pubs", "%", "%", tables);
3450:                while (rs.next()) {
3451:                    System.out.println("  " + rs.getString(1) + "."
3452:                            + rs.getString(2) + "." + rs.getString(3) + "."
3453:                            + rs.getString(4) + "." + rs.getString(5) + "");
3454:                }
3455:                System.out.println("\n");
3456:                rs.close();
3457:
3458:                System.out.println("Columns- ");
3459:                rs = m.getColumns(null, "%", "%", "%");
3460:                while (rs.next()) {
3461:                    System.out.println("TABLE_CAT:         "
3462:                            + rs.getString("TABLE_CAT") + "\n"
3463:                            + "TABLE_SCHEM:       "
3464:                            + rs.getString("TABLE_SCHEM") + "\n"
3465:                            + "TABLE_NAME:        "
3466:                            + rs.getString("TABLE_NAME") + "\n"
3467:                            + "COLUMN_NAME:       "
3468:                            + rs.getString("COLUMN_NAME") + "\n"
3469:                            + "DATA_TYPE:         " + rs.getString("DATA_TYPE")
3470:                            + "\n" + "TYPE_NAME:         "
3471:                            + rs.getString("TYPE_NAME") + "\n"
3472:                            + "COLUMN_SIZE:       "
3473:                            + rs.getString("COLUMN_SIZE") + "\n"
3474:                            + "BUFFER_LENGTH:     "
3475:                            + rs.getString("BUFFER_LENGTH") + "\n"
3476:                            + "DECIMAL_DIGITS:    "
3477:                            + rs.getString("DECIMAL_DIGITS") + "\n"
3478:                            + "NUM_PREC_RADIX:    "
3479:                            + rs.getString("NUM_PREC_RADIX") + "\n"
3480:                            + "NULLABLE:          " + rs.getString("NULLABLE")
3481:                            + "\n" + "REMARKS:           "
3482:                            + rs.getString("REMARKS") + "\n"
3483:                            + "COLUMN_DEF:        "
3484:                            + rs.getString("COLUMN_DEF") + "\n"
3485:                            + "SQL_DATA_TYPE:     "
3486:                            + rs.getString("SQL_DATA_TYPE") + "\n"
3487:                            + "SQL_DATETIME_SUB:  "
3488:                            + rs.getString("SQL_DATETIME_SUB") + "\n"
3489:                            + "CHAR_OCTET_LENGTH: "
3490:                            + rs.getString("CHAR_OCTET_LENGTH") + "\n"
3491:                            + "ORDINAL_POSITION:  "
3492:                            + rs.getString("ORDINAL_POSITION") + "\n"
3493:                            + "IS_NULLABLE:       "
3494:                            + rs.getString("IS_NULLABLE") + "\n" + "\n");
3495:                }
3496:                System.out.println("\n");
3497:                rs.close();
3498:
3499:                System.out.println("Done");
3500:            }
3501:
3502:            public boolean autoCommitFailureClosesAllResultSets()
3503:                    throws SQLException {
3504:                // TODO Auto-generated method stub
3505:                return false;
3506:            }
3507:
3508:            public ResultSet getClientInfoProperties() throws SQLException {
3509:                // TODO Auto-generated method stub
3510:                return null;
3511:            }
3512:
3513:            public ResultSet getFunctionColumns(String catalog,
3514:                    String schemaPattern, String functionNamePattern,
3515:                    String columnNamePattern) throws SQLException {
3516:                // TODO Auto-generated method stub
3517:                return null;
3518:            }
3519:
3520:            public ResultSet getFunctions(String catalog, String schemaPattern,
3521:                    String functionNamePattern) throws SQLException {
3522:                // TODO Auto-generated method stub
3523:                return null;
3524:            }
3525:
3526:            public RowIdLifetime getRowIdLifetime() throws SQLException {
3527:                // TODO Auto-generated method stub
3528:                return null;
3529:            }
3530:
3531:            public ResultSet getSchemas(String catalog, String schemaPattern)
3532:                    throws SQLException {
3533:                // TODO Auto-generated method stub
3534:                return null;
3535:            }
3536:
3537:            public boolean supportsStoredFunctionsUsingCallSyntax()
3538:                    throws SQLException {
3539:                // TODO Auto-generated method stub
3540:                return false;
3541:            }
3542:
3543:            public boolean isWrapperFor(Class<?> iface) throws SQLException {
3544:                // TODO Auto-generated method stub
3545:                return false;
3546:            }
3547:
3548:            public <T> T unwrap(Class<T> iface) throws SQLException {
3549:                // TODO Auto-generated method stub
3550:                return null;
3551:            }
3552:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.