From 803da958042521d5bbfbd077c0271ede5c2e0294 Mon Sep 17 00:00:00 2001 From: serge-rider Date: Tue, 29 Oct 2024 18:58:31 +0100 Subject: [PATCH] dbeaver/dbeaver#23361 Metadata and refactoring --- ...lConnection.java => LibSqlConnection.java} | 18 ++++---- ...SqlConstants.java => LibSqlConstants.java} | 2 +- ...aData.java => LibSqlDatabaseMetaData.java} | 6 +-- .../{LSqlDriver.java => LibSqlDriver.java} | 20 ++++---- ...SqlException.java => LibSqlException.java} | 18 ++++---- ...ment.java => LibSqlPreparedStatement.java} | 46 +++++++++---------- ...SqlResultSet.java => LibSqlResultSet.java} | 26 +++++------ ...Data.java => LibSqlResultSetMetaData.java} | 6 +-- ...SqlStatement.java => LibSqlStatement.java} | 16 +++---- .../jdbc/driver/libsql/client/LSqlClient.java | 12 ++--- ...Result.java => LibSqlExecutionResult.java} | 2 +- ...eaderInput.java => LibSqlReaderInput.java} | 4 +- ...treamInput.java => LibSqlStreamInput.java} | 4 +- .../META-INF/services/java.sql.Driver | 2 +- ...lDriverTest.java => LibSqlDriverTest.java} | 6 +-- 15 files changed, 94 insertions(+), 94 deletions(-) rename com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/{LSqlConnection.java => LibSqlConnection.java} (85%) rename com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/{LSqlConstants.java => LibSqlConstants.java} (97%) rename com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/{LSqlDatabaseMetaData.java => LibSqlDatabaseMetaData.java} (94%) rename com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/{LSqlDriver.java => LibSqlDriver.java} (89%) rename com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/{LSqlException.java => LibSqlException.java} (65%) rename com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/{LSqlPreparedStatement.java => LibSqlPreparedStatement.java} (82%) rename com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/{LSqlResultSet.java => LibSqlResultSet.java} (87%) rename com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/{LSqlResultSetMetaData.java => LibSqlResultSetMetaData.java} (93%) rename com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/{LSqlStatement.java => LibSqlStatement.java} (89%) rename com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/client/{LSqlExecutionResult.java => LibSqlExecutionResult.java} (97%) rename com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/client/{LSqlReaderInput.java => LibSqlReaderInput.java} (92%) rename com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/client/{LSqlStreamInput.java => LibSqlStreamInput.java} (93%) rename com.dbeaver.jdbc.driver.libsql/src/test/java/com/dbeaver/jdbc/upd/driver/test/{LSqlDriverTest.java => LibSqlDriverTest.java} (96%) diff --git a/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LSqlConnection.java b/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LibSqlConnection.java similarity index 85% rename from com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LSqlConnection.java rename to com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LibSqlConnection.java index d4bbe1e..2409e38 100644 --- a/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LSqlConnection.java +++ b/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LibSqlConnection.java @@ -29,18 +29,18 @@ import java.sql.Statement; import java.util.Map; -public class LSqlConnection extends AbstractJdbcConnection { +public class LibSqlConnection extends AbstractJdbcConnection { @NotNull - private final LSqlDriver driver; + private final LibSqlDriver driver; private final LSqlClient client; @NotNull private String url; @NotNull private Map driverProperties; - public LSqlConnection( - @NotNull LSqlDriver driver, + public LibSqlConnection( + @NotNull LibSqlDriver driver, @NotNull String url, @NotNull Map driverProperties ) throws SQLException { @@ -71,13 +71,13 @@ public Map getDriverProperties() { } @NotNull - public LSqlDriver getDriver() { + public LibSqlDriver getDriver() { return driver; } @Override public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { - return new LSqlStatement(this); + return new LibSqlStatement(this); } @Override @@ -86,8 +86,8 @@ public PreparedStatement prepareStatement(String sql, int resultSetType, int res } @NotNull - private LSqlPreparedStatement prepareStatementImpl(String sql) throws SQLException { - return new LSqlPreparedStatement(this, sql); + private LibSqlPreparedStatement prepareStatementImpl(String sql) throws SQLException { + return new LibSqlPreparedStatement(this, sql); } @Override @@ -101,7 +101,7 @@ public boolean isClosed() { @Override public DatabaseMetaData getMetaData() throws SQLException { - return new LSqlDatabaseMetaData(this); + return new LibSqlDatabaseMetaData(this); } } diff --git a/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LSqlConstants.java b/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LibSqlConstants.java similarity index 97% rename from com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LSqlConstants.java rename to com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LibSqlConstants.java index 1043bc4..8ec6233 100644 --- a/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LSqlConstants.java +++ b/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LibSqlConstants.java @@ -18,7 +18,7 @@ import java.util.regex.Pattern; -public class LSqlConstants { +public class LibSqlConstants { public static final Pattern CONNECTION_URL_EXAMPLE = Pattern.compile("jdbc:dbeaver:libsql:"); public static final Pattern CONNECTION_URL_PATTERN = Pattern.compile("jdbc:dbeaver:libsql:(.+)"); diff --git a/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LSqlDatabaseMetaData.java b/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LibSqlDatabaseMetaData.java similarity index 94% rename from com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LSqlDatabaseMetaData.java rename to com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LibSqlDatabaseMetaData.java index b8a73f3..75caf44 100644 --- a/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LSqlDatabaseMetaData.java +++ b/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LibSqlDatabaseMetaData.java @@ -27,12 +27,12 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -public class LSqlDatabaseMetaData extends AbstractJdbcDatabaseMetaData { +public class LibSqlDatabaseMetaData extends AbstractJdbcDatabaseMetaData { private static Pattern VERSION_PATTERN = Pattern.compile("(\\w+)\\s+([0-9.]+)\\s+(.+)"); private String serverVersion; - public LSqlDatabaseMetaData(@NotNull LSqlConnection connection) { + public LibSqlDatabaseMetaData(@NotNull LibSqlConnection connection) { super(connection, connection.getUrl()); } @@ -107,7 +107,7 @@ public ResultSet getTables(String catalog, String schemaPattern, String tableNam "SELECT NULL as TABLE_CAT, NULL AS TABLE_SCHEM," + "name AS TABLE_NAME,type as TABLE_TYPE, " + "NULL AS REMARKS, NULL AS TYPE_CAT, NULL AS TYPE_SCHEM, NULL AS TYPE_NAME " + - "FROM sqlite_master") + "FROM sqlite_master WHERE type='table'") ) { return dbStat.executeQuery(); } diff --git a/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LSqlDriver.java b/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LibSqlDriver.java similarity index 89% rename from com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LSqlDriver.java rename to com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LibSqlDriver.java index e269ad9..a5528f1 100644 --- a/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LSqlDriver.java +++ b/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LibSqlDriver.java @@ -25,17 +25,17 @@ import java.util.logging.Logger; import java.util.regex.Matcher; -public class LSqlDriver implements Driver { +public class LibSqlDriver implements Driver { static final java.util.logging.Logger parentLogger = java.util.logging.Logger.getLogger("com.dbeaver.jdbc.upd.driver.driver"); @Override public Connection connect(String url, Properties info) throws SQLException { - Matcher matcher = LSqlConstants.CONNECTION_URL_PATTERN.matcher(url); + Matcher matcher = LibSqlConstants.CONNECTION_URL_PATTERN.matcher(url); if (!matcher.matches()) { - throw new LSqlException( + throw new LibSqlException( "Invalid connection URL: " + url + - ".\nExpected URL format: " + LSqlConstants.CONNECTION_URL_EXAMPLE); + ".\nExpected URL format: " + LibSqlConstants.CONNECTION_URL_EXAMPLE); } String targetUrl = matcher.group(1); @@ -44,7 +44,7 @@ public Connection connect(String url, Properties info) throws SQLException { String propName = pne.toString(); props.put(propName, info.get(propName)); } - return new LSqlConnection(this, targetUrl, props); + return new LibSqlConnection(this, targetUrl, props); /* UPDEndpoint endpoint = new UPDEndpoint(); endpoint.setServerAddress(matcher.group(1)); @@ -122,7 +122,7 @@ private UPDProtocol openServerConnection( @Override public boolean acceptsURL(String url) { - return LSqlConstants.CONNECTION_URL_PATTERN.matcher(url).matches(); + return LibSqlConstants.CONNECTION_URL_PATTERN.matcher(url).matches(); } @Override @@ -134,12 +134,12 @@ public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws @Override public int getMajorVersion() { - return LSqlConstants.DRIVER_VERSION_MAJOR; + return LibSqlConstants.DRIVER_VERSION_MAJOR; } @Override public int getMinorVersion() { - return LSqlConstants.DRIVER_VERSION_MINOR; + return LibSqlConstants.DRIVER_VERSION_MINOR; } @Override @@ -153,10 +153,10 @@ public Logger getParentLogger() throws SQLFeatureNotSupportedException { } public String getDriverName() { - return LSqlConstants.DRIVER_NAME; + return LibSqlConstants.DRIVER_NAME; } public String getFullVersion() { - return getMajorVersion() + "." + getMinorVersion() + " (" + LSqlConstants.DRIVER_INFO + ")"; + return getMajorVersion() + "." + getMinorVersion() + " (" + LibSqlConstants.DRIVER_INFO + ")"; } } diff --git a/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LSqlException.java b/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LibSqlException.java similarity index 65% rename from com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LSqlException.java rename to com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LibSqlException.java index 5041718..c87d053 100644 --- a/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LSqlException.java +++ b/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LibSqlException.java @@ -18,35 +18,35 @@ import java.sql.SQLException; -public class LSqlException extends SQLException { - public LSqlException(String reason, String SQLState, int vendorCode) { +public class LibSqlException extends SQLException { + public LibSqlException(String reason, String SQLState, int vendorCode) { super(reason, SQLState, vendorCode); } - public LSqlException(String reason, String SQLState) { + public LibSqlException(String reason, String SQLState) { super(reason, SQLState); } - public LSqlException(String reason) { + public LibSqlException(String reason) { super(reason); } - public LSqlException() { + public LibSqlException() { } - public LSqlException(Throwable cause) { + public LibSqlException(Throwable cause) { super(cause); } - public LSqlException(String reason, Throwable cause) { + public LibSqlException(String reason, Throwable cause) { super(reason, cause); } - public LSqlException(String reason, String sqlState, Throwable cause) { + public LibSqlException(String reason, String sqlState, Throwable cause) { super(reason, sqlState, cause); } - public LSqlException(String reason, String sqlState, int vendorCode, Throwable cause) { + public LibSqlException(String reason, String sqlState, int vendorCode, Throwable cause) { super(reason, sqlState, vendorCode, cause); } } diff --git a/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LSqlPreparedStatement.java b/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LibSqlPreparedStatement.java similarity index 82% rename from com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LSqlPreparedStatement.java rename to com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LibSqlPreparedStatement.java index 0b5ca48..2fa8681 100644 --- a/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LSqlPreparedStatement.java +++ b/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LibSqlPreparedStatement.java @@ -16,8 +16,8 @@ */ package com.dbeaver.jdbc.driver.libsql; -import com.dbeaver.jdbc.driver.libsql.client.LSqlReaderInput; -import com.dbeaver.jdbc.driver.libsql.client.LSqlStreamInput; +import com.dbeaver.jdbc.driver.libsql.client.LibSqlReaderInput; +import com.dbeaver.jdbc.driver.libsql.client.LibSqlStreamInput; import org.jkiss.code.NotNull; import java.io.InputStream; @@ -27,10 +27,10 @@ import java.sql.*; import java.util.Calendar; -public class LSqlPreparedStatement extends LSqlStatement implements PreparedStatement { +public class LibSqlPreparedStatement extends LibSqlStatement implements PreparedStatement { - public LSqlPreparedStatement( - @NotNull LSqlConnection connection, String sql) throws SQLException { + public LibSqlPreparedStatement( + @NotNull LibSqlConnection connection, String sql) throws SQLException { super(connection); this.queryText = sql; } @@ -115,17 +115,17 @@ public void setTimestamp(int parameterIndex, Timestamp x) throws SQLException { @Override public void setAsciiStream(int parameterIndex, InputStream x, int length) throws SQLException { - this.addParameter(parameterIndex, new LSqlStreamInput(x, length)); + this.addParameter(parameterIndex, new LibSqlStreamInput(x, length)); } @Override public void setUnicodeStream(int parameterIndex, InputStream x, int length) throws SQLException { - this.addParameter(parameterIndex, new LSqlStreamInput(x, length)); + this.addParameter(parameterIndex, new LibSqlStreamInput(x, length)); } @Override public void setBinaryStream(int parameterIndex, InputStream x, int length) throws SQLException { - this.addParameter(parameterIndex, new LSqlStreamInput(x, length)); + this.addParameter(parameterIndex, new LibSqlStreamInput(x, length)); } @Override @@ -150,7 +150,7 @@ public void addBatch() throws SQLException { @Override public void setCharacterStream(int parameterIndex, Reader reader, int length) throws SQLException { - this.addParameter(parameterIndex, new LSqlReaderInput(reader, length)); + this.addParameter(parameterIndex, new LibSqlReaderInput(reader, length)); } @Override @@ -220,7 +220,7 @@ public void setNString(int parameterIndex, String value) throws SQLException { @Override public void setNCharacterStream(int parameterIndex, Reader value, long length) throws SQLException { - this.addParameter(parameterIndex, new LSqlReaderInput(value, length)); + this.addParameter(parameterIndex, new LibSqlReaderInput(value, length)); } @Override @@ -230,17 +230,17 @@ public void setNClob(int parameterIndex, NClob value) throws SQLException { @Override public void setClob(int parameterIndex, Reader reader, long length) throws SQLException { - this.addParameter(parameterIndex, new LSqlReaderInput(reader, length)); + this.addParameter(parameterIndex, new LibSqlReaderInput(reader, length)); } @Override public void setBlob(int parameterIndex, InputStream inputStream, long length) throws SQLException { - this.addParameter(parameterIndex, new LSqlStreamInput(inputStream, length)); + this.addParameter(parameterIndex, new LibSqlStreamInput(inputStream, length)); } @Override public void setNClob(int parameterIndex, Reader reader, long length) throws SQLException { - this.addParameter(parameterIndex, new LSqlReaderInput(reader, length)); + this.addParameter(parameterIndex, new LibSqlReaderInput(reader, length)); } @Override @@ -255,51 +255,51 @@ public void setObject(int parameterIndex, Object x, int targetSqlType, int scale @Override public void setAsciiStream(int parameterIndex, InputStream x, long length) throws SQLException { - this.addParameter(parameterIndex, new LSqlStreamInput(x, length)); + this.addParameter(parameterIndex, new LibSqlStreamInput(x, length)); } @Override public void setBinaryStream(int parameterIndex, InputStream x, long length) throws SQLException { - this.addParameter(parameterIndex, new LSqlStreamInput(x, length)); + this.addParameter(parameterIndex, new LibSqlStreamInput(x, length)); } @Override public void setCharacterStream(int parameterIndex, Reader reader, long length) throws SQLException { - this.addParameter(parameterIndex, new LSqlReaderInput(reader, length)); + this.addParameter(parameterIndex, new LibSqlReaderInput(reader, length)); } @Override public void setAsciiStream(int parameterIndex, InputStream x) throws SQLException { - this.addParameter(parameterIndex, new LSqlStreamInput(x, -1)); + this.addParameter(parameterIndex, new LibSqlStreamInput(x, -1)); } @Override public void setBinaryStream(int parameterIndex, InputStream x) throws SQLException { - this.addParameter(parameterIndex, new LSqlStreamInput(x, -1)); + this.addParameter(parameterIndex, new LibSqlStreamInput(x, -1)); } @Override public void setCharacterStream(int parameterIndex, Reader reader) throws SQLException { - this.addParameter(parameterIndex, new LSqlReaderInput(reader, -1)); + this.addParameter(parameterIndex, new LibSqlReaderInput(reader, -1)); } @Override public void setNCharacterStream(int parameterIndex, Reader value) throws SQLException { - this.addParameter(parameterIndex, new LSqlReaderInput(value, -1)); + this.addParameter(parameterIndex, new LibSqlReaderInput(value, -1)); } @Override public void setClob(int parameterIndex, Reader reader) throws SQLException { - this.addParameter(parameterIndex, new LSqlReaderInput(reader, -1)); + this.addParameter(parameterIndex, new LibSqlReaderInput(reader, -1)); } @Override public void setBlob(int parameterIndex, InputStream inputStream) throws SQLException { - this.addParameter(parameterIndex, new LSqlStreamInput(inputStream, -1)); + this.addParameter(parameterIndex, new LibSqlStreamInput(inputStream, -1)); } @Override public void setNClob(int parameterIndex, Reader reader) throws SQLException { - this.addParameter(parameterIndex, new LSqlReaderInput(reader, -1)); + this.addParameter(parameterIndex, new LibSqlReaderInput(reader, -1)); } } diff --git a/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LSqlResultSet.java b/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LibSqlResultSet.java similarity index 87% rename from com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LSqlResultSet.java rename to com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LibSqlResultSet.java index 01c9e99..ef2dce4 100644 --- a/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LSqlResultSet.java +++ b/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LibSqlResultSet.java @@ -16,7 +16,7 @@ */ package com.dbeaver.jdbc.driver.libsql; -import com.dbeaver.jdbc.driver.libsql.client.LSqlExecutionResult; +import com.dbeaver.jdbc.driver.libsql.client.LibSqlExecutionResult; import com.dbeaver.jdbc.model.AbstractJdbcResultSet; import org.jkiss.code.NotNull; import org.jkiss.utils.CommonUtils; @@ -29,26 +29,26 @@ import java.util.Locale; import java.util.Map; -public class LSqlResultSet extends AbstractJdbcResultSet { +public class LibSqlResultSet extends AbstractJdbcResultSet { @NotNull - private final LSqlExecutionResult result; + private final LibSqlExecutionResult result; private transient int cursor = 0; private transient boolean closed; private transient boolean wasNull; private transient Map nameMap; - public LSqlResultSet(@NotNull LSqlStatement statement, @NotNull LSqlExecutionResult result) { + public LibSqlResultSet(@NotNull LibSqlStatement statement, @NotNull LibSqlExecutionResult result) { super(statement, null); this.result = result; } @NotNull - public LSqlExecutionResult getResult() { + public LibSqlExecutionResult getResult() { return result; } - private int getColumnIndex(String columnLabel) throws LSqlException { + private int getColumnIndex(String columnLabel) throws LibSqlException { if (nameMap == null) { nameMap = new HashMap<>(); List columns = result.getColumns(); @@ -58,18 +58,18 @@ private int getColumnIndex(String columnLabel) throws LSqlException { } Integer index = nameMap.get(columnLabel.toUpperCase(Locale.ENGLISH)); if (index == null) { - throw new LSqlException("Column '" + columnLabel + "' is not present in result set"); + throw new LibSqlException("Column '" + columnLabel + "' is not present in result set"); } return index; } - private Object[] getCurrentRow() throws LSqlException { + private Object[] getCurrentRow() throws LibSqlException { List rows = result.getRows(); if (cursor < 1) { - throw new LSqlException("Fetch not started"); + throw new LibSqlException("Fetch not started"); } if (cursor > rows.size()) { - throw new LSqlException("Fetch ended"); + throw new LibSqlException("Fetch ended"); } return rows.get(cursor - 1); } @@ -265,9 +265,9 @@ public String getCursorName() throws SQLException { } @Override - public LSqlResultSetMetaData getMetaData() throws SQLException { + public LibSqlResultSetMetaData getMetaData() throws SQLException { if (metadata == null) { - metadata = new LSqlResultSetMetaData(this); + metadata = new LibSqlResultSetMetaData(this); } return metadata; } @@ -276,7 +276,7 @@ public LSqlResultSetMetaData getMetaData() throws SQLException { public Object getObject(int columnIndex) throws SQLException { Object[] currentRow = getCurrentRow(); if (columnIndex < 1 || columnIndex > currentRow.length) { - throw new LSqlException("Column index " + columnIndex + " is beyond range (1-" + currentRow.length + ")"); + throw new LibSqlException("Column index " + columnIndex + " is beyond range (1-" + currentRow.length + ")"); } Object value = currentRow[columnIndex - 1]; wasNull = (value == null); diff --git a/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LSqlResultSetMetaData.java b/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LibSqlResultSetMetaData.java similarity index 93% rename from com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LSqlResultSetMetaData.java rename to com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LibSqlResultSetMetaData.java index 981877d..2160c14 100644 --- a/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LSqlResultSetMetaData.java +++ b/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LibSqlResultSetMetaData.java @@ -22,12 +22,12 @@ import java.sql.SQLException; import java.sql.Types; -public class LSqlResultSetMetaData extends AbstractJdbcResultSetMetaData { +public class LibSqlResultSetMetaData extends AbstractJdbcResultSetMetaData { @NotNull - private final LSqlResultSet resultSet; + private final LibSqlResultSet resultSet; - public LSqlResultSetMetaData(@NotNull LSqlResultSet resultSet) throws SQLException { + public LibSqlResultSetMetaData(@NotNull LibSqlResultSet resultSet) throws SQLException { super(resultSet.getStatement()); this.resultSet = resultSet; } diff --git a/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LSqlStatement.java b/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LibSqlStatement.java similarity index 89% rename from com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LSqlStatement.java rename to com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LibSqlStatement.java index 2421c6d..a785326 100644 --- a/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LSqlStatement.java +++ b/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LibSqlStatement.java @@ -16,7 +16,7 @@ */ package com.dbeaver.jdbc.driver.libsql; -import com.dbeaver.jdbc.driver.libsql.client.LSqlExecutionResult; +import com.dbeaver.jdbc.driver.libsql.client.LibSqlExecutionResult; import com.dbeaver.jdbc.model.AbstractJdbcStatement; import org.jkiss.code.NotNull; import org.jkiss.code.Nullable; @@ -27,15 +27,15 @@ import java.util.LinkedHashMap; import java.util.Map; -public class LSqlStatement extends AbstractJdbcStatement { +public class LibSqlStatement extends AbstractJdbcStatement { protected String queryText; protected Map parameters = new LinkedHashMap<>(); - protected LSqlExecutionResult executionResult; - protected LSqlResultSet resultSet; + protected LibSqlExecutionResult executionResult; + protected LibSqlResultSet resultSet; - public LSqlStatement(@NotNull LSqlConnection connection) throws SQLException { + public LibSqlStatement(@NotNull LibSqlConnection connection) throws SQLException { super(connection); } @@ -113,7 +113,7 @@ public ResultSet getResultSet() throws SQLException { if (executionResult == null) { throw new SQLException("No result set was returned from server"); } - resultSet = new LSqlResultSet(this, executionResult); + resultSet = new LibSqlResultSet(this, executionResult); } return resultSet; } @@ -121,7 +121,7 @@ public ResultSet getResultSet() throws SQLException { @Override public int getUpdateCount() throws SQLException { if (executionResult == null) { - throw new LSqlException("No update count before statement execute"); + throw new LibSqlException("No update count before statement execute"); } return (int) executionResult.getUpdateCount(); } @@ -129,7 +129,7 @@ public int getUpdateCount() throws SQLException { @Override public long getLargeUpdateCount() throws SQLException { if (executionResult == null) { - throw new LSqlException("No update count before statement execute"); + throw new LibSqlException("No update count before statement execute"); } return executionResult.getUpdateCount(); } diff --git a/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/client/LSqlClient.java b/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/client/LSqlClient.java index 472e4dd..0730a40 100644 --- a/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/client/LSqlClient.java +++ b/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/client/LSqlClient.java @@ -1,6 +1,6 @@ package com.dbeaver.jdbc.driver.libsql.client; -import com.dbeaver.jdbc.driver.libsql.LSqlConstants; +import com.dbeaver.jdbc.driver.libsql.LibSqlConstants; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.Strictness; @@ -26,7 +26,7 @@ public class LSqlClient { private static final Gson gson = new GsonBuilder() .setStrictness(Strictness.LENIENT) - .setDateFormat(LSqlConstants.DEFAULT_ISO_TIMESTAMP_FORMAT) + .setDateFormat(LibSqlConstants.DEFAULT_ISO_TIMESTAMP_FORMAT) .setObjectToNumberStrategy(ToNumberPolicy.LONG_OR_DOUBLE) .create(); @@ -43,7 +43,7 @@ public LSqlClient(URL url, String authToken) { * * @return The result set. */ - public LSqlExecutionResult execute(String stmt, Map parameters) throws SQLException { + public LibSqlExecutionResult execute(String stmt, Map parameters) throws SQLException { return batch(new String[]{stmt}, new Map[]{ parameters })[0]; } @@ -53,7 +53,7 @@ public LSqlExecutionResult execute(String stmt, Map parameters) * @param stmts The SQL statements. * @return The result sets. */ - public LSqlExecutionResult[] batch(String[] stmts, Map[] parameters) throws SQLException { + public LibSqlExecutionResult[] batch(String[] stmts, Map[] parameters) throws SQLException { try { HttpURLConnection conn = openConnection(); conn.setRequestMethod("POST"); @@ -65,7 +65,7 @@ public LSqlExecutionResult[] batch(String[] stmts, Map[] paramet try (InputStreamReader in = new InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8)) { //String responseStr = IOUtils.readToString(in); Response[] response = gson.fromJson(in, Response[].class); - LSqlExecutionResult[] resultSets = new LSqlExecutionResult[response.length]; + LibSqlExecutionResult[] resultSets = new LibSqlExecutionResult[response.length]; for (int i = 0; i < response.length; i++) { if (!CommonUtils.isEmpty(response[i].error)) { throw new SQLException(response[i].error); @@ -172,7 +172,7 @@ private static void serializeParameterValue(Object value, JsonWriter jsonWriter) private static class Response { public String error; - public LSqlExecutionResult results; + public LibSqlExecutionResult results; } } \ No newline at end of file diff --git a/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/client/LSqlExecutionResult.java b/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/client/LibSqlExecutionResult.java similarity index 97% rename from com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/client/LSqlExecutionResult.java rename to com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/client/LibSqlExecutionResult.java index 76457b6..3305e1c 100644 --- a/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/client/LSqlExecutionResult.java +++ b/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/client/LibSqlExecutionResult.java @@ -18,7 +18,7 @@ import java.util.List; -public class LSqlExecutionResult { +public class LibSqlExecutionResult { private List columns; private List rows; diff --git a/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/client/LSqlReaderInput.java b/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/client/LibSqlReaderInput.java similarity index 92% rename from com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/client/LSqlReaderInput.java rename to com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/client/LibSqlReaderInput.java index ee59a05..0d28338 100644 --- a/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/client/LSqlReaderInput.java +++ b/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/client/LibSqlReaderInput.java @@ -21,11 +21,11 @@ import java.io.IOException; import java.io.Reader; -public class LSqlReaderInput { +public class LibSqlReaderInput { private Reader stream; private long length; - public LSqlReaderInput(Reader stream, long length) { + public LibSqlReaderInput(Reader stream, long length) { this.stream = stream; this.length = length; } diff --git a/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/client/LSqlStreamInput.java b/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/client/LibSqlStreamInput.java similarity index 93% rename from com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/client/LSqlStreamInput.java rename to com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/client/LibSqlStreamInput.java index 62674f0..9f0d3f9 100644 --- a/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/client/LSqlStreamInput.java +++ b/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/client/LibSqlStreamInput.java @@ -21,11 +21,11 @@ import java.io.InputStream; import java.nio.charset.StandardCharsets; -public class LSqlStreamInput { +public class LibSqlStreamInput { private InputStream stream; private long length; - public LSqlStreamInput(InputStream stream, long length) { + public LibSqlStreamInput(InputStream stream, long length) { this.stream = stream; this.length = length; } diff --git a/com.dbeaver.jdbc.driver.libsql/src/main/resources/META-INF/services/java.sql.Driver b/com.dbeaver.jdbc.driver.libsql/src/main/resources/META-INF/services/java.sql.Driver index c4a7907..93970c0 100644 --- a/com.dbeaver.jdbc.driver.libsql/src/main/resources/META-INF/services/java.sql.Driver +++ b/com.dbeaver.jdbc.driver.libsql/src/main/resources/META-INF/services/java.sql.Driver @@ -1 +1 @@ -com.dbeaver.jdbc.driver.libsql.LSqlDriver +com.dbeaver.jdbc.driver.libsql.LibSqlDriver diff --git a/com.dbeaver.jdbc.driver.libsql/src/test/java/com/dbeaver/jdbc/upd/driver/test/LSqlDriverTest.java b/com.dbeaver.jdbc.driver.libsql/src/test/java/com/dbeaver/jdbc/upd/driver/test/LibSqlDriverTest.java similarity index 96% rename from com.dbeaver.jdbc.driver.libsql/src/test/java/com/dbeaver/jdbc/upd/driver/test/LSqlDriverTest.java rename to com.dbeaver.jdbc.driver.libsql/src/test/java/com/dbeaver/jdbc/upd/driver/test/LibSqlDriverTest.java index 558c60c..6e6fe54 100644 --- a/com.dbeaver.jdbc.driver.libsql/src/test/java/com/dbeaver/jdbc/upd/driver/test/LSqlDriverTest.java +++ b/com.dbeaver.jdbc.driver.libsql/src/test/java/com/dbeaver/jdbc/upd/driver/test/LibSqlDriverTest.java @@ -16,17 +16,17 @@ */ package com.dbeaver.jdbc.upd.driver.test; -import com.dbeaver.jdbc.driver.libsql.LSqlDriver; +import com.dbeaver.jdbc.driver.libsql.LibSqlDriver; import java.sql.*; import java.util.Properties; -public class LSqlDriverTest { +public class LibSqlDriverTest { public static void main(String[] args) throws Exception { long startTime = System.currentTimeMillis(); try { - LSqlDriver driver = new LSqlDriver(); + LibSqlDriver driver = new LibSqlDriver(); Properties props = new Properties(); try (Connection connection = driver.connect("jdbc:dbeaver:libsql:" + args[0], props)) { DatabaseMetaData metaData = connection.getMetaData();