From 2514b6b6dff3743c868e64b61565c631a340ee76 Mon Sep 17 00:00:00 2001 From: Serge Rider Date: Sun, 8 Dec 2024 16:44:56 +0100 Subject: [PATCH] dbeaver/pro#3793 Back to roots (11) --- .../META-INF/MANIFEST.MF | 2 +- .../jdbc/driver/libsql/LibSqlResultSet.java | 8 ++--- .../libsql/LibSqlResultSetMetaData.java | 32 ++++++++++++------- .../driver/libsql/client/LibSqlClient.java | 16 ++++++---- pom.xml | 12 +++++++ 5 files changed, 47 insertions(+), 23 deletions(-) diff --git a/com.dbeaver.jdbc.driver.libsql/META-INF/MANIFEST.MF b/com.dbeaver.jdbc.driver.libsql/META-INF/MANIFEST.MF index a0c152e..d6cde7d 100644 --- a/com.dbeaver.jdbc.driver.libsql/META-INF/MANIFEST.MF +++ b/com.dbeaver.jdbc.driver.libsql/META-INF/MANIFEST.MF @@ -4,7 +4,7 @@ Bundle-Name: DBeaver LibSQL JDBC Driver Bundle-SymbolicName: com.dbeaver.jdbc.driver.libsql Bundle-Version: 1.0.3.qualifier Bundle-Release-Date: 20230522 -Bundle-RequiredExecutionEnvironment: JavaSE-17 +Bundle-RequiredExecutionEnvironment: JavaSE-11 Export-Package: com.dbeaver.jdbc.driver.libsql, com.dbeaver.jdbc.driver.libsql.client Require-Bundle: com.dbeaver.jdbc.api, diff --git a/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LibSqlResultSet.java b/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LibSqlResultSet.java index a24f11f..69a066d 100644 --- a/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LibSqlResultSet.java +++ b/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LibSqlResultSet.java @@ -134,8 +134,8 @@ public double getDouble(int columnIndex) throws SQLException { public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException { Object object = getObject(columnIndex); return object == null ? null : - object instanceof BigDecimal bd ? bd : - object instanceof Long str ? BigDecimal.valueOf(str) : BigDecimal.valueOf(CommonUtils.toDouble(object)); + object instanceof BigDecimal ? (BigDecimal) object : + object instanceof Long ? BigDecimal.valueOf((Long) object) : BigDecimal.valueOf(CommonUtils.toDouble(object)); } @Override @@ -221,8 +221,8 @@ public double getDouble(String columnLabel) throws SQLException { public BigDecimal getBigDecimal(String columnLabel, int scale) throws SQLException { Object object = getObject(columnLabel); return object == null ? null : - object instanceof BigDecimal bd ? bd : - object instanceof Long str ? BigDecimal.valueOf(str) : BigDecimal.valueOf(CommonUtils.toDouble(object)); + object instanceof BigDecimal ? (BigDecimal) object : + object instanceof Long ? BigDecimal.valueOf((Long) object) : BigDecimal.valueOf(CommonUtils.toDouble(object)); } @Override diff --git a/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LibSqlResultSetMetaData.java b/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LibSqlResultSetMetaData.java index f11ea6c..0ff9253 100644 --- a/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LibSqlResultSetMetaData.java +++ b/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LibSqlResultSetMetaData.java @@ -137,22 +137,30 @@ public String getTableName(int column) throws SQLException { @Override public int getColumnType(int column) throws SQLException { - return switch (getDataTypeFromData(column)) { - case BOOLEAN -> Types.BOOLEAN; - case NUMBER -> Types.NUMERIC; - case STRING -> Types.VARCHAR; - default -> Types.OTHER; - }; + switch (getDataTypeFromData(column)) { + case BOOLEAN: + return Types.BOOLEAN; + case NUMBER: + return Types.NUMERIC; + case STRING: + return Types.VARCHAR; + default: + return Types.OTHER; + } } @Override public String getColumnTypeName(int column) throws SQLException { - return switch (getDataTypeFromData(column)) { - case BOOLEAN -> "BOOLEAN"; - case NUMBER -> "NUMERIC"; - case STRING -> "VARCHAR"; - default -> "UNKNOWN"; - }; + switch (getDataTypeFromData(column)) { + case BOOLEAN: + return "BOOLEAN"; + case NUMBER: + return "NUMERIC"; + case STRING: + return "VARCHAR"; + default: + return "UNKNOWN"; + } } @Override diff --git a/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/client/LibSqlClient.java b/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/client/LibSqlClient.java index e5a3876..7e1fab7 100644 --- a/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/client/LibSqlClient.java +++ b/com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/client/LibSqlClient.java @@ -133,15 +133,16 @@ public LibSqlExecutionResult[] executeBatch( } } catch (Exception e) { switch (httpResponse.statusCode()) { - case HttpURLConnection.HTTP_UNAUTHORIZED -> + case HttpURLConnection.HTTP_UNAUTHORIZED: throw new SQLException("Authentication required", e); - case HttpURLConnection.HTTP_FORBIDDEN -> + case HttpURLConnection.HTTP_FORBIDDEN: throw new SQLException("Access denied", e); } throw e; } } catch (Exception e) { - if (e instanceof SQLException sqle) { + if (e instanceof SQLException) { + SQLException sqle = (SQLException) e; throw sqle; } throw new SQLException(e); @@ -217,11 +218,14 @@ private boolean isIndexedParams(Map parameter) { private static void serializeParameterValue(Object value, JsonWriter jsonWriter) throws IOException { if (value == null) { jsonWriter.nullValue(); - } else if (value instanceof Number nValue) { + } else if (value instanceof Number) { + Number nValue = (Number) value; jsonWriter.value(nValue); - } else if (value instanceof Boolean bValue) { + } else if (value instanceof Boolean) { + Boolean bValue = (Boolean) value; jsonWriter.value(bValue); - } else if (value instanceof String strValue) { + } else if (value instanceof String) { + String strValue = (String) value; jsonWriter.value(strValue); } else { jsonWriter.value(value.toString()); diff --git a/pom.xml b/pom.xml index a6a3c91..1bc03ac 100644 --- a/pom.xml +++ b/pom.xml @@ -63,6 +63,18 @@ ${project.basedir}/src/test/java + + + org.eclipse.tycho + tycho-compiler-plugin + ${tycho-version} + + false + ${java.version.min} + ${java.version.min} + ${java.version.min} + + org.apache.maven.plugins maven-surefire-plugin