Class CsvDriver

  • All Implemented Interfaces:
    java.sql.Driver

    public class CsvDriver
    extends java.lang.Object
    implements java.sql.Driver
    This class implements the java.sql.Driver JDBC interface for the CsvJdbc driver.
    • Field Detail

      • DEFAULT_EXTENSION

        public static final java.lang.String DEFAULT_EXTENSION
        See Also:
        Constant Field Values
      • DEFAULT_SEPARATOR

        public static final java.lang.String DEFAULT_SEPARATOR
        See Also:
        Constant Field Values
      • DEFAULT_HEADERLINE

        public static final java.lang.String DEFAULT_HEADERLINE
      • DEFAULT_IS_HEADER_FIXED_WIDTH

        public static final boolean DEFAULT_IS_HEADER_FIXED_WIDTH
        See Also:
        Constant Field Values
      • DEFAULT_COLUMN_TYPES

        public static final java.lang.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 java.lang.String DEFAULT_TIMESTAMP_FORMAT
      • DEFAULT_DATE_FORMAT

        public static final java.lang.String DEFAULT_DATE_FORMAT
        See Also:
        Constant Field Values
      • DEFAULT_TIME_FORMAT

        public static final java.lang.String DEFAULT_TIME_FORMAT
        See Also:
        Constant Field Values
      • DEFAULT_COMMENT_CHAR

        public static final java.lang.String DEFAULT_COMMENT_CHAR
      • DEFAULT_SKIP_LEADING_LINES

        public static final java.lang.String DEFAULT_SKIP_LEADING_LINES
      • DEFAULT_IGNORE_UNPARSEABLE_LINES

        public static final java.lang.String DEFAULT_IGNORE_UNPARSEABLE_LINES
        See Also:
        Constant Field Values
      • DEFAULT_MISSING_VALUE

        public static final java.lang.String DEFAULT_MISSING_VALUE
      • DEFAULT_FILE_TAIL_PREPEND

        public static final java.lang.String DEFAULT_FILE_TAIL_PREPEND
        See Also:
        Constant Field Values
      • DEFAULT_DEFECTIVE_HEADERS

        public static final java.lang.String DEFAULT_DEFECTIVE_HEADERS
        See Also:
        Constant Field Values
      • DEFAULT_SKIP_LEADING_DATA_LINES

        public static final java.lang.String DEFAULT_SKIP_LEADING_DATA_LINES
        See Also:
        Constant Field Values
      • SUPPRESS_HEADERS

        public static final java.lang.String SUPPRESS_HEADERS
        See Also:
        Constant Field Values
      • IS_HEADER_FIXED_WIDTH

        public static final java.lang.String IS_HEADER_FIXED_WIDTH
        See Also:
        Constant Field Values
      • TIMESTAMP_FORMAT

        public static final java.lang.String TIMESTAMP_FORMAT
        See Also:
        Constant Field Values
      • SKIP_LEADING_LINES

        public static final java.lang.String SKIP_LEADING_LINES
        See Also:
        Constant Field Values
      • IGNORE_UNPARSEABLE_LINES

        public static final java.lang.String IGNORE_UNPARSEABLE_LINES
        See Also:
        Constant Field Values
      • FILE_TAIL_PREPEND

        public static final java.lang.String FILE_TAIL_PREPEND
        See Also:
        Constant Field Values
      • DEFECTIVE_HEADERS

        public static final java.lang.String DEFECTIVE_HEADERS
        See Also:
        Constant Field Values
      • SKIP_LEADING_DATA_LINES

        public static final java.lang.String SKIP_LEADING_DATA_LINES
        See Also:
        Constant Field Values
      • TRANSPOSED_LINES

        public static final java.lang.String TRANSPOSED_LINES
        See Also:
        Constant Field Values
      • TRANSPOSED_FIELDS_TO_SKIP

        public static final java.lang.String TRANSPOSED_FIELDS_TO_SKIP
        See Also:
        Constant Field Values
      • CRYPTO_FILTER_CLASS_NAME

        public static final java.lang.String CRYPTO_FILTER_CLASS_NAME
        See Also:
        Constant Field Values
      • DEFAULT_TIME_ZONE_NAME

        public static final java.lang.String DEFAULT_TIME_ZONE_NAME
        See Also:
        Constant Field Values
      • DEFAULT_QUOTE_STYLE

        public static final java.lang.String DEFAULT_QUOTE_STYLE
        See Also:
        Constant Field Values
      • READER_CLASS_PREFIX

        public static final java.lang.String READER_CLASS_PREFIX
        See Also:
        Constant Field Values
    • Constructor Detail

      • CsvDriver

        public CsvDriver()
    • Method Detail

      • getPropertyInfo

        public java.sql.DriverPropertyInfo[] getPropertyInfo​(java.lang.String url,
                                                             java.util.Properties info)
                                                      throws java.sql.SQLException
        Specified by:
        getPropertyInfo in interface java.sql.Driver
        Throws:
        java.sql.SQLException
      • getMajorVersion

        public int getMajorVersion()
        Specified by:
        getMajorVersion in interface java.sql.Driver
      • getMinorVersion

        public int getMinorVersion()
        Specified by:
        getMinorVersion in interface java.sql.Driver
      • connect

        public java.sql.Connection connect​(java.lang.String url,
                                           java.util.Properties info)
                                    throws java.sql.SQLException
        Specified by:
        connect in interface java.sql.Driver
        Throws:
        java.sql.SQLException
      • acceptsURL

        public boolean acceptsURL​(java.lang.String url)
                           throws java.sql.SQLException
        Specified by:
        acceptsURL in interface java.sql.Driver
        Throws:
        java.sql.SQLException
      • jdbcCompliant

        public boolean jdbcCompliant()
        Specified by:
        jdbcCompliant in interface java.sql.Driver
      • getParentLogger

        public java.util.logging.Logger getParentLogger()
                                                 throws java.sql.SQLFeatureNotSupportedException
        Specified by:
        getParentLogger in interface java.sql.Driver
        Throws:
        java.sql.SQLFeatureNotSupportedException
      • writeLog

        public static void writeLog​(java.lang.String message)
      • writeToCsv

        public static void writeToCsv​(java.sql.ResultSet resultSet,
                                      java.io.PrintStream out,
                                      boolean writeHeaderLine)
                               throws java.sql.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:
        java.sql.SQLException - if writing to CSV file fails.