Package org.relique.jdbc.csv
Class CsvDriver
- java.lang.Object
-
- org.relique.jdbc.csv.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 Summary
Fields Modifier and Type Field Description static java.lang.String
CHARSET
static java.lang.String
COLUMN_TYPES
static java.lang.String
COMMENT_CHAR
static java.lang.String
CRYPTO_FILTER_CLASS_NAME
static java.lang.String
DATE_FORMAT
static java.lang.String
DEFAULT_COLUMN_TYPES
static java.lang.String
DEFAULT_COMMENT_CHAR
static java.lang.String
DEFAULT_DATE_FORMAT
static java.lang.String
DEFAULT_DEFECTIVE_HEADERS
static java.lang.String
DEFAULT_EXTENSION
static java.lang.String
DEFAULT_FILE_TAIL_PREPEND
static java.lang.String
DEFAULT_HEADERLINE
static java.lang.String
DEFAULT_IGNORE_UNPARSEABLE_LINES
static boolean
DEFAULT_INDEXED_FILES
static boolean
DEFAULT_IS_HEADER_FIXED_WIDTH
static java.lang.String
DEFAULT_MISSING_VALUE
static java.lang.String
DEFAULT_QUOTE_STYLE
static char
DEFAULT_QUOTECHAR
static java.lang.String
DEFAULT_SEPARATOR
static java.lang.String
DEFAULT_SKIP_LEADING_DATA_LINES
static java.lang.String
DEFAULT_SKIP_LEADING_LINES
static boolean
DEFAULT_SUPPRESS
static java.lang.String
DEFAULT_TIME_FORMAT
static java.lang.String
DEFAULT_TIME_ZONE_NAME
static java.lang.String
DEFAULT_TIMESTAMP_FORMAT
static boolean
DEFAULT_TRIM_HEADERS
static boolean
DEFAULT_TRIM_VALUES
static java.lang.String
DEFECTIVE_HEADERS
static java.lang.String
FILE_EXTENSION
static java.lang.String
FILE_TAIL_PREPEND
static java.lang.String
FIXED_WIDTHS
static java.lang.String
FUNCTION
static java.lang.String
HEADERLINE
static java.lang.String
IGNORE_UNPARSEABLE_LINES
static java.lang.String
INDEXED_FILES
static java.lang.String
IS_HEADER_FIXED_WIDTH
static java.lang.String
LOCALE
static java.lang.String
MISSING_VALUE
static java.lang.String
QUOTE_STYLE
static java.lang.String
QUOTECHAR
static java.lang.String
READER_CLASS_PREFIX
static java.lang.String
SEPARATOR
static java.lang.String
SKIP_LEADING_DATA_LINES
static java.lang.String
SKIP_LEADING_LINES
static java.lang.String
SUPPRESS_HEADERS
static java.lang.String
TIME_FORMAT
static java.lang.String
TIME_ZONE_NAME
static java.lang.String
TIMESTAMP_FORMAT
static java.lang.String
TRANSPOSED_FIELDS_TO_SKIP
static java.lang.String
TRANSPOSED_LINES
static java.lang.String
TRIM_HEADERS
static java.lang.String
TRIM_VALUES
static java.lang.String
URL_PREFIX
static java.lang.String
ZIP_FILE_PREFIX
-
Constructor Summary
Constructors Constructor Description CsvDriver()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
acceptsURL(java.lang.String url)
java.sql.Connection
connect(java.lang.String url, java.util.Properties info)
int
getMajorVersion()
int
getMinorVersion()
java.util.logging.Logger
getParentLogger()
java.sql.DriverPropertyInfo[]
getPropertyInfo(java.lang.String url, java.util.Properties info)
boolean
jdbcCompliant()
static void
writeLog(java.lang.String message)
static void
writeToCsv(java.sql.ResultSet resultSet, java.io.PrintStream out, boolean writeHeaderLine)
Convenience method to write a ResultSet to a CSV file.
-
-
-
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_QUOTECHAR
public static final char DEFAULT_QUOTECHAR
- See Also:
- Constant Field Values
-
DEFAULT_HEADERLINE
public static final java.lang.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 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
-
FILE_EXTENSION
public static final java.lang.String FILE_EXTENSION
- See Also:
- Constant Field Values
-
SEPARATOR
public static final java.lang.String SEPARATOR
- See Also:
- Constant Field Values
-
QUOTECHAR
public static final java.lang.String QUOTECHAR
- See Also:
- Constant Field Values
-
HEADERLINE
public static final java.lang.String HEADERLINE
- 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
-
TRIM_HEADERS
public static final java.lang.String TRIM_HEADERS
- See Also:
- Constant Field Values
-
TRIM_VALUES
public static final java.lang.String TRIM_VALUES
- See Also:
- Constant Field Values
-
COLUMN_TYPES
public static final java.lang.String COLUMN_TYPES
- See Also:
- Constant Field Values
-
INDEXED_FILES
public static final java.lang.String INDEXED_FILES
- See Also:
- Constant Field Values
-
TIMESTAMP_FORMAT
public static final java.lang.String TIMESTAMP_FORMAT
- See Also:
- Constant Field Values
-
DATE_FORMAT
public static final java.lang.String DATE_FORMAT
- See Also:
- Constant Field Values
-
TIME_FORMAT
public static final java.lang.String TIME_FORMAT
- See Also:
- Constant Field Values
-
LOCALE
public static final java.lang.String LOCALE
- See Also:
- Constant Field Values
-
COMMENT_CHAR
public static final java.lang.String COMMENT_CHAR
- 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
-
MISSING_VALUE
public static final java.lang.String MISSING_VALUE
- 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
-
CHARSET
public static final java.lang.String CHARSET
- See Also:
- Constant Field Values
-
URL_PREFIX
public static final java.lang.String URL_PREFIX
- See Also:
- Constant Field Values
-
CRYPTO_FILTER_CLASS_NAME
public static final java.lang.String CRYPTO_FILTER_CLASS_NAME
- See Also:
- Constant Field Values
-
TIME_ZONE_NAME
public static final java.lang.String TIME_ZONE_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
-
QUOTE_STYLE
public static final java.lang.String QUOTE_STYLE
- 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
-
ZIP_FILE_PREFIX
public static final java.lang.String ZIP_FILE_PREFIX
- See Also:
- Constant Field Values
-
FIXED_WIDTHS
public static final java.lang.String FIXED_WIDTHS
- See Also:
- Constant Field Values
-
FUNCTION
public static final java.lang.String FUNCTION
- See Also:
- Constant Field Values
-
-
Method Detail
-
getPropertyInfo
public java.sql.DriverPropertyInfo[] getPropertyInfo(java.lang.String url, java.util.Properties info) throws java.sql.SQLException
- Specified by:
getPropertyInfo
in interfacejava.sql.Driver
- Throws:
java.sql.SQLException
-
getMajorVersion
public int getMajorVersion()
- Specified by:
getMajorVersion
in interfacejava.sql.Driver
-
getMinorVersion
public int getMinorVersion()
- Specified by:
getMinorVersion
in interfacejava.sql.Driver
-
connect
public java.sql.Connection connect(java.lang.String url, java.util.Properties info) throws java.sql.SQLException
- Specified by:
connect
in interfacejava.sql.Driver
- Throws:
java.sql.SQLException
-
acceptsURL
public boolean acceptsURL(java.lang.String url) throws java.sql.SQLException
- Specified by:
acceptsURL
in interfacejava.sql.Driver
- Throws:
java.sql.SQLException
-
jdbcCompliant
public boolean jdbcCompliant()
- Specified by:
jdbcCompliant
in interfacejava.sql.Driver
-
getParentLogger
public java.util.logging.Logger getParentLogger() throws java.sql.SQLFeatureNotSupportedException
- Specified by:
getParentLogger
in interfacejava.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.
-
-