KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > relique > jdbc > csv > CsvConnection


1 /**
2     Copyright (C) 2002-2003 Together
3
4     This library is free software; you can redistribute it and/or
5     modify it under the terms of the GNU Lesser General Public
6     License as published by the Free Software Foundation; either
7     version 2.1 of the License, or (at your option) any later version.
8
9     This library is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12     Lesser General Public License for more details.
13
14     You should have received a copy of the GNU Lesser General Public
15     License along with this library; if not, write to the Free Software
16     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
18 */

19
20 package org.relique.jdbc.csv;
21
22 import java.io.File JavaDoc;
23 import java.sql.CallableStatement JavaDoc;
24 import java.sql.Connection JavaDoc;
25 import java.sql.DatabaseMetaData JavaDoc;
26 import java.sql.PreparedStatement JavaDoc;
27 import java.sql.SQLException JavaDoc;
28 import java.sql.SQLWarning JavaDoc;
29 import java.sql.Savepoint JavaDoc;
30 import java.sql.Statement JavaDoc;
31 import java.util.Enumeration JavaDoc;
32 import java.util.Map JavaDoc;
33 import java.util.Properties JavaDoc;
34 import java.util.StringTokenizer JavaDoc;
35 import java.util.Vector JavaDoc;
36
37 /**
38  * This class implements the Connection interface for the CsvJdbc driver.
39  *
40  * @author Zoran Milakovic
41  */

42 public class CsvConnection
43     implements Connection JavaDoc {
44
45   /** Directory where the CSV files to use are located */
46   private String JavaDoc path;
47
48   /** File extension to use */
49   private String JavaDoc extension = CsvDriver.DEFAULT_EXTENSION;
50
51   /** Field separator to use */
52   private char separator = CsvDriver.DEFAULT_SEPARATOR;
53
54   /** Should headers be suppressed */
55   private boolean suppressHeaders = CsvDriver.DEFAULT_SUPPRESS;
56
57   /** If tree of directory should be created */
58   private boolean create = CsvDriver.DEFAULT_CREATE;
59
60   /** Max size of files*/
61   private long maxFileSize = CsvDriver.DEFAULT_FILE_MAXSIZE;
62
63   /** Escape for line brakes*/
64   private String JavaDoc lineBrakesEscape = CsvDriver.DEFAULT_LINE_BREAK_ESCAPE;
65
66   /** Escape for carriage return*/
67   private String JavaDoc carriageReturnEscape = CsvDriver.DEFAULT_CARRIAGE_RETURN_ESCAPE;
68
69   /** Use quotes or not when write to csv file*/
70   private boolean useQuotes = CsvDriver.DEFAULT_USE_QUOTES;
71   
72   /** Use quotes escape or not when write to csv file*/
73   private boolean useQuotesEscape = CsvDriver.DEFAULT_USE_QUOTES_ESCAPE;
74
75   /** Collection of all created Statements */
76   private Vector JavaDoc statements = new Vector JavaDoc();
77
78   /** Charset that should be used to read the files */
79   private String JavaDoc charset = null;
80
81   /** Stores whether this Connection is closed or not */
82   private boolean closed;
83
84   /** If value is true csv file will be saved after each query.Default value is true in JDBC compliant drivers.*/
85   private boolean autoCommit=true;
86
87
88   /**
89    * Creates a new CsvConnection that takes the supplied path
90    * @param path directory where the CSV files are located
91    */

92   protected CsvConnection(String JavaDoc path) throws SQLException JavaDoc {
93     // validate argument(s)
94
if (path == null || path.length() == 0) {
95       throw new IllegalArgumentException JavaDoc(
96           "'path' argument may not be empty or null");
97     }
98     //check for properties
99
StringTokenizer JavaDoc st = new StringTokenizer JavaDoc(path, ";");
100     this.path = st.nextToken();
101     if (!this.path.endsWith(File.separator)) {
102       this.path += File.separator;
103     }
104     while (st.hasMoreTokens()) {
105       String JavaDoc next = st.nextToken();
106       if (!this.setProperty(next)) {
107         throw new IllegalArgumentException JavaDoc(
108             "unknown property " + next);
109       }
110     }
111     File JavaDoc filePath = new File JavaDoc(this.path);
112
113     if (!this.create && !filePath.exists()) {
114       throw new SQLException JavaDoc(
115           "Specified path '" + filePath.getAbsolutePath() +
116           "' does not exist !");
117     }
118
119     if (this.create && !filePath.exists())
120       filePath.mkdirs();
121
122   }
123
124   /**
125    * Creates a new CsvConnection that takes the supplied path and properties
126    * @param path directory where the CSV files are located
127    * @param info set of properties containing custom options
128    */

129   protected CsvConnection(String JavaDoc path, Properties JavaDoc info) throws SQLException JavaDoc {
130     this(path);
131     // check for properties
132
if (info != null) {
133       // set the file extension to be used
134
if (info.getProperty(CsvDriver.FILE_EXTENSION) != null) {
135         extension = info.getProperty(CsvDriver.FILE_EXTENSION);
136         if (!extension.startsWith("."))
137           extension = "." + extension;
138       }
139       // set the separator character to be used
140
if (info.getProperty(CsvDriver.SEPARATOR) != null) {
141         separator = info.getProperty(CsvDriver.SEPARATOR).charAt(0);
142 // patch for TAB separator
143
if(info.getProperty(CsvDriver.SEPARATOR).equalsIgnoreCase("TAB"))
144             this.separator = '\t';
145 // patch for SEMICOLON separator
146
if(info.getProperty(CsvDriver.SEPARATOR).equalsIgnoreCase("SC"))
147             this.separator = ';';
148       }
149       // set the header suppression flag
150
if (info.getProperty(CsvDriver.SUPPRESS_HEADERS) != null) {
151         suppressHeaders = Boolean.valueOf(info.getProperty(
152             CsvDriver.SUPPRESS_HEADERS)).booleanValue();
153       }
154       // default charset
155
if (info.getProperty(CsvDriver.CHARSET) != null) {
156         charset = info.getProperty(CsvDriver.CHARSET);
157       }
158       // set create
159
if (info.getProperty(CsvDriver.CREATE) != null) {
160         create = Boolean.valueOf(info.getProperty(
161             CsvDriver.SUPPRESS_HEADERS)).booleanValue();
162       }
163       // default max file size
164
if (info.getProperty(CsvDriver.MAXFILESIZE) != null) {
165         maxFileSize = Long.valueOf(info.getProperty(CsvDriver.MAXFILESIZE)).
166             longValue();
167       }
168       // default escape for line break
169
if (info.getProperty(CsvDriver.LINE_BREAK_ESCAPE) != null) {
170         lineBrakesEscape = info.getProperty(CsvDriver.LINE_BREAK_ESCAPE);
171       }
172       // default escape for carriage return
173
if (info.getProperty(CsvDriver.CARRIAGE_RETURN_ESCAPE) != null) {
174         carriageReturnEscape = info.getProperty(CsvDriver.CARRIAGE_RETURN_ESCAPE);
175       }
176       // default use quotes
177
if (info.getProperty(CsvDriver.USE_QUOTES) != null) {
178         useQuotes = new Boolean JavaDoc(info.getProperty(CsvDriver.USE_QUOTES)).booleanValue();
179       }
180 // default use quotes escape
181
if (info.getProperty(CsvDriver.USE_QUOTES_ESCAPE) != null) {
182         useQuotesEscape = new Boolean JavaDoc(info.getProperty(CsvDriver.USE_QUOTES_ESCAPE)).booleanValue();
183       }
184     }
185   }
186
187   private boolean setProperty(String JavaDoc propString) {
188     boolean retVal = true;
189     StringTokenizer JavaDoc st = new StringTokenizer JavaDoc(propString, "=");
190     String JavaDoc name = st.nextToken();
191     String JavaDoc value = st.nextToken();
192     if (name.equals(CsvDriver.SEPARATOR)) {
193       this.separator = value.charAt(0);
194       //patch for TAB separator
195
if(value.equalsIgnoreCase("TAB"))
196           this.separator = '\t';
197 // patch for SEMICOLON separator
198
if(value.equalsIgnoreCase("SC"))
199           this.separator = ';';
200     }
201     else if (name.equals(CsvDriver.FILE_EXTENSION)) {
202       if (!value.startsWith("."))
203         value = "." + value;
204       this.extension = value;
205     }
206     else if (name.equals(CsvDriver.SUPPRESS_HEADERS)) {
207       this.suppressHeaders = Boolean.valueOf(value).booleanValue();
208     }
209     else if (name.equals(CsvDriver.CHARSET)) {
210       this.charset = value;
211     }
212     else if (name.equals(CsvDriver.CREATE)) {
213       this.create = Boolean.valueOf(value).booleanValue();
214     }
215     else if (name.equals(CsvDriver.MAXFILESIZE)) {
216       this.maxFileSize = Long.valueOf(value).longValue();
217     }
218     else if (name.equals(CsvDriver.LINE_BREAK_ESCAPE)) {
219       this.lineBrakesEscape = value;
220     }
221     else if (name.equals(CsvDriver.CARRIAGE_RETURN_ESCAPE)) {
222       this.carriageReturnEscape = value;
223     }
224     else if (name.equals(CsvDriver.USE_QUOTES)) {
225       this.useQuotes = new Boolean JavaDoc( value ).booleanValue();
226     }
227     else if (name.equals(CsvDriver.USE_QUOTES_ESCAPE)) {
228         this.useQuotesEscape = new Boolean JavaDoc( value ).booleanValue();
229     }
230     else
231       retVal = false;
232     return retVal;
233   }
234
235   /**
236    * Creates a <code>Statement</code> object for sending
237    * SQL statements to the database.
238    * SQL statements without parameters are normally
239    * executed using <code>Statement</code> objects. If the same SQL statement
240    * is executed many times, it may be more efficient to use a
241    * <code>PreparedStatement</code> object.
242    * <P>
243    * Result sets created using the returned <code>Statement</code>
244    * object will by default be type <code>TYPE_FORWARD_ONLY</code>
245    * and have a concurrency level of <code>CONCUR_READ_ONLY</code>.
246    *
247    * @return a new default <code>Statement</code> object
248    * @exception SQLException if a database access error occurs
249    */

250   public Statement JavaDoc createStatement() throws SQLException JavaDoc {
251     CsvStatement statement = new CsvStatement(this);
252     statements.add(statement);
253     return statement;
254   }
255
256   /**
257    * Creates a <code>PreparedStatement</code> object for sending
258    * parameterized SQL statements to the database.
259    * <P>
260    * A SQL statement with or without IN parameters can be
261    * pre-compiled and stored in a <code>PreparedStatement</code> object. This
262    * object can then be used to efficiently execute this statement
263    * multiple times.
264    *
265    * <P><B>Note:</B> This method is optimized for handling
266    * parametric SQL statements that benefit from precompilation. If
267    * the driver supports precompilation,
268    * the method <code>prepareStatement</code> will send
269    * the statement to the database for precompilation. Some drivers
270    * may not support precompilation. In this case, the statement may
271    * not be sent to the database until the <code>PreparedStatement</code>
272    * object is executed. This has no direct effect on users; however, it does
273    * affect which methods throw certain <code>SQLException</code> objects.
274    * <P>
275    * Result sets created using the returned <code>PreparedStatement</code>
276    * object will by default be type <code>TYPE_FORWARD_ONLY</code>
277    * and have a concurrency level of <code>CONCUR_READ_ONLY</code>.
278    *
279    * @param sql an SQL statement that may contain one or more '?' IN
280    * parameter placeholders
281    * @return a new default <code>PreparedStatement</code> object containing the
282    * pre-compiled SQL statement
283    * @exception SQLException if a database access error occurs
284    */

285   public PreparedStatement JavaDoc prepareStatement(String JavaDoc sql) throws SQLException JavaDoc {
286     int index = sql.indexOf("?");
287     while (index != -1) {
288       sql = sql.substring(0, index) + CsvPreparedStatement.PREPARE_SEPARATOR + sql.substring(index + 1);
289       index = sql.indexOf("?");
290     }
291
292     CsvPreparedStatement statement = new CsvPreparedStatement(this, sql);
293     statements.add(statement);
294     return statement;
295   }
296
297   /**
298    * Creates a <code>CallableStatement</code> object for calling
299    * database stored procedures.
300    * The <code>CallableStatement</code> object provides
301    * methods for setting up its IN and OUT parameters, and
302    * methods for executing the call to a stored procedure.
303    *
304    * <P><B>Note:</B> This method is optimized for handling stored
305    * procedure call statements. Some drivers may send the call
306    * statement to the database when the method <code>prepareCall</code>
307    * is done; others
308    * may wait until the <code>CallableStatement</code> object
309    * is executed. This has no
310    * direct effect on users; however, it does affect which method
311    * throws certain SQLExceptions.
312    * <P>
313    * Result sets created using the returned <code>CallableStatement</code>
314    * object will by default be type <code>TYPE_FORWARD_ONLY</code>
315    * and have a concurrency level of <code>CONCUR_READ_ONLY</code>.
316    *
317    * @param sql an SQL statement that may contain one or more '?'
318    * parameter placeholders. Typically this statement is a JDBC
319    * function call escape string.
320    * @return a new default <code>CallableStatement</code> object containing the
321    * pre-compiled SQL statement
322    * @exception SQLException if a database access error occurs
323    */

324   public CallableStatement JavaDoc prepareCall(String JavaDoc sql) throws SQLException JavaDoc {
325     throw new UnsupportedOperationException JavaDoc(
326         "Connection.prepareCall(String) unsupported");
327   }
328
329   /**
330    * Converts the given SQL statement into the system's native SQL grammar.
331    * A driver may convert the JDBC SQL grammar into its system's
332    * native SQL grammar prior to sending it. This method returns the
333    * native form of the statement that the driver would have sent.
334    *
335    * @param sql an SQL statement that may contain one or more '?'
336    * parameter placeholders
337    * @return the native form of this statement
338    * @exception SQLException if a database access error occurs
339    */

340   public String JavaDoc nativeSQL(String JavaDoc sql) throws SQLException JavaDoc {
341     throw new UnsupportedOperationException JavaDoc(
342         "Connection.nativeSQL(String) unsupported");
343   }
344
345   /**
346    * Sets this connection's auto-commit mode to the given state.
347    * If a connection is in auto-commit mode, then all its SQL
348    * statements will be executed and committed as individual
349    * transactions. Otherwise, its SQL statements are grouped into
350    * transactions that are terminated by a call to either
351    * the method <code>commit</code> or the method <code>rollback</code>.
352    * By default, new connections are in auto-commit
353    * mode.
354    * <P>
355    * The commit occurs when the statement completes or the next
356    * execute occurs, whichever comes first. In the case of
357    * statements returning a <code>ResultSet</code> object,
358    * the statement completes when the last row of the
359    * <code>ResultSet</code> object has been retrieved or the
360    * <code>ResultSet</code> object has been closed. In advanced cases, a
361    * single statement may return multiple results as well as output
362    * parameter values. In these cases, the commit occurs when all results and
363    * output parameter values have been retrieved.
364    * <P>
365    * <B>NOTE:</B> If this method is called during a transaction, the
366    * transaction is committed.
367    *
368    * @param autoCommit <code>true</code> to enable auto-commit mode;
369    * <code>false</code> to disable it
370    * @exception SQLException if a database access error occurs
371    * @see #getAutoCommit
372    */

373   public void setAutoCommit(boolean autoCommit) throws SQLException JavaDoc {
374     this.autoCommit = autoCommit;
375 // throw new UnsupportedOperationException(
376
// "Connection.setAutoCommit(boolean) unsupported");
377
}
378
379   /**
380    * Retrieves the current auto-commit mode for this <code>Connection</code>
381    * object.
382    *
383    * @return the current state of this <code>Connection</code> object's
384    * auto-commit mode
385    * @exception SQLException if a database access error occurs
386    * @see #setAutoCommit
387    */

388   public boolean getAutoCommit() throws SQLException JavaDoc {
389 // throw new UnsupportedOperationException(
390
// "Connection.getAutoCommit() unsupported");
391
// return true;
392
return this.autoCommit;
393   }
394
395   /**
396    * Makes all changes made since the previous
397    * commit/rollback permanent and releases any database locks
398    * currently held by this <code>Connection</code> object.
399    * This method should be
400    * used only when auto-commit mode has been disabled.
401    *
402    * @exception SQLException if a database access error occurs or this
403    * <code>Connection</code> object is in auto-commit mode
404    * @see #setAutoCommit
405    */

406   public void commit() throws SQLException JavaDoc {
407     for (int i = 0; i < this.statements.size(); i++) {
408       ( (Statement JavaDoc) statements.get(i)).close();
409     }
410   }
411
412   /**
413    * Undoes all changes made in the current transaction
414    * and releases any database locks currently held
415    * by this <code>Connection</code> object. This method should be
416    * used only when auto-commit mode has been disabled.
417    *
418    * @exception SQLException if a database access error occurs or this
419    * <code>Connection</code> object is in auto-commit mode
420    * @see #setAutoCommit
421    */

422   public void rollback() throws SQLException JavaDoc {
423     throw new UnsupportedOperationException JavaDoc(
424         "Connection.rollback() unsupported");
425   }
426
427   /**
428    * Releases this <code>Connection</code> object's database and JDBC
429    * resources immediately instead of waiting for them to be automatically
430    * released.
431    * <P>
432    * Calling the method <code>close</code> on a <code>Connection</code>
433    * object that is already closed is a no-op.
434    * <P>
435    * <B>Note:</B> A <code>Connection</code> object is automatically
436    * closed when it is garbage collected. Certain fatal errors also
437    * close a <code>Connection</code> object.
438    *
439    * @exception SQLException if a database access error occurs
440    */

441   public void close() throws SQLException JavaDoc {
442     // close all created statements
443
for (Enumeration JavaDoc i = statements.elements(); i.hasMoreElements(); ) {
444       Statement JavaDoc statement = (Statement JavaDoc) i.nextElement();
445       statement.close();
446     }
447     // set this Connection as closed
448
closed = true;
449   }
450
451   /**
452    * Retrieves whether this <code>Connection</code> object has been
453    * closed. A connection is closed if the method <code>close</code>
454    * has been called on it or if certain fatal errors have occurred.
455    * This method is guaranteed to return <code>true</code> only when
456    * it is called after the method <code>Connection.close</code> has
457    * been called.
458    * <P>
459    * This method generally cannot be called to determine whether a
460    * connection to a database is valid or invalid. A typical client
461    * can determine that a connection is invalid by catching any
462    * exceptions that might be thrown when an operation is attempted.
463    *
464    * @return <code>true</code> if this <code>Connection</code> object
465    * is closed; <code>false</code> if it is still open
466    * @exception SQLException if a database access error occurs
467    */

468   public boolean isClosed() throws SQLException JavaDoc {
469     return closed;
470   }
471
472   /**
473    * Retrieves a <code>DatabaseMetaData</code> object that contains
474    * metadata about the database to which this
475    * <code>Connection</code> object represents a connection.
476    * The metadata includes information about the database's
477    * tables, its supported SQL grammar, its stored
478    * procedures, the capabilities of this connection, and so on.
479    *
480    * @return a <code>DatabaseMetaData</code> object for this
481    * <code>Connection</code> object
482    * @exception SQLException if a database access error occurs
483    */

484   public DatabaseMetaData JavaDoc getMetaData() throws SQLException JavaDoc {
485     throw new UnsupportedOperationException JavaDoc(
486         "Connection.getMetaData() unsupported");
487   }
488
489   /**
490    * Puts this connection in read-only mode as a hint to the driver to enable
491    * database optimizations.
492    *
493    * <P><B>Note:</B> This method cannot be called during a transaction.
494    *
495    * @param readOnly <code>true</code> enables read-only mode;
496    * <code>false</code> disables it
497    * @exception SQLException if a database access error occurs or this
498    * method is called during a transaction
499    */

500   public void setReadOnly(boolean readOnly) throws SQLException JavaDoc {
501     throw new UnsupportedOperationException JavaDoc(
502         "Connection.setReadOnly(boolean) unsupported");
503   }
504
505   /**
506    * Retrieves whether this <code>Connection</code>
507    * object is in read-only mode.
508    *
509    * @return <code>true</code> if this <code>Connection</code> object
510    * is read-only; <code>false</code> otherwise
511    * @exception SQLException if a database access error occurs
512    */

513   public boolean isReadOnly() throws SQLException JavaDoc {
514     return true;
515   }
516
517   /**
518    * Sets the given catalog name in order to select
519    * a subspace of this <code>Connection</code> object's database
520    * in which to work.
521    * <P>
522    * If the driver does not support catalogs, it will
523    * silently ignore this request.
524    *
525    * @param catalog the name of a catalog (subspace in this
526    * <code>Connection</code> object's database) in which to work
527    * @exception SQLException if a database access error occurs
528    * @see #getCatalog
529    */

530   public void setCatalog(String JavaDoc catalog) throws SQLException JavaDoc {
531     // silently ignore this request
532
}
533
534   /**
535    * Retrieves this <code>Connection</code> object's current catalog name.
536    *
537    * @return the current catalog name or <code>null</code> if there is none
538    * @exception SQLException if a database access error occurs
539    * @see #setCatalog
540    */

541   public String JavaDoc getCatalog() throws SQLException JavaDoc {
542     return null;
543   }
544
545   /**
546    * Attempts to change the transaction isolation level for this
547    * <code>Connection</code> object to the one given.
548    * The constants defined in the interface <code>Connection</code>
549    * are the possible transaction isolation levels.
550    * <P>
551    * <B>Note:</B> If this method is called during a transaction, the result
552    * is implementation-defined.
553    *
554    * @param level one of the following <code>Connection</code> constants:
555    * <code>Connection.TRANSACTION_READ_UNCOMMITTED</code>,
556    * <code>Connection.TRANSACTION_READ_COMMITTED</code>,
557    * <code>Connection.TRANSACTION_REPEATABLE_READ</code>, or
558    * <code>Connection.TRANSACTION_SERIALIZABLE</code>.
559    * (Note that <code>Connection.TRANSACTION_NONE</code> cannot be used
560    * because it specifies that transactions are not supported.)
561    * @exception SQLException if a database access error occurs
562        * or the given parameter is not one of the <code>Connection</code>
563    * constants
564    * @see DatabaseMetaData#supportsTransactionIsolationLevel
565    * @see #getTransactionIsolation
566    */

567   public void setTransactionIsolation(int level) throws SQLException JavaDoc {
568     throw new UnsupportedOperationException JavaDoc(
569         "Connection.setTransactionIsolation(int) unsupported");
570   }
571
572   /**
573    * Retrieves this <code>Connection</code> object's current
574    * transaction isolation level.
575    *
576    * @return the current transaction isolation level, which will be one
577    * of the following constants:
578    * <code>Connection.TRANSACTION_READ_UNCOMMITTED</code>,
579    * <code>Connection.TRANSACTION_READ_COMMITTED</code>,
580    * <code>Connection.TRANSACTION_REPEATABLE_READ</code>,
581    * <code>Connection.TRANSACTION_SERIALIZABLE</code>, or
582    * <code>Connection.TRANSACTION_NONE</code>.
583    * @exception SQLException if a database access error occurs
584    * @see #setTransactionIsolation
585    */

586   public int getTransactionIsolation() throws SQLException JavaDoc {
587     return Connection.TRANSACTION_NONE;
588   }
589
590   /**
591    * Retrieves the first warning reported by calls on this
592    * <code>Connection</code> object. If there is more than one
593    * warning, subsequent warnings will be chained to the first one
594    * and can be retrieved by calling the method
595    * <code>SQLWarning.getNextWarning</code> on the warning
596    * that was retrieved previously.
597    * <P>
598    * This method may not be
599    * called on a closed connection; doing so will cause an
600    * <code>SQLException</code> to be thrown.
601    *
602    * <P><B>Note:</B> Subsequent warnings will be chained to this
603    * SQLWarning.
604    *
605    * @return the first <code>SQLWarning</code> object or <code>null</code>
606    * if there are none
607    * @exception SQLException if a database access error occurs or
608    * this method is called on a closed connection
609    * @see SQLWarning
610    */

611   public SQLWarning JavaDoc getWarnings() throws SQLException JavaDoc {
612     throw new UnsupportedOperationException JavaDoc(
613         "Connection.getWarnings() unsupported");
614   }
615
616   /**
617    * Clears all warnings reported for this <code>Connection</code> object.
618    * After a call to this method, the method <code>getWarnings</code>
619    * returns <code>null</code> until a new warning is
620    * reported for this <code>Connection</code> object.
621    *
622    * @exception SQLException if a database access error occurs
623    */

624   public void clearWarnings() throws SQLException JavaDoc {
625     throw new UnsupportedOperationException JavaDoc(
626         "Connection.getWarnings() unsupported");
627   }
628
629   //--------------------------JDBC 2.0-----------------------------
630

631   /**
632    * Creates a <code>Statement</code> object that will generate
633    * <code>ResultSet</code> objects with the given type and concurrency.
634    * This method is the same as the <code>createStatement</code> method
635    * above, but it allows the default result set
636    * type and concurrency to be overridden.
637    *
638    * @param resultSetType a result set type; one of
639    * <code>ResultSet.TYPE_FORWARD_ONLY</code>,
640    * <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or
641    * <code>ResultSet.TYPE_SCROLL_SENSITIVE</code>
642    * @param resultSetConcurrency a concurrency type; one of
643    * <code>ResultSet.CONCUR_READ_ONLY</code> or
644    * <code>ResultSet.CONCUR_UPDATABLE</code>
645    * @return a new <code>Statement</code> object that will generate
646    * <code>ResultSet</code> objects with the given type and
647    * concurrency
648    * @exception SQLException if a database access error occurs
649    * or the given parameters are not <code>ResultSet</code>
650    * constants indicating type and concurrency
651    */

652   public Statement JavaDoc createStatement(int resultSetType, int resultSetConcurrency) throws
653       SQLException JavaDoc {
654     throw new UnsupportedOperationException JavaDoc(
655         "Connection.createStatement(int, int) unsupported");
656   }
657
658   /**
659    * Creates a <code>PreparedStatement</code> object that will generate
660    * <code>ResultSet</code> objects with the given type and concurrency.
661    * This method is the same as the <code>prepareStatement</code> method
662    * above, but it allows the default result set
663    * type and concurrency to be overridden.
664    *
665    * @param sql a <code>String</code> object that is the SQL statement to
666    * be sent to the database; may contain one or more ? IN
667    * parameters
668    * @param resultSetType a result set type; one of
669    * <code>ResultSet.TYPE_FORWARD_ONLY</code>,
670    * <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or
671    * <code>ResultSet.TYPE_SCROLL_SENSITIVE</code>
672    * @param resultSetConcurrency a concurrency type; one of
673    * <code>ResultSet.CONCUR_READ_ONLY</code> or
674    * <code>ResultSet.CONCUR_UPDATABLE</code>
675    * @return a new PreparedStatement object containing the
676    * pre-compiled SQL statement that will produce <code>ResultSet</code>
677    * objects with the given type and concurrency
678    * @exception SQLException if a database access error occurs
679    * or the given parameters are not <code>ResultSet</code>
680    * constants indicating type and concurrency
681    */

682   public PreparedStatement JavaDoc prepareStatement(String JavaDoc sql, int resultSetType,
683                                             int resultSetConcurrency) throws
684       SQLException JavaDoc {
685     throw new UnsupportedOperationException JavaDoc(
686         "Connection.prepareStatement(String, int, int) unsupported");
687   }
688
689   /**
690    * Creates a <code>CallableStatement</code> object that will generate
691    * <code>ResultSet</code> objects with the given type and concurrency.
692    * This method is the same as the <code>prepareCall</code> method
693    * above, but it allows the default result set
694    * type and concurrency to be overridden.
695    *
696    * @param sql a <code>String</code> object that is the SQL statement to
697    * be sent to the database; may contain on or more ? parameters
698    * @param resultSetType a result set type; one of
699    * <code>ResultSet.TYPE_FORWARD_ONLY</code>,
700    * <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or
701    * <code>ResultSet.TYPE_SCROLL_SENSITIVE</code>
702    * @param resultSetConcurrency a concurrency type; one of
703    * <code>ResultSet.CONCUR_READ_ONLY</code> or
704    * <code>ResultSet.CONCUR_UPDATABLE</code>
705    * @return a new <code>CallableStatement</code> object containing the
706    * pre-compiled SQL statement that will produce <code>ResultSet</code>
707    * objects with the given type and concurrency
708    * @exception SQLException if a database access error occurs
709    * or the given parameters are not <code>ResultSet</code>
710    * constants indicating type and concurrency
711    */

712   public CallableStatement JavaDoc prepareCall(String JavaDoc sql, int resultSetType,
713                                        int resultSetConcurrency) throws
714       SQLException JavaDoc {
715     throw new UnsupportedOperationException JavaDoc(
716         "Connection.prepareCall(String, int, int) unsupported");
717   }
718
719   /**
720    * Retrieves the <code>Map</code> object associated with this
721    * <code>Connection</code> object.
722    * Unless the application has added an entry, the type map returned
723    * will be empty.
724    *
725    * @return the <code>java.util.Map</code> object associated
726    * with this <code>Connection</code> object
727    * @exception SQLException if a database access error occurs
728    * @see #setTypeMap
729    */

730   public Map JavaDoc getTypeMap() throws SQLException JavaDoc {
731     throw new UnsupportedOperationException JavaDoc(
732         "Connection.getTypeMap() unsupported");
733   }
734
735   /**
736    * Installs the given <code>TypeMap</code> object as the type map for
737    * this <code>Connection</code> object. The type map will be used for the
738    * custom mapping of SQL structured types and distinct types.
739    *
740    * @param map the <code>java.util.Map</code> object to install
741    * as the replacement for this <code>Connection</code>
742    * object's default type map
743    * @exception SQLException if a database access error occurs or
744    * the given parameter is not a <code>java.util.Map</code>
745    * object
746    * @see #getTypeMap
747    */

748   public void setTypeMap(Map JavaDoc map) throws SQLException JavaDoc {
749     throw new UnsupportedOperationException JavaDoc(
750         "Connection.setTypeMap(Map) unsupported");
751   }
752
753   //--------------------------JDBC 3.0-----------------------------
754
/**
755    * Changes the holdability of <code>ResultSet</code> objects
756    * created using this <code>Connection</code> object to the given
757    * holdability.
758    *
759    * @param holdability a <code>ResultSet</code> holdability constant; one of
760    * <code>ResultSet.HOLD_CURSORS_OVER_COMMIT</code> or
761    * <code>ResultSet.CLOSE_CURSORS_AT_COMMIT</code>
762    * @throws SQLException if a database access occurs, the given parameter
763    * is not a <code>ResultSet</code> constant indicating holdability,
764    * or the given holdability is not supported
765    * @since 1.4
766    * @see #getHoldability
767    * @see java.sql.ResultSet
768    */

769   public void setHoldability(int holdability) throws SQLException JavaDoc {
770     throw new UnsupportedOperationException JavaDoc(
771         "Connection.setHoldability(int) unsupported");
772   }
773
774   /**
775    * Retrieves the current holdability of ResultSet objects created
776    * using this Connection object.
777    *
778    * @return the holdability, one of <code>ResultSet.HOLD_CURSORS_OVER_COMMIT</code> or
779    * <code>ResultSet.CLOSE_CURSORS_AT_COMMIT</code>
780    * @throws SQLException if a database access occurs
781    * @since 1.4
782    * @see #setHoldability
783    * @see java.sql.ResultSet
784    */

785   public int getHoldability() throws SQLException JavaDoc {
786     throw new UnsupportedOperationException JavaDoc(
787         "Connection.getHoldability() unsupported");
788   }
789
790 // Removed since this only builds under JDK 1.4
791
public Savepoint JavaDoc setSavepoint() throws SQLException JavaDoc {
792     throw new UnsupportedOperationException JavaDoc(
793         "Connection.setSavepoint() unsupported");
794   }
795
796   public Savepoint JavaDoc setSavepoint(String JavaDoc name) throws SQLException JavaDoc {
797     throw new UnsupportedOperationException JavaDoc(
798         "Connection.setSavepoint(String) unsupported");
799   }
800
801   public void rollback(Savepoint JavaDoc savepoint) throws SQLException JavaDoc {
802     throw new UnsupportedOperationException JavaDoc(
803         "Connection.rollback(Savepoint) unsupported");
804   }
805
806   public void releaseSavepoint(Savepoint JavaDoc savepoint) throws SQLException JavaDoc {
807     throw new UnsupportedOperationException JavaDoc(
808         "Connection.releaseSavepoint(Savepoint) unsupported");
809   }
810
811   public Statement JavaDoc createStatement(int resultSetType,
812                                    int resultSetConcurrency,
813                                    int resultSetHoldability) throws
814       SQLException JavaDoc {
815     throw new UnsupportedOperationException JavaDoc(
816         "Connection.createStatement(int,int,int) unsupported");
817   }
818
819   public PreparedStatement JavaDoc prepareStatement(String JavaDoc sql,
820                                             int resultSetType,
821                                             int resultSetConcurrency,
822                                             int resultSetHoldability) throws
823       SQLException JavaDoc {
824     throw new UnsupportedOperationException JavaDoc(
825         "Connection.prepareStatement(String,int,int,int) unsupported");
826   }
827
828   public CallableStatement JavaDoc prepareCall(String JavaDoc sql,
829                                        int resultSetType,
830                                        int resultSetConcurrency,
831                                        int resultSetHoldability) throws
832       SQLException JavaDoc {
833     throw new UnsupportedOperationException JavaDoc(
834         "Connection.prepareCall(String,int,int,int) unsupported");
835   }
836
837   public PreparedStatement JavaDoc prepareStatement(String JavaDoc sql, int autoGeneratedKeys) throws
838       SQLException JavaDoc {
839     throw new UnsupportedOperationException JavaDoc(
840         "Connection.prepareStatement(String,int) unsupported");
841   }
842
843   public PreparedStatement JavaDoc prepareStatement(String JavaDoc sql, int[] columnIndexes) throws
844       SQLException JavaDoc {
845     throw new UnsupportedOperationException JavaDoc(
846         "Connection.prepareStatement(String,int[]) unsupported");
847   }
848
849   public PreparedStatement JavaDoc prepareStatement(String JavaDoc sql, String JavaDoc[] columnNames) throws
850       SQLException JavaDoc {
851     throw new UnsupportedOperationException JavaDoc(
852         "Connection.prepareStatement(String,String[]) unsupported");
853   }
854
855   //---------------------------------------------------------------------
856
// Properties
857
//---------------------------------------------------------------------
858

859   /**
860    * Accessor method for the path property
861    * @return current value for the path property
862    */

863   protected String JavaDoc getPath() {
864     return path;
865   }
866
867   /**
868    * Accessor method for the extension property
869    * @return current value for the extension property
870    */

871   protected String JavaDoc getExtension() {
872     return extension;
873   }
874
875   /**
876    * Accessor method for the separator property
877    * @return current value for the separator property
878    */

879   protected char getSeperator() {
880     return separator;
881   }
882
883   /**
884    * Accessor method for the suppressHeaders property
885    * @return current value for the suppressHeaders property
886    */

887   protected boolean isSuppressHeaders() {
888     return suppressHeaders;
889   }
890
891   /**
892    * Accessor method for the charset property
893    * @return current value for the suppressHeaders property
894    */

895   protected String JavaDoc getCharset() {
896     return charset;
897   }
898
899   protected long getMaxFileSize() {
900     return maxFileSize;
901   }
902
903   protected String JavaDoc getLineBreakEscape() {
904     return lineBrakesEscape;
905   }
906
907   protected String JavaDoc getCarriageReturnEscape() {
908       return carriageReturnEscape;
909   }
910
911   protected boolean getUseQuotes() {
912     return this.useQuotes;
913   }
914   
915   protected boolean getUseQuotesEscape() {
916     return this.useQuotesEscape;
917   }
918
919 }
920
Popular Tags