From 6f88ce6f68c54bfda9d8c2976afabb02a2a364ed Mon Sep 17 00:00:00 2001 From: Manfred Riem Date: Mon, 22 Apr 2024 16:14:08 -0500 Subject: [PATCH] Fixes #99 - Implement CSVDriver.createStatement --- .../java/com/manorrock/guppy/csv/CSV2SQL.java | 42 --- .../manorrock/guppy/csv/CSVConnection.java | 2 +- .../com/manorrock/guppy/csv/CSVStatement.java | 261 ++++++++++++++++++ 3 files changed, 262 insertions(+), 43 deletions(-) delete mode 100644 csv/src/main/java/com/manorrock/guppy/csv/CSV2SQL.java create mode 100644 csv/src/main/java/com/manorrock/guppy/csv/CSVStatement.java diff --git a/csv/src/main/java/com/manorrock/guppy/csv/CSV2SQL.java b/csv/src/main/java/com/manorrock/guppy/csv/CSV2SQL.java deleted file mode 100644 index 03372e6..0000000 --- a/csv/src/main/java/com/manorrock/guppy/csv/CSV2SQL.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2002-2020, Manorrock.com. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.manorrock.guppy.csv; - -/** - * The CSV-to-SQL utility. - * - * @author Manfred Riem (mriem@manorrock.com) - */ -public class CSV2SQL { - - /** - * Main. - * - * @param arguments the command-line arguments. - */ - public static void main(String[] arguments) { - } -} diff --git a/csv/src/main/java/com/manorrock/guppy/csv/CSVConnection.java b/csv/src/main/java/com/manorrock/guppy/csv/CSVConnection.java index b1e8e1c..d53bbe1 100644 --- a/csv/src/main/java/com/manorrock/guppy/csv/CSVConnection.java +++ b/csv/src/main/java/com/manorrock/guppy/csv/CSVConnection.java @@ -63,7 +63,7 @@ public CSVConnection(String url, Properties info) { @Override public Statement createStatement() throws SQLException { - throw new UnsupportedOperationException("Not supported yet."); + return new CSVStatement(); } @Override diff --git a/csv/src/main/java/com/manorrock/guppy/csv/CSVStatement.java b/csv/src/main/java/com/manorrock/guppy/csv/CSVStatement.java new file mode 100644 index 0000000..9d74c04 --- /dev/null +++ b/csv/src/main/java/com/manorrock/guppy/csv/CSVStatement.java @@ -0,0 +1,261 @@ +/* + * Copyright (c) 2002-2024, Manorrock.com. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +package com.manorrock.guppy.csv; + +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.SQLWarning; +import java.sql.Statement; + +/** + * The CSV JDBC statement. + * + * @author Manfred Riem (mriem@manorrock.com) + */ +public class CSVStatement implements Statement { + + @Override + public ResultSet executeQuery(String sql) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int executeUpdate(String sql) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void close() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getMaxFieldSize() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setMaxFieldSize(int max) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getMaxRows() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setMaxRows(int max) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setEscapeProcessing(boolean enable) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getQueryTimeout() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setQueryTimeout(int seconds) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void cancel() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public SQLWarning getWarnings() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void clearWarnings() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setCursorName(String name) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean execute(String sql) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public ResultSet getResultSet() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getUpdateCount() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean getMoreResults() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setFetchDirection(int direction) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getFetchDirection() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setFetchSize(int rows) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getFetchSize() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getResultSetConcurrency() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getResultSetType() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void addBatch(String sql) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void clearBatch() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int[] executeBatch() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Connection getConnection() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean getMoreResults(int current) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public ResultSet getGeneratedKeys() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int executeUpdate(String sql, int[] columnIndexes) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int executeUpdate(String sql, String[] columnNames) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean execute(String sql, int autoGeneratedKeys) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean execute(String sql, int[] columnIndexes) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean execute(String sql, String[] columnNames) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getResultSetHoldability() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isClosed() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setPoolable(boolean poolable) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isPoolable() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void closeOnCompletion() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isCloseOnCompletion() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public T unwrap(Class iface) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isWrapperFor(Class iface) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + +}