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