org.relique.jdbc.csv
Class CsvDriver

java.lang.Object
  extended by org.relique.jdbc.csv.CsvDriver
All Implemented Interfaces:
Driver

public class CsvDriver
extends Object
implements Driver

This class implements the java.sql.Driver JDBC interface for the CsvJdbc driver.


Field Summary
static String CHARSET
           
static String COLUMN_TYPES
           
static String COMMENT_CHAR
           
static String CRYPTO_FILTER_CLASS_NAME
           
static String DATE_FORMAT
           
static String DEFAULT_COLUMN_TYPES
           
static String DEFAULT_COMMENT_CHAR
           
static String DEFAULT_DATE_FORMAT
           
static String DEFAULT_DEFECTIVE_HEADERS
           
static String DEFAULT_EXTENSION
           
static String DEFAULT_FILE_TAIL_PREPEND
           
static String DEFAULT_HEADERLINE
           
static String DEFAULT_IGNORE_UNPARSEABLE_LINES
           
static boolean DEFAULT_INDEXED_FILES
           
static boolean DEFAULT_IS_HEADER_FIXED_WIDTH
           
static String DEFAULT_MISSING_VALUE
           
static String DEFAULT_QUOTE_STYLE
           
static char DEFAULT_QUOTECHAR
           
static String DEFAULT_SEPARATOR
           
static String DEFAULT_SKIP_LEADING_DATA_LINES
           
static String DEFAULT_SKIP_LEADING_LINES
           
static boolean DEFAULT_SUPPRESS
           
static String DEFAULT_TIME_FORMAT
           
static String DEFAULT_TIME_ZONE_NAME
           
static String DEFAULT_TIMESTAMP_FORMAT
           
static boolean DEFAULT_TRIM_HEADERS
           
static boolean DEFAULT_TRIM_VALUES
           
static String DEFECTIVE_HEADERS
           
static String FILE_EXTENSION
           
static String FILE_TAIL_PREPEND
           
static String FIXED_WIDTHS
           
static String FUNCTION
           
static String HEADERLINE
           
static String IGNORE_UNPARSEABLE_LINES
           
static String INDEXED_FILES
           
static String IS_HEADER_FIXED_WIDTH
           
static String LOCALE
           
static String MISSING_VALUE
           
static String QUOTE_STYLE
           
static String QUOTECHAR
           
static String READER_CLASS_PREFIX
           
static String SEPARATOR
           
static String SKIP_LEADING_DATA_LINES
           
static String SKIP_LEADING_LINES
           
static String SUPPRESS_HEADERS
           
static String TIME_FORMAT
           
static String TIME_ZONE_NAME
           
static String TIMESTAMP_FORMAT
           
static String TRANSPOSED_FIELDS_TO_SKIP
           
static String TRANSPOSED_LINES
           
static String TRIM_HEADERS
           
static String TRIM_VALUES
           
static String URL_PREFIX
           
static String ZIP_FILE_PREFIX
           
 
Constructor Summary
CsvDriver()
           
 
Method Summary
 boolean acceptsURL(String url)
           
 Connection connect(String url, Properties info)
           
 int getMajorVersion()
           
 int getMinorVersion()
           
 Logger getParentLogger()
           
 DriverPropertyInfo[] getPropertyInfo(String url, Properties info)
           
 boolean jdbcCompliant()
           
static void writeLog(String message)
           
static void writeToCsv(ResultSet resultSet, PrintStream out, boolean writeHeaderLine)
          Convenience method to write a ResultSet to a CSV file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_EXTENSION

public static final String DEFAULT_EXTENSION
See Also:
Constant Field Values

DEFAULT_SEPARATOR

public static final String DEFAULT_SEPARATOR
See Also:
Constant Field Values

DEFAULT_QUOTECHAR

public static final char DEFAULT_QUOTECHAR
See Also:
Constant Field Values

DEFAULT_HEADERLINE

public static final String DEFAULT_HEADERLINE

DEFAULT_SUPPRESS

public static final boolean DEFAULT_SUPPRESS
See Also:
Constant Field Values

DEFAULT_IS_HEADER_FIXED_WIDTH

public static final boolean DEFAULT_IS_HEADER_FIXED_WIDTH
See Also:
Constant Field Values

DEFAULT_TRIM_HEADERS

public static final boolean DEFAULT_TRIM_HEADERS
See Also:
Constant Field Values

DEFAULT_TRIM_VALUES

public static final boolean DEFAULT_TRIM_VALUES
See Also:
Constant Field Values

DEFAULT_COLUMN_TYPES

public static final String DEFAULT_COLUMN_TYPES
See Also:
Constant Field Values

DEFAULT_INDEXED_FILES

public static final boolean DEFAULT_INDEXED_FILES
See Also:
Constant Field Values

DEFAULT_TIMESTAMP_FORMAT

public static final String DEFAULT_TIMESTAMP_FORMAT

DEFAULT_DATE_FORMAT

public static final String DEFAULT_DATE_FORMAT
See Also:
Constant Field Values

DEFAULT_TIME_FORMAT

public static final String DEFAULT_TIME_FORMAT
See Also:
Constant Field Values

DEFAULT_COMMENT_CHAR

public static final String DEFAULT_COMMENT_CHAR

DEFAULT_SKIP_LEADING_LINES

public static final String DEFAULT_SKIP_LEADING_LINES

DEFAULT_IGNORE_UNPARSEABLE_LINES

public static final String DEFAULT_IGNORE_UNPARSEABLE_LINES
See Also:
Constant Field Values

DEFAULT_MISSING_VALUE

public static final String DEFAULT_MISSING_VALUE

DEFAULT_FILE_TAIL_PREPEND

public static final String DEFAULT_FILE_TAIL_PREPEND
See Also:
Constant Field Values

DEFAULT_DEFECTIVE_HEADERS

public static final String DEFAULT_DEFECTIVE_HEADERS
See Also:
Constant Field Values

DEFAULT_SKIP_LEADING_DATA_LINES

public static final String DEFAULT_SKIP_LEADING_DATA_LINES
See Also:
Constant Field Values

FILE_EXTENSION

public static final String FILE_EXTENSION
See Also:
Constant Field Values

SEPARATOR

public static final String SEPARATOR
See Also:
Constant Field Values

QUOTECHAR

public static final String QUOTECHAR
See Also:
Constant Field Values

HEADERLINE

public static final String HEADERLINE
See Also:
Constant Field Values

SUPPRESS_HEADERS

public static final String SUPPRESS_HEADERS
See Also:
Constant Field Values

IS_HEADER_FIXED_WIDTH

public static final String IS_HEADER_FIXED_WIDTH
See Also:
Constant Field Values

TRIM_HEADERS

public static final String TRIM_HEADERS
See Also:
Constant Field Values

TRIM_VALUES

public static final String TRIM_VALUES
See Also:
Constant Field Values

COLUMN_TYPES

public static final String COLUMN_TYPES
See Also:
Constant Field Values

INDEXED_FILES

public static final String INDEXED_FILES
See Also:
Constant Field Values

TIMESTAMP_FORMAT

public static final String TIMESTAMP_FORMAT
See Also:
Constant Field Values

DATE_FORMAT

public static final String DATE_FORMAT
See Also:
Constant Field Values

TIME_FORMAT

public static final String TIME_FORMAT
See Also:
Constant Field Values

LOCALE

public static final String LOCALE
See Also:
Constant Field Values

COMMENT_CHAR

public static final String COMMENT_CHAR
See Also:
Constant Field Values

SKIP_LEADING_LINES

public static final String SKIP_LEADING_LINES
See Also:
Constant Field Values

IGNORE_UNPARSEABLE_LINES

public static final String IGNORE_UNPARSEABLE_LINES
See Also:
Constant Field Values

MISSING_VALUE

public static final String MISSING_VALUE
See Also:
Constant Field Values

FILE_TAIL_PREPEND

public static final String FILE_TAIL_PREPEND
See Also:
Constant Field Values

DEFECTIVE_HEADERS

public static final String DEFECTIVE_HEADERS
See Also:
Constant Field Values

SKIP_LEADING_DATA_LINES

public static final String SKIP_LEADING_DATA_LINES
See Also:
Constant Field Values

TRANSPOSED_LINES

public static final String TRANSPOSED_LINES
See Also:
Constant Field Values

TRANSPOSED_FIELDS_TO_SKIP

public static final String TRANSPOSED_FIELDS_TO_SKIP
See Also:
Constant Field Values

CHARSET

public static final String CHARSET
See Also:
Constant Field Values

URL_PREFIX

public static final String URL_PREFIX
See Also:
Constant Field Values

CRYPTO_FILTER_CLASS_NAME

public static final String CRYPTO_FILTER_CLASS_NAME
See Also:
Constant Field Values

TIME_ZONE_NAME

public static final String TIME_ZONE_NAME
See Also:
Constant Field Values

DEFAULT_TIME_ZONE_NAME

public static final String DEFAULT_TIME_ZONE_NAME
See Also:
Constant Field Values

QUOTE_STYLE

public static final String QUOTE_STYLE
See Also:
Constant Field Values

DEFAULT_QUOTE_STYLE

public static final String DEFAULT_QUOTE_STYLE
See Also:
Constant Field Values

READER_CLASS_PREFIX

public static final String READER_CLASS_PREFIX
See Also:
Constant Field Values

ZIP_FILE_PREFIX

public static final String ZIP_FILE_PREFIX
See Also:
Constant Field Values

FIXED_WIDTHS

public static final String FIXED_WIDTHS
See Also:
Constant Field Values

FUNCTION

public static final String FUNCTION
See Also:
Constant Field Values
Constructor Detail

CsvDriver

public CsvDriver()
Method Detail

getPropertyInfo

public DriverPropertyInfo[] getPropertyInfo(String url,
                                            Properties info)
                                     throws SQLException
Specified by:
getPropertyInfo in interface Driver
Throws:
SQLException

getMajorVersion

public int getMajorVersion()
Specified by:
getMajorVersion in interface Driver

getMinorVersion

public int getMinorVersion()
Specified by:
getMinorVersion in interface Driver

connect

public Connection connect(String url,
                          Properties info)
                   throws SQLException
Specified by:
connect in interface Driver
Throws:
SQLException

acceptsURL

public boolean acceptsURL(String url)
                   throws SQLException
Specified by:
acceptsURL in interface Driver
Throws:
SQLException

jdbcCompliant

public boolean jdbcCompliant()
Specified by:
jdbcCompliant in interface Driver

getParentLogger

public Logger getParentLogger()
                       throws SQLFeatureNotSupportedException
Throws:
SQLFeatureNotSupportedException

writeLog

public static void writeLog(String message)

writeToCsv

public static void writeToCsv(ResultSet resultSet,
                              PrintStream out,
                              boolean writeHeaderLine)
                       throws SQLException
Convenience method to write a ResultSet to a CSV file. Output CSV file has the same format as the CSV file that is being queried, so that it can be used for later SQL queries.

Parameters:
resultSet - JDBC ResultSet to write.
out - open stream to write to.
writeHeaderLine - if true, the column names are written as first line.
Throws:
SQLException - if writing to CSV file fails.


Copyright © 2016. All rights reserved.