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;
23 import java.sql.CallableStatement;
24 import java.sql.Connection;
25 import java.sql.DatabaseMetaData;
26 import java.sql.PreparedStatement;
27 import java.sql.SQLException;
28 import java.sql.SQLWarning;
29 import java.sql.Savepoint;
30 import java.sql.Statement;
31 import java.util.Enumeration;
32 import java.util.Map;
33 import java.util.Properties;
34 import java.util.StringTokenizer;
35 import java.util.Vector;
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 {
44
45 /*** Directory where the CSV files to use are located */
46 private String path;
47
48 /*** File extension to use */
49 private String 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 lineBrakesEscape = CsvDriver.DEFAULT_LINE_BREAK_ESCAPE;
65
66 /*** Escape for carriage return*/
67 private String 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 statements = new Vector();
77
78 /*** Charset that should be used to read the files */
79 private String 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 /*** Trim string */
88 private boolean trimString = CsvDriver.DEFAULT_TRIM;
89
90 /***
91 * Creates a new CsvConnection that takes the supplied path
92 * @param path directory where the CSV files are located
93 */
94 protected CsvConnection(String path) throws SQLException {
95 // validate argument(s)
96 if (path == null || path.length() == 0) {
97 throw new IllegalArgumentException(
98 "'path' argument may not be empty or null");
99 }
100 //check for properties
101 StringTokenizer st = new StringTokenizer(path, ";");
102 this.path = st.nextToken();
103 if (!this.path.endsWith(File.separator)) {
104 this.path += File.separator;
105 }
106 while (st.hasMoreTokens()) {
107 String next = st.nextToken();
108 if (!this.setProperty(next)) {
109 throw new IllegalArgumentException(
110 "unknown property " + next);
111 }
112 }
113 File filePath = new File(this.path);
114
115 if (!this.create && !filePath.exists()) {
116 throw new SQLException(
117 "Specified path '" + filePath.getAbsolutePath() +
118 "' does not exist !");
119 }
120
121 if (this.create && !filePath.exists())
122 filePath.mkdirs();
123
124 }
125
126 /***
127 * Creates a new CsvConnection that takes the supplied path and properties
128 * @param path directory where the CSV files are located
129 * @param info set of properties containing custom options
130 */
131 protected CsvConnection(String path, Properties info) throws SQLException {
132 this(path);
133 // check for properties
134 if (info != null) {
135 // set the file extension to be used
136 if (info.getProperty(CsvDriver.FILE_EXTENSION) != null) {
137 extension = info.getProperty(CsvDriver.FILE_EXTENSION);
138 if (!extension.startsWith("."))
139 extension = "." + extension;
140 }
141 // set the separator character to be used
142 if (info.getProperty(CsvDriver.SEPARATOR) != null) {
143 separator = info.getProperty(CsvDriver.SEPARATOR).charAt(0);
144 // patch for TAB separator
145 if(info.getProperty(CsvDriver.SEPARATOR).equalsIgnoreCase("TAB"))
146 this.separator = '\t';
147 // patch for SEMICOLON separator
148 if(info.getProperty(CsvDriver.SEPARATOR).equalsIgnoreCase("SC"))
149 this.separator = ';';
150 }
151 // set the header suppression flag
152 if (info.getProperty(CsvDriver.SUPPRESS_HEADERS) != null) {
153 suppressHeaders = Boolean.valueOf(info.getProperty(
154 CsvDriver.SUPPRESS_HEADERS)).booleanValue();
155 }
156 // default charset
157 if (info.getProperty(CsvDriver.CHARSET) != null) {
158 charset = info.getProperty(CsvDriver.CHARSET);
159 }
160 // set create
161 if (info.getProperty(CsvDriver.CREATE) != null) {
162 create = Boolean.valueOf(info.getProperty(
163 CsvDriver.SUPPRESS_HEADERS)).booleanValue();
164 }
165 // default max file size
166 if (info.getProperty(CsvDriver.MAXFILESIZE) != null) {
167 maxFileSize = Long.valueOf(info.getProperty(CsvDriver.MAXFILESIZE)).
168 longValue();
169 }
170 // default escape for line break
171 if (info.getProperty(CsvDriver.LINE_BREAK_ESCAPE) != null) {
172 lineBrakesEscape = info.getProperty(CsvDriver.LINE_BREAK_ESCAPE);
173 }
174 // default escape for carriage return
175 if (info.getProperty(CsvDriver.CARRIAGE_RETURN_ESCAPE) != null) {
176 carriageReturnEscape = info.getProperty(CsvDriver.CARRIAGE_RETURN_ESCAPE);
177 }
178 // default use quotes
179 if (info.getProperty(CsvDriver.USE_QUOTES) != null) {
180 useQuotes = new Boolean(info.getProperty(CsvDriver.USE_QUOTES)).booleanValue();
181 }
182 // default use quotes escape
183 if (info.getProperty(CsvDriver.USE_QUOTES_ESCAPE) != null) {
184 useQuotesEscape = new Boolean(info.getProperty(CsvDriver.USE_QUOTES_ESCAPE)).booleanValue();
185 }
186 // default use trim string
187 if (info.getProperty(CsvDriver.TRIM_STRING) != null) {
188 trimString = Boolean.valueOf(info.getProperty(
189 CsvDriver.TRIM_STRING)).booleanValue();
190 }
191 }
192 }
193
194 private boolean setProperty(String propString) {
195 boolean retVal = true;
196 StringTokenizer st = new StringTokenizer(propString, "=");
197 String name = st.nextToken();
198 String value = st.nextToken();
199 if (name.equals(CsvDriver.SEPARATOR)) {
200 this.separator = value.charAt(0);
201 //patch for TAB separator
202 if(value.equalsIgnoreCase("TAB"))
203 this.separator = '\t';
204 // patch for SEMICOLON separator
205 if(value.equalsIgnoreCase("SC"))
206 this.separator = ';';
207 }
208 else if (name.equals(CsvDriver.FILE_EXTENSION)) {
209 if (!value.startsWith("."))
210 value = "." + value;
211 this.extension = value;
212 }
213 else if (name.equals(CsvDriver.SUPPRESS_HEADERS)) {
214 this.suppressHeaders = Boolean.valueOf(value).booleanValue();
215 }
216 else if (name.equals(CsvDriver.CHARSET)) {
217 this.charset = value;
218 }
219 else if (name.equals(CsvDriver.CREATE)) {
220 this.create = Boolean.valueOf(value).booleanValue();
221 }
222 else if (name.equals(CsvDriver.MAXFILESIZE)) {
223 this.maxFileSize = Long.valueOf(value).longValue();
224 }
225 else if (name.equals(CsvDriver.LINE_BREAK_ESCAPE)) {
226 this.lineBrakesEscape = value;
227 }
228 else if (name.equals(CsvDriver.CARRIAGE_RETURN_ESCAPE)) {
229 this.carriageReturnEscape = value;
230 }
231 else if (name.equals(CsvDriver.USE_QUOTES)) {
232 this.useQuotes = new Boolean( value ).booleanValue();
233 }
234 else if (name.equals(CsvDriver.USE_QUOTES_ESCAPE)) {
235 this.useQuotesEscape = new Boolean( value ).booleanValue();
236 }
237 else if (name.equals(CsvDriver.TRIM_STRING)) {
238 this.trimString = Boolean.valueOf(value).booleanValue();
239 }
240 else
241 retVal = false;
242 return retVal;
243 }
244
245 /***
246 * Creates a <code>Statement</code> object for sending
247 * SQL statements to the database.
248 * SQL statements without parameters are normally
249 * executed using <code>Statement</code> objects. If the same SQL statement
250 * is executed many times, it may be more efficient to use a
251 * <code>PreparedStatement</code> object.
252 * <P>
253 * Result sets created using the returned <code>Statement</code>
254 * object will by default be type <code>TYPE_FORWARD_ONLY</code>
255 * and have a concurrency level of <code>CONCUR_READ_ONLY</code>.
256 *
257 * @return a new default <code>Statement</code> object
258 * @exception SQLException if a database access error occurs
259 */
260 public Statement createStatement() throws SQLException {
261 CsvStatement statement = new CsvStatement(this);
262 statements.add(statement);
263 return statement;
264 }
265
266 /***
267 * Creates a <code>PreparedStatement</code> object for sending
268 * parameterized SQL statements to the database.
269 * <P>
270 * A SQL statement with or without IN parameters can be
271 * pre-compiled and stored in a <code>PreparedStatement</code> object. This
272 * object can then be used to efficiently execute this statement
273 * multiple times.
274 *
275 * <P><B>Note:</B> This method is optimized for handling
276 * parametric SQL statements that benefit from precompilation. If
277 * the driver supports precompilation,
278 * the method <code>prepareStatement</code> will send
279 * the statement to the database for precompilation. Some drivers
280 * may not support precompilation. In this case, the statement may
281 * not be sent to the database until the <code>PreparedStatement</code>
282 * object is executed. This has no direct effect on users; however, it does
283 * affect which methods throw certain <code>SQLException</code> objects.
284 * <P>
285 * Result sets created using the returned <code>PreparedStatement</code>
286 * object will by default be type <code>TYPE_FORWARD_ONLY</code>
287 * and have a concurrency level of <code>CONCUR_READ_ONLY</code>.
288 *
289 * @param sql an SQL statement that may contain one or more '?' IN
290 * parameter placeholders
291 * @return a new default <code>PreparedStatement</code> object containing the
292 * pre-compiled SQL statement
293 * @exception SQLException if a database access error occurs
294 */
295 public PreparedStatement prepareStatement(String sql) throws SQLException {
296 int index = sql.indexOf("?");
297 while (index != -1) {
298 sql = sql.substring(0, index) + CsvPreparedStatement.PREPARE_SEPARATOR + sql.substring(index + 1);
299 index = sql.indexOf("?");
300 }
301
302 CsvPreparedStatement statement = new CsvPreparedStatement(this, sql);
303 statements.add(statement);
304 return statement;
305 }
306
307 /***
308 * Creates a <code>CallableStatement</code> object for calling
309 * database stored procedures.
310 * The <code>CallableStatement</code> object provides
311 * methods for setting up its IN and OUT parameters, and
312 * methods for executing the call to a stored procedure.
313 *
314 * <P><B>Note:</B> This method is optimized for handling stored
315 * procedure call statements. Some drivers may send the call
316 * statement to the database when the method <code>prepareCall</code>
317 * is done; others
318 * may wait until the <code>CallableStatement</code> object
319 * is executed. This has no
320 * direct effect on users; however, it does affect which method
321 * throws certain SQLExceptions.
322 * <P>
323 * Result sets created using the returned <code>CallableStatement</code>
324 * object will by default be type <code>TYPE_FORWARD_ONLY</code>
325 * and have a concurrency level of <code>CONCUR_READ_ONLY</code>.
326 *
327 * @param sql an SQL statement that may contain one or more '?'
328 * parameter placeholders. Typically this statement is a JDBC
329 * function call escape string.
330 * @return a new default <code>CallableStatement</code> object containing the
331 * pre-compiled SQL statement
332 * @exception SQLException if a database access error occurs
333 */
334 public CallableStatement prepareCall(String sql) throws SQLException {
335 throw new UnsupportedOperationException(
336 "Connection.prepareCall(String) unsupported");
337 }
338
339 /***
340 * Converts the given SQL statement into the system's native SQL grammar.
341 * A driver may convert the JDBC SQL grammar into its system's
342 * native SQL grammar prior to sending it. This method returns the
343 * native form of the statement that the driver would have sent.
344 *
345 * @param sql an SQL statement that may contain one or more '?'
346 * parameter placeholders
347 * @return the native form of this statement
348 * @exception SQLException if a database access error occurs
349 */
350 public String nativeSQL(String sql) throws SQLException {
351 throw new UnsupportedOperationException(
352 "Connection.nativeSQL(String) unsupported");
353 }
354
355 /***
356 * Sets this connection's auto-commit mode to the given state.
357 * If a connection is in auto-commit mode, then all its SQL
358 * statements will be executed and committed as individual
359 * transactions. Otherwise, its SQL statements are grouped into
360 * transactions that are terminated by a call to either
361 * the method <code>commit</code> or the method <code>rollback</code>.
362 * By default, new connections are in auto-commit
363 * mode.
364 * <P>
365 * The commit occurs when the statement completes or the next
366 * execute occurs, whichever comes first. In the case of
367 * statements returning a <code>ResultSet</code> object,
368 * the statement completes when the last row of the
369 * <code>ResultSet</code> object has been retrieved or the
370 * <code>ResultSet</code> object has been closed. In advanced cases, a
371 * single statement may return multiple results as well as output
372 * parameter values. In these cases, the commit occurs when all results and
373 * output parameter values have been retrieved.
374 * <P>
375 * <B>NOTE:</B> If this method is called during a transaction, the
376 * transaction is committed.
377 *
378 * @param autoCommit <code>true</code> to enable auto-commit mode;
379 * <code>false</code> to disable it
380 * @exception SQLException if a database access error occurs
381 * @see #getAutoCommit
382 */
383 public void setAutoCommit(boolean autoCommit) throws SQLException {
384 this.autoCommit = autoCommit;
385 // throw new UnsupportedOperationException(
386 // "Connection.setAutoCommit(boolean) unsupported");
387 }
388
389 /***
390 * Retrieves the current auto-commit mode for this <code>Connection</code>
391 * object.
392 *
393 * @return the current state of this <code>Connection</code> object's
394 * auto-commit mode
395 * @exception SQLException if a database access error occurs
396 * @see #setAutoCommit
397 */
398 public boolean getAutoCommit() throws SQLException {
399 // throw new UnsupportedOperationException(
400 // "Connection.getAutoCommit() unsupported");
401 // return true;
402 return this.autoCommit;
403 }
404
405 /***
406 * Makes all changes made since the previous
407 * commit/rollback permanent and releases any database locks
408 * currently held by this <code>Connection</code> object.
409 * This method should be
410 * used only when auto-commit mode has been disabled.
411 *
412 * @exception SQLException if a database access error occurs or this
413 * <code>Connection</code> object is in auto-commit mode
414 * @see #setAutoCommit
415 */
416 public void commit() throws SQLException {
417 for (int i = 0; i < this.statements.size(); i++) {
418 ( (Statement) statements.get(i)).close();
419 }
420 }
421
422 /***
423 * Undoes all changes made in the current transaction
424 * and releases any database locks currently held
425 * by this <code>Connection</code> object. This method should be
426 * used only when auto-commit mode has been disabled.
427 *
428 * @exception SQLException if a database access error occurs or this
429 * <code>Connection</code> object is in auto-commit mode
430 * @see #setAutoCommit
431 */
432 public void rollback() throws SQLException {
433 throw new UnsupportedOperationException(
434 "Connection.rollback() unsupported");
435 }
436
437 /***
438 * Releases this <code>Connection</code> object's database and JDBC
439 * resources immediately instead of waiting for them to be automatically
440 * released.
441 * <P>
442 * Calling the method <code>close</code> on a <code>Connection</code>
443 * object that is already closed is a no-op.
444 * <P>
445 * <B>Note:</B> A <code>Connection</code> object is automatically
446 * closed when it is garbage collected. Certain fatal errors also
447 * close a <code>Connection</code> object.
448 *
449 * @exception SQLException if a database access error occurs
450 */
451 public void close() throws SQLException {
452 // close all created statements
453 for (Enumeration i = statements.elements(); i.hasMoreElements(); ) {
454 Statement statement = (Statement) i.nextElement();
455 statement.close();
456 }
457 // set this Connection as closed
458 closed = true;
459 }
460
461 /***
462 * Retrieves whether this <code>Connection</code> object has been
463 * closed. A connection is closed if the method <code>close</code>
464 * has been called on it or if certain fatal errors have occurred.
465 * This method is guaranteed to return <code>true</code> only when
466 * it is called after the method <code>Connection.close</code> has
467 * been called.
468 * <P>
469 * This method generally cannot be called to determine whether a
470 * connection to a database is valid or invalid. A typical client
471 * can determine that a connection is invalid by catching any
472 * exceptions that might be thrown when an operation is attempted.
473 *
474 * @return <code>true</code> if this <code>Connection</code> object
475 * is closed; <code>false</code> if it is still open
476 * @exception SQLException if a database access error occurs
477 */
478 public boolean isClosed() throws SQLException {
479 return closed;
480 }
481
482 /***
483 * Retrieves a <code>DatabaseMetaData</code> object that contains
484 * metadata about the database to which this
485 * <code>Connection</code> object represents a connection.
486 * The metadata includes information about the database's
487 * tables, its supported SQL grammar, its stored
488 * procedures, the capabilities of this connection, and so on.
489 *
490 * @return a <code>DatabaseMetaData</code> object for this
491 * <code>Connection</code> object
492 * @exception SQLException if a database access error occurs
493 */
494 public DatabaseMetaData getMetaData() throws SQLException {
495 throw new UnsupportedOperationException(
496 "Connection.getMetaData() unsupported");
497 }
498
499 /***
500 * Puts this connection in read-only mode as a hint to the driver to enable
501 * database optimizations.
502 *
503 * <P><B>Note:</B> This method cannot be called during a transaction.
504 *
505 * @param readOnly <code>true</code> enables read-only mode;
506 * <code>false</code> disables it
507 * @exception SQLException if a database access error occurs or this
508 * method is called during a transaction
509 */
510 public void setReadOnly(boolean readOnly) throws SQLException {
511 throw new UnsupportedOperationException(
512 "Connection.setReadOnly(boolean) unsupported");
513 }
514
515 /***
516 * Retrieves whether this <code>Connection</code>
517 * object is in read-only mode.
518 *
519 * @return <code>true</code> if this <code>Connection</code> object
520 * is read-only; <code>false</code> otherwise
521 * @exception SQLException if a database access error occurs
522 */
523 public boolean isReadOnly() throws SQLException {
524 return true;
525 }
526
527 /***
528 * Sets the given catalog name in order to select
529 * a subspace of this <code>Connection</code> object's database
530 * in which to work.
531 * <P>
532 * If the driver does not support catalogs, it will
533 * silently ignore this request.
534 *
535 * @param catalog the name of a catalog (subspace in this
536 * <code>Connection</code> object's database) in which to work
537 * @exception SQLException if a database access error occurs
538 * @see #getCatalog
539 */
540 public void setCatalog(String catalog) throws SQLException {
541 // silently ignore this request
542 }
543
544 /***
545 * Retrieves this <code>Connection</code> object's current catalog name.
546 *
547 * @return the current catalog name or <code>null</code> if there is none
548 * @exception SQLException if a database access error occurs
549 * @see #setCatalog
550 */
551 public String getCatalog() throws SQLException {
552 return null;
553 }
554
555 /***
556 * Attempts to change the transaction isolation level for this
557 * <code>Connection</code> object to the one given.
558 * The constants defined in the interface <code>Connection</code>
559 * are the possible transaction isolation levels.
560 * <P>
561 * <B>Note:</B> If this method is called during a transaction, the result
562 * is implementation-defined.
563 *
564 * @param level one of the following <code>Connection</code> constants:
565 * <code>Connection.TRANSACTION_READ_UNCOMMITTED</code>,
566 * <code>Connection.TRANSACTION_READ_COMMITTED</code>,
567 * <code>Connection.TRANSACTION_REPEATABLE_READ</code>, or
568 * <code>Connection.TRANSACTION_SERIALIZABLE</code>.
569 * (Note that <code>Connection.TRANSACTION_NONE</code> cannot be used
570 * because it specifies that transactions are not supported.)
571 * @exception SQLException if a database access error occurs
572 * or the given parameter is not one of the <code>Connection</code>
573 * constants
574 * @see DatabaseMetaData#supportsTransactionIsolationLevel
575 * @see #getTransactionIsolation
576 */
577 public void setTransactionIsolation(int level) throws SQLException {
578 throw new UnsupportedOperationException(
579 "Connection.setTransactionIsolation(int) unsupported");
580 }
581
582 /***
583 * Retrieves this <code>Connection</code> object's current
584 * transaction isolation level.
585 *
586 * @return the current transaction isolation level, which will be one
587 * of the following constants:
588 * <code>Connection.TRANSACTION_READ_UNCOMMITTED</code>,
589 * <code>Connection.TRANSACTION_READ_COMMITTED</code>,
590 * <code>Connection.TRANSACTION_REPEATABLE_READ</code>,
591 * <code>Connection.TRANSACTION_SERIALIZABLE</code>, or
592 * <code>Connection.TRANSACTION_NONE</code>.
593 * @exception SQLException if a database access error occurs
594 * @see #setTransactionIsolation
595 */
596 public int getTransactionIsolation() throws SQLException {
597 return Connection.TRANSACTION_NONE;
598 }
599
600 /***
601 * Retrieves the first warning reported by calls on this
602 * <code>Connection</code> object. If there is more than one
603 * warning, subsequent warnings will be chained to the first one
604 * and can be retrieved by calling the method
605 * <code>SQLWarning.getNextWarning</code> on the warning
606 * that was retrieved previously.
607 * <P>
608 * This method may not be
609 * called on a closed connection; doing so will cause an
610 * <code>SQLException</code> to be thrown.
611 *
612 * <P><B>Note:</B> Subsequent warnings will be chained to this
613 * SQLWarning.
614 *
615 * @return the first <code>SQLWarning</code> object or <code>null</code>
616 * if there are none
617 * @exception SQLException if a database access error occurs or
618 * this method is called on a closed connection
619 * @see SQLWarning
620 */
621 public SQLWarning getWarnings() throws SQLException {
622 throw new UnsupportedOperationException(
623 "Connection.getWarnings() unsupported");
624 }
625
626 /***
627 * Clears all warnings reported for this <code>Connection</code> object.
628 * After a call to this method, the method <code>getWarnings</code>
629 * returns <code>null</code> until a new warning is
630 * reported for this <code>Connection</code> object.
631 *
632 * @exception SQLException if a database access error occurs
633 */
634 public void clearWarnings() throws SQLException {
635 throw new UnsupportedOperationException(
636 "Connection.getWarnings() unsupported");
637 }
638
639 //--------------------------JDBC 2.0-----------------------------
640
641 /***
642 * Creates a <code>Statement</code> object that will generate
643 * <code>ResultSet</code> objects with the given type and concurrency.
644 * This method is the same as the <code>createStatement</code> method
645 * above, but it allows the default result set
646 * type and concurrency to be overridden.
647 *
648 * @param resultSetType a result set type; one of
649 * <code>ResultSet.TYPE_FORWARD_ONLY</code>,
650 * <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or
651 * <code>ResultSet.TYPE_SCROLL_SENSITIVE</code>
652 * @param resultSetConcurrency a concurrency type; one of
653 * <code>ResultSet.CONCUR_READ_ONLY</code> or
654 * <code>ResultSet.CONCUR_UPDATABLE</code>
655 * @return a new <code>Statement</code> object that will generate
656 * <code>ResultSet</code> objects with the given type and
657 * concurrency
658 * @exception SQLException if a database access error occurs
659 * or the given parameters are not <code>ResultSet</code>
660 * constants indicating type and concurrency
661 */
662 public Statement createStatement(int resultSetType, int resultSetConcurrency) throws
663 SQLException {
664 throw new UnsupportedOperationException(
665 "Connection.createStatement(int, int) unsupported");
666 }
667
668 /***
669 * Creates a <code>PreparedStatement</code> object that will generate
670 * <code>ResultSet</code> objects with the given type and concurrency.
671 * This method is the same as the <code>prepareStatement</code> method
672 * above, but it allows the default result set
673 * type and concurrency to be overridden.
674 *
675 * @param sql a <code>String</code> object that is the SQL statement to
676 * be sent to the database; may contain one or more ? IN
677 * parameters
678 * @param resultSetType a result set type; one of
679 * <code>ResultSet.TYPE_FORWARD_ONLY</code>,
680 * <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or
681 * <code>ResultSet.TYPE_SCROLL_SENSITIVE</code>
682 * @param resultSetConcurrency a concurrency type; one of
683 * <code>ResultSet.CONCUR_READ_ONLY</code> or
684 * <code>ResultSet.CONCUR_UPDATABLE</code>
685 * @return a new PreparedStatement object containing the
686 * pre-compiled SQL statement that will produce <code>ResultSet</code>
687 * objects with the given type and concurrency
688 * @exception SQLException if a database access error occurs
689 * or the given parameters are not <code>ResultSet</code>
690 * constants indicating type and concurrency
691 */
692 public PreparedStatement prepareStatement(String sql, int resultSetType,
693 int resultSetConcurrency) throws
694 SQLException {
695 throw new UnsupportedOperationException(
696 "Connection.prepareStatement(String, int, int) unsupported");
697 }
698
699 /***
700 * Creates a <code>CallableStatement</code> object that will generate
701 * <code>ResultSet</code> objects with the given type and concurrency.
702 * This method is the same as the <code>prepareCall</code> method
703 * above, but it allows the default result set
704 * type and concurrency to be overridden.
705 *
706 * @param sql a <code>String</code> object that is the SQL statement to
707 * be sent to the database; may contain on or more ? parameters
708 * @param resultSetType a result set type; one of
709 * <code>ResultSet.TYPE_FORWARD_ONLY</code>,
710 * <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or
711 * <code>ResultSet.TYPE_SCROLL_SENSITIVE</code>
712 * @param resultSetConcurrency a concurrency type; one of
713 * <code>ResultSet.CONCUR_READ_ONLY</code> or
714 * <code>ResultSet.CONCUR_UPDATABLE</code>
715 * @return a new <code>CallableStatement</code> object containing the
716 * pre-compiled SQL statement that will produce <code>ResultSet</code>
717 * objects with the given type and concurrency
718 * @exception SQLException if a database access error occurs
719 * or the given parameters are not <code>ResultSet</code>
720 * constants indicating type and concurrency
721 */
722 public CallableStatement prepareCall(String sql, int resultSetType,
723 int resultSetConcurrency) throws
724 SQLException {
725 throw new UnsupportedOperationException(
726 "Connection.prepareCall(String, int, int) unsupported");
727 }
728
729 /***
730 * Retrieves the <code>Map</code> object associated with this
731 * <code>Connection</code> object.
732 * Unless the application has added an entry, the type map returned
733 * will be empty.
734 *
735 * @return the <code>java.util.Map</code> object associated
736 * with this <code>Connection</code> object
737 * @exception SQLException if a database access error occurs
738 * @see #setTypeMap
739 */
740 public Map getTypeMap() throws SQLException {
741 throw new UnsupportedOperationException(
742 "Connection.getTypeMap() unsupported");
743 }
744
745 /***
746 * Installs the given <code>TypeMap</code> object as the type map for
747 * this <code>Connection</code> object. The type map will be used for the
748 * custom mapping of SQL structured types and distinct types.
749 *
750 * @param map the <code>java.util.Map</code> object to install
751 * as the replacement for this <code>Connection</code>
752 * object's default type map
753 * @exception SQLException if a database access error occurs or
754 * the given parameter is not a <code>java.util.Map</code>
755 * object
756 * @see #getTypeMap
757 */
758 public void setTypeMap(Map map) throws SQLException {
759 throw new UnsupportedOperationException(
760 "Connection.setTypeMap(Map) unsupported");
761 }
762
763 //--------------------------JDBC 3.0-----------------------------
764 /***
765 * Changes the holdability of <code>ResultSet</code> objects
766 * created using this <code>Connection</code> object to the given
767 * holdability.
768 *
769 * @param holdability a <code>ResultSet</code> holdability constant; one of
770 * <code>ResultSet.HOLD_CURSORS_OVER_COMMIT</code> or
771 * <code>ResultSet.CLOSE_CURSORS_AT_COMMIT</code>
772 * @throws SQLException if a database access occurs, the given parameter
773 * is not a <code>ResultSet</code> constant indicating holdability,
774 * or the given holdability is not supported
775 * @since 1.4
776 * @see #getHoldability
777 * @see java.sql.ResultSet
778 */
779 public void setHoldability(int holdability) throws SQLException {
780 throw new UnsupportedOperationException(
781 "Connection.setHoldability(int) unsupported");
782 }
783
784 /***
785 * Retrieves the current holdability of ResultSet objects created
786 * using this Connection object.
787 *
788 * @return the holdability, one of <code>ResultSet.HOLD_CURSORS_OVER_COMMIT</code> or
789 * <code>ResultSet.CLOSE_CURSORS_AT_COMMIT</code>
790 * @throws SQLException if a database access occurs
791 * @since 1.4
792 * @see #setHoldability
793 * @see java.sql.ResultSet
794 */
795 public int getHoldability() throws SQLException {
796 throw new UnsupportedOperationException(
797 "Connection.getHoldability() unsupported");
798 }
799
800 // Removed since this only builds under JDK 1.4
801 public Savepoint setSavepoint() throws SQLException {
802 throw new UnsupportedOperationException(
803 "Connection.setSavepoint() unsupported");
804 }
805
806 public Savepoint setSavepoint(String name) throws SQLException {
807 throw new UnsupportedOperationException(
808 "Connection.setSavepoint(String) unsupported");
809 }
810
811 public void rollback(Savepoint savepoint) throws SQLException {
812 throw new UnsupportedOperationException(
813 "Connection.rollback(Savepoint) unsupported");
814 }
815
816 public void releaseSavepoint(Savepoint savepoint) throws SQLException {
817 throw new UnsupportedOperationException(
818 "Connection.releaseSavepoint(Savepoint) unsupported");
819 }
820
821 public Statement createStatement(int resultSetType,
822 int resultSetConcurrency,
823 int resultSetHoldability) throws
824 SQLException {
825 throw new UnsupportedOperationException(
826 "Connection.createStatement(int,int,int) unsupported");
827 }
828
829 public PreparedStatement prepareStatement(String sql,
830 int resultSetType,
831 int resultSetConcurrency,
832 int resultSetHoldability) throws
833 SQLException {
834 throw new UnsupportedOperationException(
835 "Connection.prepareStatement(String,int,int,int) unsupported");
836 }
837
838 public CallableStatement prepareCall(String sql,
839 int resultSetType,
840 int resultSetConcurrency,
841 int resultSetHoldability) throws
842 SQLException {
843 throw new UnsupportedOperationException(
844 "Connection.prepareCall(String,int,int,int) unsupported");
845 }
846
847 public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws
848 SQLException {
849 throw new UnsupportedOperationException(
850 "Connection.prepareStatement(String,int) unsupported");
851 }
852
853 public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws
854 SQLException {
855 throw new UnsupportedOperationException(
856 "Connection.prepareStatement(String,int[]) unsupported");
857 }
858
859 public PreparedStatement prepareStatement(String sql, String[] columnNames) throws
860 SQLException {
861 throw new UnsupportedOperationException(
862 "Connection.prepareStatement(String,String[]) unsupported");
863 }
864
865 //---------------------------------------------------------------------
866 // Properties
867 //---------------------------------------------------------------------
868
869 /***
870 * Accessor method for the path property
871 * @return current value for the path property
872 */
873 protected String getPath() {
874 return path;
875 }
876
877 /***
878 * Accessor method for the extension property
879 * @return current value for the extension property
880 */
881 protected String getExtension() {
882 return extension;
883 }
884
885 /***
886 * Accessor method for the separator property
887 * @return current value for the separator property
888 */
889 protected char getSeperator() {
890 return separator;
891 }
892
893 /***
894 * Accessor method for the suppressHeaders property
895 * @return current value for the suppressHeaders property
896 */
897 protected boolean isSuppressHeaders() {
898 return suppressHeaders;
899 }
900
901 /***
902 * Accessor method for the trimString property
903 * @return current value for the trimString property
904 */
905 protected boolean isTrimString() {
906 return trimString;
907 }
908
909 /***
910 * Accessor method for the charset property
911 * @return current value for the suppressHeaders property
912 */
913 protected String getCharset() {
914 return charset;
915 }
916
917 protected long getMaxFileSize() {
918 return maxFileSize;
919 }
920
921 protected String getLineBreakEscape() {
922 return lineBrakesEscape;
923 }
924
925 protected String getCarriageReturnEscape() {
926 return carriageReturnEscape;
927 }
928
929 protected boolean getUseQuotes() {
930 return this.useQuotes;
931 }
932
933 protected boolean getUseQuotesEscape() {
934 return this.useQuotesEscape;
935 }
936
937 }
This page was automatically generated by Maven