Source Code Cross Referenced for CsvConnection.java in  » Database-JDBC-Connection-Pool » octopus » org » relique » jdbc » csv » 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 » org.relique.jdbc.csv 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /**
0002:            Copyright (C) 2002-2003  Together
0003:
0004:            This library is free software; you can redistribute it and/or
0005:            modify it under the terms of the GNU Lesser General Public
0006:            License as published by the Free Software Foundation; either
0007:            version 2.1 of the License, or (at your option) any later version.
0008:
0009:            This library is distributed in the hope that it will be useful,
0010:            but WITHOUT ANY WARRANTY; without even the implied warranty of
0011:            MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012:            Lesser General Public License for more details.
0013:
0014:            You should have received a copy of the GNU Lesser General Public
0015:            License along with this library; if not, write to the Free Software
0016:            Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
0017:
0018:         */package org.relique.jdbc.csv;
0019:
0020:        import java.io.File;
0021:        import java.sql.Array;
0022:        import java.sql.Blob;
0023:        import java.sql.CallableStatement;
0024:        import java.sql.Clob;
0025:        import java.sql.Connection;
0026:        import java.sql.DatabaseMetaData;
0027:        import java.sql.NClob;
0028:        import java.sql.PreparedStatement;
0029:        import java.sql.SQLClientInfoException;
0030:        import java.sql.SQLException;
0031:        import java.sql.SQLWarning;
0032:        import java.sql.SQLXML;
0033:        import java.sql.Savepoint;
0034:        import java.sql.Statement;
0035:        import java.sql.Struct;
0036:        import java.util.Enumeration;
0037:        import java.util.Map;
0038:        import java.util.Properties;
0039:        import java.util.StringTokenizer;
0040:        import java.util.Vector;
0041:
0042:        /**
0043:         * This class implements the Connection interface for the CsvJdbc driver.
0044:         *
0045:         * @author     Zoran Milakovic
0046:         */
0047:        public class CsvConnection implements  Connection {
0048:
0049:            /** Directory where the CSV files to use are located */
0050:            private String path;
0051:
0052:            /** File extension to use */
0053:            private String extension = CsvDriver.DEFAULT_EXTENSION;
0054:
0055:            /** Field separator to use */
0056:            private char separator = CsvDriver.DEFAULT_SEPARATOR;
0057:
0058:            /** Should headers be suppressed */
0059:            private boolean suppressHeaders = CsvDriver.DEFAULT_SUPPRESS;
0060:
0061:            /** If tree of directory should be created */
0062:            private boolean create = CsvDriver.DEFAULT_CREATE;
0063:
0064:            /** Max size of files*/
0065:            private long maxFileSize = CsvDriver.DEFAULT_FILE_MAXSIZE;
0066:
0067:            /** Escape for line brakes*/
0068:            private String lineBrakesEscape = CsvDriver.DEFAULT_LINE_BREAK_ESCAPE;
0069:
0070:            /** Escape for carriage return*/
0071:            private String carriageReturnEscape = CsvDriver.DEFAULT_CARRIAGE_RETURN_ESCAPE;
0072:
0073:            /** Use quotes or not when write to csv file*/
0074:            private boolean useQuotes = CsvDriver.DEFAULT_USE_QUOTES;
0075:
0076:            /** Use quotes escape or not when write to csv file*/
0077:            private boolean useQuotesEscape = CsvDriver.DEFAULT_USE_QUOTES_ESCAPE;
0078:
0079:            /** Collection of all created Statements */
0080:            private Vector statements = new Vector();
0081:
0082:            /** Charset that should be used to read the files */
0083:            private String charset = null;
0084:
0085:            /** Stores whether this Connection is closed or not */
0086:            private boolean closed;
0087:
0088:            /** If value is true csv file will be saved after each query.Default value is true in JDBC compliant drivers.*/
0089:            private boolean autoCommit = true;
0090:
0091:            /** Trim string */
0092:            private boolean trimString = CsvDriver.DEFAULT_TRIM;
0093:
0094:            /**
0095:             * Creates a new CsvConnection that takes the supplied path
0096:             * @param path directory where the CSV files are located
0097:             */
0098:            protected CsvConnection(String path) throws SQLException {
0099:                // validate argument(s)
0100:                if (path == null || path.length() == 0) {
0101:                    throw new IllegalArgumentException(
0102:                            "'path' argument may not be empty or null");
0103:                }
0104:                //check for properties
0105:                StringTokenizer st = new StringTokenizer(path, ";");
0106:                this .path = st.nextToken();
0107:                if (!this .path.endsWith(File.separator)) {
0108:                    this .path += File.separator;
0109:                }
0110:                while (st.hasMoreTokens()) {
0111:                    String next = st.nextToken();
0112:                    if (!this .setProperty(next)) {
0113:                        throw new IllegalArgumentException("unknown property "
0114:                                + next);
0115:                    }
0116:                }
0117:                File filePath = new File(this .path);
0118:
0119:                if (!this .create && !filePath.exists()) {
0120:                    throw new SQLException("Specified path '"
0121:                            + filePath.getAbsolutePath() + "' does not exist !");
0122:                }
0123:
0124:                if (this .create && !filePath.exists())
0125:                    filePath.mkdirs();
0126:
0127:            }
0128:
0129:            /**
0130:             * Creates a new CsvConnection that takes the supplied path and properties
0131:             * @param path directory where the CSV files are located
0132:             * @param info set of properties containing custom options
0133:             */
0134:            protected CsvConnection(String path, Properties info)
0135:                    throws SQLException {
0136:                this (path);
0137:                // check for properties
0138:                if (info != null) {
0139:                    // set the file extension to be used
0140:                    if (info.getProperty(CsvDriver.FILE_EXTENSION) != null) {
0141:                        extension = info.getProperty(CsvDriver.FILE_EXTENSION);
0142:                        if (!extension.startsWith("."))
0143:                            extension = "." + extension;
0144:                    }
0145:                    // set the separator character to be used
0146:                    if (info.getProperty(CsvDriver.SEPARATOR) != null) {
0147:                        separator = info.getProperty(CsvDriver.SEPARATOR)
0148:                                .charAt(0);
0149:                        //      patch for TAB separator
0150:                        if (info.getProperty(CsvDriver.SEPARATOR)
0151:                                .equalsIgnoreCase("TAB"))
0152:                            this .separator = '\t';
0153:                        //      patch for SEMICOLON separator
0154:                        if (info.getProperty(CsvDriver.SEPARATOR)
0155:                                .equalsIgnoreCase("SC"))
0156:                            this .separator = ';';
0157:                    }
0158:                    // set the header suppression flag
0159:                    if (info.getProperty(CsvDriver.SUPPRESS_HEADERS) != null) {
0160:                        suppressHeaders = Boolean.valueOf(
0161:                                info.getProperty(CsvDriver.SUPPRESS_HEADERS))
0162:                                .booleanValue();
0163:                    }
0164:                    // default charset
0165:                    if (info.getProperty(CsvDriver.CHARSET) != null) {
0166:                        charset = info.getProperty(CsvDriver.CHARSET);
0167:                    }
0168:                    // set create
0169:                    if (info.getProperty(CsvDriver.CREATE) != null) {
0170:                        create = Boolean.valueOf(
0171:                                info.getProperty(CsvDriver.SUPPRESS_HEADERS))
0172:                                .booleanValue();
0173:                    }
0174:                    // default max file size
0175:                    if (info.getProperty(CsvDriver.MAXFILESIZE) != null) {
0176:                        maxFileSize = Long.valueOf(
0177:                                info.getProperty(CsvDriver.MAXFILESIZE))
0178:                                .longValue();
0179:                    }
0180:                    // default escape for line break
0181:                    if (info.getProperty(CsvDriver.LINE_BREAK_ESCAPE) != null) {
0182:                        lineBrakesEscape = info
0183:                                .getProperty(CsvDriver.LINE_BREAK_ESCAPE);
0184:                    }
0185:                    // default escape for carriage return
0186:                    if (info.getProperty(CsvDriver.CARRIAGE_RETURN_ESCAPE) != null) {
0187:                        carriageReturnEscape = info
0188:                                .getProperty(CsvDriver.CARRIAGE_RETURN_ESCAPE);
0189:                    }
0190:                    // default use quotes
0191:                    if (info.getProperty(CsvDriver.USE_QUOTES) != null) {
0192:                        useQuotes = new Boolean(info
0193:                                .getProperty(CsvDriver.USE_QUOTES))
0194:                                .booleanValue();
0195:                    }
0196:                    //    default use quotes escape
0197:                    if (info.getProperty(CsvDriver.USE_QUOTES_ESCAPE) != null) {
0198:                        useQuotesEscape = new Boolean(info
0199:                                .getProperty(CsvDriver.USE_QUOTES_ESCAPE))
0200:                                .booleanValue();
0201:                    }
0202:                    //    default use trim string      
0203:                    if (info.getProperty(CsvDriver.TRIM_STRING) != null) {
0204:                        trimString = Boolean.valueOf(
0205:                                info.getProperty(CsvDriver.TRIM_STRING))
0206:                                .booleanValue();
0207:                    }
0208:                }
0209:            }
0210:
0211:            private boolean setProperty(String propString) {
0212:                boolean retVal = true;
0213:                StringTokenizer st = new StringTokenizer(propString, "=");
0214:                String name = st.nextToken();
0215:                String value = st.nextToken();
0216:                if (name.equals(CsvDriver.SEPARATOR)) {
0217:                    this .separator = value.charAt(0);
0218:                    //patch for TAB separator
0219:                    if (value.equalsIgnoreCase("TAB"))
0220:                        this .separator = '\t';
0221:                    //    patch for SEMICOLON separator
0222:                    if (value.equalsIgnoreCase("SC"))
0223:                        this .separator = ';';
0224:                } else if (name.equals(CsvDriver.FILE_EXTENSION)) {
0225:                    if (!value.startsWith("."))
0226:                        value = "." + value;
0227:                    this .extension = value;
0228:                } else if (name.equals(CsvDriver.SUPPRESS_HEADERS)) {
0229:                    this .suppressHeaders = Boolean.valueOf(value)
0230:                            .booleanValue();
0231:                } else if (name.equals(CsvDriver.CHARSET)) {
0232:                    this .charset = value;
0233:                } else if (name.equals(CsvDriver.CREATE)) {
0234:                    this .create = Boolean.valueOf(value).booleanValue();
0235:                } else if (name.equals(CsvDriver.MAXFILESIZE)) {
0236:                    this .maxFileSize = Long.valueOf(value).longValue();
0237:                } else if (name.equals(CsvDriver.LINE_BREAK_ESCAPE)) {
0238:                    this .lineBrakesEscape = value;
0239:                } else if (name.equals(CsvDriver.CARRIAGE_RETURN_ESCAPE)) {
0240:                    this .carriageReturnEscape = value;
0241:                } else if (name.equals(CsvDriver.USE_QUOTES)) {
0242:                    this .useQuotes = new Boolean(value).booleanValue();
0243:                } else if (name.equals(CsvDriver.USE_QUOTES_ESCAPE)) {
0244:                    this .useQuotesEscape = new Boolean(value).booleanValue();
0245:                } else if (name.equals(CsvDriver.TRIM_STRING)) {
0246:                    this .trimString = Boolean.valueOf(value).booleanValue();
0247:                } else
0248:                    retVal = false;
0249:                return retVal;
0250:            }
0251:
0252:            /**
0253:             * Creates a <code>Statement</code> object for sending
0254:             * SQL statements to the database.
0255:             * SQL statements without parameters are normally
0256:             * executed using <code>Statement</code> objects. If the same SQL statement
0257:             * is executed many times, it may be more efficient to use a
0258:             * <code>PreparedStatement</code> object.
0259:             * <P>
0260:             * Result sets created using the returned <code>Statement</code>
0261:             * object will by default be type <code>TYPE_FORWARD_ONLY</code>
0262:             * and have a concurrency level of <code>CONCUR_READ_ONLY</code>.
0263:             *
0264:             * @return a new default <code>Statement</code> object
0265:             * @exception SQLException if a database access error occurs
0266:             */
0267:            public Statement createStatement() throws SQLException {
0268:                CsvStatement statement = new CsvStatement(this );
0269:                statements.add(statement);
0270:                return statement;
0271:            }
0272:
0273:            /**
0274:             * Creates a <code>PreparedStatement</code> object for sending
0275:             * parameterized SQL statements to the database.
0276:             * <P>
0277:             * A SQL statement with or without IN parameters can be
0278:             * pre-compiled and stored in a <code>PreparedStatement</code> object. This
0279:             * object can then be used to efficiently execute this statement
0280:             * multiple times.
0281:             *
0282:             * <P><B>Note:</B> This method is optimized for handling
0283:             * parametric SQL statements that benefit from precompilation. If
0284:             * the driver supports precompilation,
0285:             * the method <code>prepareStatement</code> will send
0286:             * the statement to the database for precompilation. Some drivers
0287:             * may not support precompilation. In this case, the statement may
0288:             * not be sent to the database until the <code>PreparedStatement</code>
0289:             * object is executed.  This has no direct effect on users; however, it does
0290:             * affect which methods throw certain <code>SQLException</code> objects.
0291:             * <P>
0292:             * Result sets created using the returned <code>PreparedStatement</code>
0293:             * object will by default be type <code>TYPE_FORWARD_ONLY</code>
0294:             * and have a concurrency level of <code>CONCUR_READ_ONLY</code>.
0295:             *
0296:             * @param sql an SQL statement that may contain one or more '?' IN
0297:             * parameter placeholders
0298:             * @return a new default <code>PreparedStatement</code> object containing the
0299:             * pre-compiled SQL statement
0300:             * @exception SQLException if a database access error occurs
0301:             */
0302:            public PreparedStatement prepareStatement(String sql)
0303:                    throws SQLException {
0304:                int index = sql.indexOf("?");
0305:                while (index != -1) {
0306:                    sql = sql.substring(0, index)
0307:                            + CsvPreparedStatement.PREPARE_SEPARATOR
0308:                            + sql.substring(index + 1);
0309:                    index = sql.indexOf("?");
0310:                }
0311:
0312:                CsvPreparedStatement statement = new CsvPreparedStatement(this ,
0313:                        sql);
0314:                statements.add(statement);
0315:                return statement;
0316:            }
0317:
0318:            /**
0319:             * Creates a <code>CallableStatement</code> object for calling
0320:             * database stored procedures.
0321:             * The <code>CallableStatement</code> object provides
0322:             * methods for setting up its IN and OUT parameters, and
0323:             * methods for executing the call to a stored procedure.
0324:             *
0325:             * <P><B>Note:</B> This method is optimized for handling stored
0326:             * procedure call statements. Some drivers may send the call
0327:             * statement to the database when the method <code>prepareCall</code>
0328:             * is done; others
0329:             * may wait until the <code>CallableStatement</code> object
0330:             * is executed. This has no
0331:             * direct effect on users; however, it does affect which method
0332:             * throws certain SQLExceptions.
0333:             * <P>
0334:             * Result sets created using the returned <code>CallableStatement</code>
0335:             * object will by default be type <code>TYPE_FORWARD_ONLY</code>
0336:             * and have a concurrency level of <code>CONCUR_READ_ONLY</code>.
0337:             *
0338:             * @param sql an SQL statement that may contain one or more '?'
0339:             * parameter placeholders. Typically this  statement is a JDBC
0340:             * function call escape string.
0341:             * @return a new default <code>CallableStatement</code> object containing the
0342:             * pre-compiled SQL statement
0343:             * @exception SQLException if a database access error occurs
0344:             */
0345:            public CallableStatement prepareCall(String sql)
0346:                    throws SQLException {
0347:                throw new UnsupportedOperationException(
0348:                        "Connection.prepareCall(String) unsupported");
0349:            }
0350:
0351:            /**
0352:             * Converts the given SQL statement into the system's native SQL grammar.
0353:             * A driver may convert the JDBC SQL grammar into its system's
0354:             * native SQL grammar prior to sending it. This method returns the
0355:             * native form of the statement that the driver would have sent.
0356:             *
0357:             * @param sql an SQL statement that may contain one or more '?'
0358:             * parameter placeholders
0359:             * @return the native form of this statement
0360:             * @exception SQLException if a database access error occurs
0361:             */
0362:            public String nativeSQL(String sql) throws SQLException {
0363:                throw new UnsupportedOperationException(
0364:                        "Connection.nativeSQL(String) unsupported");
0365:            }
0366:
0367:            /**
0368:             * Sets this connection's auto-commit mode to the given state.
0369:             * If a connection is in auto-commit mode, then all its SQL
0370:             * statements will be executed and committed as individual
0371:             * transactions.  Otherwise, its SQL statements are grouped into
0372:             * transactions that are terminated by a call to either
0373:             * the method <code>commit</code> or the method <code>rollback</code>.
0374:             * By default, new connections are in auto-commit
0375:             * mode.
0376:             * <P>
0377:             * The commit occurs when the statement completes or the next
0378:             * execute occurs, whichever comes first. In the case of
0379:             * statements returning a <code>ResultSet</code> object,
0380:             * the statement completes when the last row of the
0381:             * <code>ResultSet</code> object has been retrieved or the
0382:             * <code>ResultSet</code> object has been closed. In advanced cases, a
0383:             * single statement may return multiple results as well as output
0384:             * parameter values. In these cases, the commit occurs when all results and
0385:             * output parameter values have been retrieved.
0386:             * <P>
0387:             * <B>NOTE:</B>  If this method is called during a transaction, the
0388:             * transaction is committed.
0389:             *
0390:             * @param autoCommit <code>true</code> to enable auto-commit mode;
0391:             *         <code>false</code> to disable it
0392:             * @exception SQLException if a database access error occurs
0393:             * @see #getAutoCommit
0394:             */
0395:            public void setAutoCommit(boolean autoCommit) throws SQLException {
0396:                this .autoCommit = autoCommit;
0397:                //        throw new UnsupportedOperationException(
0398:                //                "Connection.setAutoCommit(boolean) unsupported");
0399:            }
0400:
0401:            /**
0402:             * Retrieves the current auto-commit mode for this <code>Connection</code>
0403:             * object.
0404:             *
0405:             * @return the current state of this <code>Connection</code> object's
0406:             *         auto-commit mode
0407:             * @exception SQLException if a database access error occurs
0408:             * @see #setAutoCommit
0409:             */
0410:            public boolean getAutoCommit() throws SQLException {
0411:                //        throw new UnsupportedOperationException(
0412:                //                "Connection.getAutoCommit() unsupported");
0413:                //    return true;
0414:                return this .autoCommit;
0415:            }
0416:
0417:            /**
0418:             * Makes all changes made since the previous
0419:             * commit/rollback permanent and releases any database locks
0420:             * currently held by this <code>Connection</code> object.
0421:             * This method should be
0422:             * used only when auto-commit mode has been disabled.
0423:             *
0424:             * @exception SQLException if a database access error occurs or this
0425:             *            <code>Connection</code> object is in auto-commit mode
0426:             * @see #setAutoCommit
0427:             */
0428:            public void commit() throws SQLException {
0429:                for (int i = 0; i < this .statements.size(); i++) {
0430:                    ((Statement) statements.get(i)).close();
0431:                }
0432:            }
0433:
0434:            /**
0435:             * Undoes all changes made in the current transaction
0436:             * and releases any database locks currently held
0437:             * by this <code>Connection</code> object. This method should be
0438:             * used only when auto-commit mode has been disabled.
0439:             *
0440:             * @exception SQLException if a database access error occurs or this
0441:             *            <code>Connection</code> object is in auto-commit mode
0442:             * @see #setAutoCommit
0443:             */
0444:            public void rollback() throws SQLException {
0445:                throw new UnsupportedOperationException(
0446:                        "Connection.rollback() unsupported");
0447:            }
0448:
0449:            /**
0450:             * Releases this <code>Connection</code> object's database and JDBC
0451:             * resources immediately instead of waiting for them to be automatically
0452:             * released.
0453:             * <P>
0454:             * Calling the method <code>close</code> on a <code>Connection</code>
0455:             * object that is already closed is a no-op.
0456:             * <P>
0457:             * <B>Note:</B> A <code>Connection</code> object is automatically
0458:             * closed when it is garbage collected. Certain fatal errors also
0459:             * close a <code>Connection</code> object.
0460:             *
0461:             * @exception SQLException if a database access error occurs
0462:             */
0463:            public void close() throws SQLException {
0464:                // close all created statements
0465:                for (Enumeration i = statements.elements(); i.hasMoreElements();) {
0466:                    Statement statement = (Statement) i.nextElement();
0467:                    statement.close();
0468:                }
0469:                // set this Connection as closed
0470:                closed = true;
0471:            }
0472:
0473:            /**
0474:             * Retrieves whether this <code>Connection</code> object has been
0475:             * closed.  A connection is closed if the method <code>close</code>
0476:             * has been called on it or if certain fatal errors have occurred.
0477:             * This method is guaranteed to return <code>true</code> only when
0478:             * it is called after the method <code>Connection.close</code> has
0479:             * been called.
0480:             * <P>
0481:             * This method generally cannot be called to determine whether a
0482:             * connection to a database is valid or invalid.  A typical client
0483:             * can determine that a connection is invalid by catching any
0484:             * exceptions that might be thrown when an operation is attempted.
0485:             *
0486:             * @return <code>true</code> if this <code>Connection</code> object
0487:             *         is closed; <code>false</code> if it is still open
0488:             * @exception SQLException if a database access error occurs
0489:             */
0490:            public boolean isClosed() throws SQLException {
0491:                return closed;
0492:            }
0493:
0494:            /**
0495:             * Retrieves a <code>DatabaseMetaData</code> object that contains
0496:             * metadata about the database to which this
0497:             * <code>Connection</code> object represents a connection.
0498:             * The metadata includes information about the database's
0499:             * tables, its supported SQL grammar, its stored
0500:             * procedures, the capabilities of this connection, and so on.
0501:             *
0502:             * @return a <code>DatabaseMetaData</code> object for this
0503:             *         <code>Connection</code> object
0504:             * @exception SQLException if a database access error occurs
0505:             */
0506:            public DatabaseMetaData getMetaData() throws SQLException {
0507:                throw new UnsupportedOperationException(
0508:                        "Connection.getMetaData() unsupported");
0509:            }
0510:
0511:            /**
0512:             * Puts this connection in read-only mode as a hint to the driver to enable
0513:             * database optimizations.
0514:             *
0515:             * <P><B>Note:</B> This method cannot be called during a transaction.
0516:             *
0517:             * @param readOnly <code>true</code> enables read-only mode;
0518:             *        <code>false</code> disables it
0519:             * @exception SQLException if a database access error occurs or this
0520:             *            method is called during a transaction
0521:             */
0522:            public void setReadOnly(boolean readOnly) throws SQLException {
0523:                throw new UnsupportedOperationException(
0524:                        "Connection.setReadOnly(boolean) unsupported");
0525:            }
0526:
0527:            /**
0528:             * Retrieves whether this <code>Connection</code>
0529:             * object is in read-only mode.
0530:             *
0531:             * @return <code>true</code> if this <code>Connection</code> object
0532:             *         is read-only; <code>false</code> otherwise
0533:             * @exception SQLException if a database access error occurs
0534:             */
0535:            public boolean isReadOnly() throws SQLException {
0536:                return true;
0537:            }
0538:
0539:            /**
0540:             * Sets the given catalog name in order to select
0541:             * a subspace of this <code>Connection</code> object's database
0542:             * in which to work.
0543:             * <P>
0544:             * If the driver does not support catalogs, it will
0545:             * silently ignore this request.
0546:             *
0547:             * @param catalog the name of a catalog (subspace in this
0548:             *        <code>Connection</code> object's database) in which to work
0549:             * @exception SQLException if a database access error occurs
0550:             * @see #getCatalog
0551:             */
0552:            public void setCatalog(String catalog) throws SQLException {
0553:                // silently ignore this request
0554:            }
0555:
0556:            /**
0557:             * Retrieves this <code>Connection</code> object's current catalog name.
0558:             *
0559:             * @return the current catalog name or <code>null</code> if there is none
0560:             * @exception SQLException if a database access error occurs
0561:             * @see #setCatalog
0562:             */
0563:            public String getCatalog() throws SQLException {
0564:                return null;
0565:            }
0566:
0567:            /**
0568:             * Attempts to change the transaction isolation level for this
0569:             * <code>Connection</code> object to the one given.
0570:             * The constants defined in the interface <code>Connection</code>
0571:             * are the possible transaction isolation levels.
0572:             * <P>
0573:             * <B>Note:</B> If this method is called during a transaction, the result
0574:             * is implementation-defined.
0575:             *
0576:             * @param level one of the following <code>Connection</code> constants:
0577:             *        <code>Connection.TRANSACTION_READ_UNCOMMITTED</code>,
0578:             *        <code>Connection.TRANSACTION_READ_COMMITTED</code>,
0579:             *        <code>Connection.TRANSACTION_REPEATABLE_READ</code>, or
0580:             *        <code>Connection.TRANSACTION_SERIALIZABLE</code>.
0581:             *        (Note that <code>Connection.TRANSACTION_NONE</code> cannot be used
0582:             *        because it specifies that transactions are not supported.)
0583:             * @exception SQLException if a database access error occurs
0584:             *            or the given parameter is not one of the <code>Connection</code>
0585:             *            constants
0586:             * @see DatabaseMetaData#supportsTransactionIsolationLevel
0587:             * @see #getTransactionIsolation
0588:             */
0589:            public void setTransactionIsolation(int level) throws SQLException {
0590:                throw new UnsupportedOperationException(
0591:                        "Connection.setTransactionIsolation(int) unsupported");
0592:            }
0593:
0594:            /**
0595:             * Retrieves this <code>Connection</code> object's current
0596:             * transaction isolation level.
0597:             *
0598:             * @return the current transaction isolation level, which will be one
0599:             *         of the following constants:
0600:             *        <code>Connection.TRANSACTION_READ_UNCOMMITTED</code>,
0601:             *        <code>Connection.TRANSACTION_READ_COMMITTED</code>,
0602:             *        <code>Connection.TRANSACTION_REPEATABLE_READ</code>,
0603:             *        <code>Connection.TRANSACTION_SERIALIZABLE</code>, or
0604:             *        <code>Connection.TRANSACTION_NONE</code>.
0605:             * @exception SQLException if a database access error occurs
0606:             * @see #setTransactionIsolation
0607:             */
0608:            public int getTransactionIsolation() throws SQLException {
0609:                return Connection.TRANSACTION_NONE;
0610:            }
0611:
0612:            /**
0613:             * Retrieves the first warning reported by calls on this
0614:             * <code>Connection</code> object.  If there is more than one
0615:             * warning, subsequent warnings will be chained to the first one
0616:             * and can be retrieved by calling the method
0617:             * <code>SQLWarning.getNextWarning</code> on the warning
0618:             * that was retrieved previously.
0619:             * <P>
0620:             * This method may not be
0621:             * called on a closed connection; doing so will cause an
0622:             * <code>SQLException</code> to be thrown.
0623:             *
0624:             * <P><B>Note:</B> Subsequent warnings will be chained to this
0625:             * SQLWarning.
0626:             *
0627:             * @return the first <code>SQLWarning</code> object or <code>null</code>
0628:             *         if there are none
0629:             * @exception SQLException if a database access error occurs or
0630:             *            this method is called on a closed connection
0631:             * @see SQLWarning
0632:             */
0633:            public SQLWarning getWarnings() throws SQLException {
0634:                throw new UnsupportedOperationException(
0635:                        "Connection.getWarnings() unsupported");
0636:            }
0637:
0638:            /**
0639:             * Clears all warnings reported for this <code>Connection</code> object.
0640:             * After a call to this method, the method <code>getWarnings</code>
0641:             * returns <code>null</code> until a new warning is
0642:             * reported for this <code>Connection</code> object.
0643:             *
0644:             * @exception SQLException if a database access error occurs
0645:             */
0646:            public void clearWarnings() throws SQLException {
0647:                throw new UnsupportedOperationException(
0648:                        "Connection.getWarnings() unsupported");
0649:            }
0650:
0651:            //--------------------------JDBC 2.0-----------------------------
0652:
0653:            /**
0654:             * Creates a <code>Statement</code> object that will generate
0655:             * <code>ResultSet</code> objects with the given type and concurrency.
0656:             * This method is the same as the <code>createStatement</code> method
0657:             * above, but it allows the default result set
0658:             * type and concurrency to be overridden.
0659:             *
0660:             * @param resultSetType a result set type; one of
0661:             *        <code>ResultSet.TYPE_FORWARD_ONLY</code>,
0662:             *        <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or
0663:             *        <code>ResultSet.TYPE_SCROLL_SENSITIVE</code>
0664:             * @param resultSetConcurrency a concurrency type; one of
0665:             *        <code>ResultSet.CONCUR_READ_ONLY</code> or
0666:             *        <code>ResultSet.CONCUR_UPDATABLE</code>
0667:             * @return a new <code>Statement</code> object that will generate
0668:             *         <code>ResultSet</code> objects with the given type and
0669:             *         concurrency
0670:             * @exception SQLException if a database access error occurs
0671:             *         or the given parameters are not <code>ResultSet</code>
0672:             *         constants indicating type and concurrency
0673:             */
0674:            public Statement createStatement(int resultSetType,
0675:                    int resultSetConcurrency) throws SQLException {
0676:                throw new UnsupportedOperationException(
0677:                        "Connection.createStatement(int, int) unsupported");
0678:            }
0679:
0680:            /**
0681:             * Creates a <code>PreparedStatement</code> object that will generate
0682:             * <code>ResultSet</code> objects with the given type and concurrency.
0683:             * This method is the same as the <code>prepareStatement</code> method
0684:             * above, but it allows the default result set
0685:             * type and concurrency to be overridden.
0686:             *
0687:             * @param sql a <code>String</code> object that is the SQL statement to
0688:             *            be sent to the database; may contain one or more ? IN
0689:             *            parameters
0690:             * @param resultSetType a result set type; one of
0691:             *         <code>ResultSet.TYPE_FORWARD_ONLY</code>,
0692:             *         <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or
0693:             *         <code>ResultSet.TYPE_SCROLL_SENSITIVE</code>
0694:             * @param resultSetConcurrency a concurrency type; one of
0695:             *         <code>ResultSet.CONCUR_READ_ONLY</code> or
0696:             *         <code>ResultSet.CONCUR_UPDATABLE</code>
0697:             * @return a new PreparedStatement object containing the
0698:             * pre-compiled SQL statement that will produce <code>ResultSet</code>
0699:             * objects with the given type and concurrency
0700:             * @exception SQLException if a database access error occurs
0701:             *         or the given parameters are not <code>ResultSet</code>
0702:             *         constants indicating type and concurrency
0703:             */
0704:            public PreparedStatement prepareStatement(String sql,
0705:                    int resultSetType, int resultSetConcurrency)
0706:                    throws SQLException {
0707:                throw new UnsupportedOperationException(
0708:                        "Connection.prepareStatement(String, int, int) unsupported");
0709:            }
0710:
0711:            /**
0712:             * Creates a <code>CallableStatement</code> object that will generate
0713:             * <code>ResultSet</code> objects with the given type and concurrency.
0714:             * This method is the same as the <code>prepareCall</code> method
0715:             * above, but it allows the default result set
0716:             * type and concurrency to be overridden.
0717:             *
0718:             * @param sql a <code>String</code> object that is the SQL statement to
0719:             *            be sent to the database; may contain on or more ? parameters
0720:             * @param resultSetType a result set type; one of
0721:             *         <code>ResultSet.TYPE_FORWARD_ONLY</code>,
0722:             *         <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or
0723:             *         <code>ResultSet.TYPE_SCROLL_SENSITIVE</code>
0724:             * @param resultSetConcurrency a concurrency type; one of
0725:             *         <code>ResultSet.CONCUR_READ_ONLY</code> or
0726:             *         <code>ResultSet.CONCUR_UPDATABLE</code>
0727:             * @return a new <code>CallableStatement</code> object containing the
0728:             * pre-compiled SQL statement that will produce <code>ResultSet</code>
0729:             * objects with the given type and concurrency
0730:             * @exception SQLException if a database access error occurs
0731:             *         or the given parameters are not <code>ResultSet</code>
0732:             *         constants indicating type and concurrency
0733:             */
0734:            public CallableStatement prepareCall(String sql, int resultSetType,
0735:                    int resultSetConcurrency) throws SQLException {
0736:                throw new UnsupportedOperationException(
0737:                        "Connection.prepareCall(String, int, int) unsupported");
0738:            }
0739:
0740:            /**
0741:             * Retrieves the <code>Map</code> object associated with this
0742:             * <code>Connection</code> object.
0743:             * Unless the application has added an entry, the type map returned
0744:             * will be empty.
0745:             *
0746:             * @return the <code>java.util.Map</code> object associated
0747:             *         with this <code>Connection</code> object
0748:             * @exception SQLException if a database access error occurs
0749:             * @see #setTypeMap
0750:             */
0751:            public Map getTypeMap() throws SQLException {
0752:                throw new UnsupportedOperationException(
0753:                        "Connection.getTypeMap() unsupported");
0754:            }
0755:
0756:            /**
0757:             * Installs the given <code>TypeMap</code> object as the type map for
0758:             * this <code>Connection</code> object.  The type map will be used for the
0759:             * custom mapping of SQL structured types and distinct types.
0760:             *
0761:             * @param map the <code>java.util.Map</code> object to install
0762:             *        as the replacement for this <code>Connection</code>
0763:             *        object's default type map
0764:             * @exception SQLException if a database access error occurs or
0765:             *        the given parameter is not a <code>java.util.Map</code>
0766:             *        object
0767:             * @see #getTypeMap
0768:             */
0769:            //  public void setTypeMap(Map map) throws SQLException {
0770:            //    throw new UnsupportedOperationException(
0771:            //        "Connection.setTypeMap(Map) unsupported");
0772:            //  }
0773:            //--------------------------JDBC 3.0-----------------------------
0774:            /**
0775:             * Changes the holdability of <code>ResultSet</code> objects
0776:             * created using this <code>Connection</code> object to the given
0777:             * holdability.
0778:             *
0779:             * @param holdability a <code>ResultSet</code> holdability constant; one of
0780:             *        <code>ResultSet.HOLD_CURSORS_OVER_COMMIT</code> or
0781:             *        <code>ResultSet.CLOSE_CURSORS_AT_COMMIT</code>
0782:             * @throws SQLException if a database access occurs, the given parameter
0783:             *         is not a <code>ResultSet</code> constant indicating holdability,
0784:             *         or the given holdability is not supported
0785:             * @since 1.4
0786:             * @see #getHoldability
0787:             * @see java.sql.ResultSet
0788:             */
0789:            public void setHoldability(int holdability) throws SQLException {
0790:                throw new UnsupportedOperationException(
0791:                        "Connection.setHoldability(int) unsupported");
0792:            }
0793:
0794:            /**
0795:             * Retrieves the current holdability of ResultSet objects created
0796:             * using this Connection object.
0797:             *
0798:             * @return the holdability, one of <code>ResultSet.HOLD_CURSORS_OVER_COMMIT</code> or
0799:             * <code>ResultSet.CLOSE_CURSORS_AT_COMMIT</code>
0800:             * @throws SQLException if a database access occurs
0801:             * @since 1.4
0802:             * @see #setHoldability
0803:             * @see java.sql.ResultSet
0804:             */
0805:            public int getHoldability() throws SQLException {
0806:                throw new UnsupportedOperationException(
0807:                        "Connection.getHoldability() unsupported");
0808:            }
0809:
0810:            //     Removed since this only builds under JDK 1.4
0811:            public Savepoint setSavepoint() throws SQLException {
0812:                throw new UnsupportedOperationException(
0813:                        "Connection.setSavepoint() unsupported");
0814:            }
0815:
0816:            public Savepoint setSavepoint(String name) throws SQLException {
0817:                throw new UnsupportedOperationException(
0818:                        "Connection.setSavepoint(String) unsupported");
0819:            }
0820:
0821:            public void rollback(Savepoint savepoint) throws SQLException {
0822:                throw new UnsupportedOperationException(
0823:                        "Connection.rollback(Savepoint) unsupported");
0824:            }
0825:
0826:            public void releaseSavepoint(Savepoint savepoint)
0827:                    throws SQLException {
0828:                throw new UnsupportedOperationException(
0829:                        "Connection.releaseSavepoint(Savepoint) unsupported");
0830:            }
0831:
0832:            public Statement createStatement(int resultSetType,
0833:                    int resultSetConcurrency, int resultSetHoldability)
0834:                    throws SQLException {
0835:                throw new UnsupportedOperationException(
0836:                        "Connection.createStatement(int,int,int) unsupported");
0837:            }
0838:
0839:            public PreparedStatement prepareStatement(String sql,
0840:                    int resultSetType, int resultSetConcurrency,
0841:                    int resultSetHoldability) throws SQLException {
0842:                throw new UnsupportedOperationException(
0843:                        "Connection.prepareStatement(String,int,int,int) unsupported");
0844:            }
0845:
0846:            public CallableStatement prepareCall(String sql, int resultSetType,
0847:                    int resultSetConcurrency, int resultSetHoldability)
0848:                    throws SQLException {
0849:                throw new UnsupportedOperationException(
0850:                        "Connection.prepareCall(String,int,int,int) unsupported");
0851:            }
0852:
0853:            public PreparedStatement prepareStatement(String sql,
0854:                    int autoGeneratedKeys) throws SQLException {
0855:                throw new UnsupportedOperationException(
0856:                        "Connection.prepareStatement(String,int) unsupported");
0857:            }
0858:
0859:            public PreparedStatement prepareStatement(String sql,
0860:                    int[] columnIndexes) throws SQLException {
0861:                throw new UnsupportedOperationException(
0862:                        "Connection.prepareStatement(String,int[]) unsupported");
0863:            }
0864:
0865:            public PreparedStatement prepareStatement(String sql,
0866:                    String[] columnNames) throws SQLException {
0867:                throw new UnsupportedOperationException(
0868:                        "Connection.prepareStatement(String,String[]) unsupported");
0869:            }
0870:
0871:            //---------------------------------------------------------------------
0872:            // Properties
0873:            //---------------------------------------------------------------------
0874:
0875:            /**
0876:             * Accessor method for the path property
0877:             * @return current value for the path property
0878:             */
0879:            protected String getPath() {
0880:                return path;
0881:            }
0882:
0883:            /**
0884:             * Accessor method for the extension property
0885:             * @return current value for the extension property
0886:             */
0887:            protected String getExtension() {
0888:                return extension;
0889:            }
0890:
0891:            /**
0892:             * Accessor method for the separator property
0893:             * @return current value for the separator property
0894:             */
0895:            protected char getSeperator() {
0896:                return separator;
0897:            }
0898:
0899:            /**
0900:             * Accessor method for the suppressHeaders property
0901:             * @return current value for the suppressHeaders property
0902:             */
0903:            protected boolean isSuppressHeaders() {
0904:                return suppressHeaders;
0905:            }
0906:
0907:            /**
0908:             * Accessor method for the trimString property
0909:             * @return current value for the trimString property
0910:             */
0911:            protected boolean isTrimString() {
0912:                return trimString;
0913:            }
0914:
0915:            /**
0916:             * Accessor method for the charset property
0917:             * @return current value for the suppressHeaders property
0918:             */
0919:            protected String getCharset() {
0920:                return charset;
0921:            }
0922:
0923:            protected long getMaxFileSize() {
0924:                return maxFileSize;
0925:            }
0926:
0927:            protected String getLineBreakEscape() {
0928:                return lineBrakesEscape;
0929:            }
0930:
0931:            protected String getCarriageReturnEscape() {
0932:                return carriageReturnEscape;
0933:            }
0934:
0935:            protected boolean getUseQuotes() {
0936:                return this .useQuotes;
0937:            }
0938:
0939:            protected boolean getUseQuotesEscape() {
0940:                return this .useQuotesEscape;
0941:            }
0942:
0943:            public Array createArrayOf(String typeName, Object[] elements)
0944:                    throws SQLException {
0945:                // TODO Auto-generated method stub
0946:                return null;
0947:            }
0948:
0949:            public Blob createBlob() throws SQLException {
0950:                // TODO Auto-generated method stub
0951:                return null;
0952:            }
0953:
0954:            public Clob createClob() throws SQLException {
0955:                // TODO Auto-generated method stub
0956:                return null;
0957:            }
0958:
0959:            public NClob createNClob() throws SQLException {
0960:                // TODO Auto-generated method stub
0961:                return null;
0962:            }
0963:
0964:            public SQLXML createSQLXML() throws SQLException {
0965:                // TODO Auto-generated method stub
0966:                return null;
0967:            }
0968:
0969:            public Struct createStruct(String typeName, Object[] attributes)
0970:                    throws SQLException {
0971:                // TODO Auto-generated method stub
0972:                return null;
0973:            }
0974:
0975:            public Properties getClientInfo() throws SQLException {
0976:                // TODO Auto-generated method stub
0977:                return null;
0978:            }
0979:
0980:            public String getClientInfo(String name) throws SQLException {
0981:                // TODO Auto-generated method stub
0982:                return null;
0983:            }
0984:
0985:            public boolean isValid(int timeout) throws SQLException {
0986:                // TODO Auto-generated method stub
0987:                return false;
0988:            }
0989:
0990:            public void setClientInfo(Properties properties)
0991:                    throws SQLClientInfoException {
0992:                // TODO Auto-generated method stub
0993:                throw new UnsupportedOperationException(
0994:                        "Connection.setClientInfo(Properties) unsupported");
0995:
0996:            }
0997:
0998:            public void setClientInfo(String name, String value)
0999:                    throws SQLClientInfoException {
1000:                // TODO Auto-generated method stub
1001:                throw new UnsupportedOperationException(
1002:                        "Connection.setClientInfo(String,String) unsupported");
1003:
1004:            }
1005:
1006:            public void setTypeMap(Map<String, Class<?>> arg0)
1007:                    throws SQLException {
1008:                // TODO Auto-generated method stub
1009:                throw new UnsupportedOperationException(
1010:                        "Connection.setTypeMap(Map<String, Class<?>>) unsupported");
1011:
1012:            }
1013:
1014:            public boolean isWrapperFor(Class<?> iface) throws SQLException {
1015:                // TODO Auto-generated method stub
1016:                return false;
1017:            }
1018:
1019:            public <T> T unwrap(Class<T> iface) throws SQLException {
1020:                // TODO Auto-generated method stub
1021:                return null;
1022:            }
1023:
1024:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.