Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
- uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: 11
java-version: 17
java-package: jdk
cache: 'maven'
- name: spotless:check
Expand All @@ -53,7 +53,7 @@ jobs:
- uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: 11
java-version: 17
java-package: jdk
cache: 'maven'
- name: Download and install signatures jar
Expand Down Expand Up @@ -226,7 +226,7 @@ jobs:
uses: actions/setup-java@v5
with: # running setup-java again overwrites the settings.xml
distribution: 'temurin'
java-version: '11'
java-version: '17'
java-package: jdk
server-id: central # Value of the distributionManagement/repository/id field of the pom.xml
server-username: MAVEN_CENTRAL_USERNAME # env variable for username in deploy (1)
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.15.0</version>
<configuration>
<release>8</release>
<release>17</release>
</configuration>
<executions>
<execution>
Expand Down
9 changes: 4 additions & 5 deletions src/main/java/org/sqlite/SQLiteConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,7 @@ public void apply(Connection conn) throws SQLException {
pragmaParams.add(each.pragmaName);
}

if (conn instanceof SQLiteConnection) {
SQLiteConnection sqliteConn = (SQLiteConnection) conn;
if (conn instanceof SQLiteConnection sqliteConn) {
sqliteConn.setLimit(
SQLiteLimits.SQLITE_LIMIT_ATTACHED,
parseLimitPragma(Pragma.LIMIT_ATTACHED, DEFAULT_MAX_ATTACHED));
Expand Down Expand Up @@ -204,7 +203,7 @@ public void apply(Connection conn) throws SQLException {
} else {
passwordPragma = "pragma key = '%s'";
}
stat.execute(String.format(passwordPragma, password.replace("'", "''")));
stat.execute(passwordPragma.formatted(password.replace("'", "''")));
stat.execute("select 1 from sqlite_schema");
}
}
Expand All @@ -217,7 +216,7 @@ public void apply(Connection conn) throws SQLException {

String value = pragmaTable.getProperty(key);
if (value != null) {
stat.execute(String.format("pragma %s=%s", key, value));
stat.execute("pragma %s=%s".formatted(key, value));
}
}
} finally {
Expand Down Expand Up @@ -1070,7 +1069,7 @@ public void setTempStore(TempStore storeType) {
* href="https://www.sqlite.org/pragma.html#pragma_temp_store_directory">www.sqlite.org/pragma.html#pragma_temp_store_directory</a>
*/
public void setTempStoreDirectory(String directoryName) {
setPragma(Pragma.TEMP_STORE_DIRECTORY, String.format("'%s'", directoryName));
setPragma(Pragma.TEMP_STORE_DIRECTORY, "'%s'".formatted(directoryName));
}

/**
Expand Down
9 changes: 4 additions & 5 deletions src/main/java/org/sqlite/SQLiteConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -241,14 +241,14 @@ private static DB open(String url, String origFileName, Properties props) throws
resourceAddr = new URL(resourceName);
} catch (MalformedURLException e) {
throw new SQLException(
String.format("resource %s not found: %s", resourceName, e));
"resource %s not found: %s".formatted(resourceName, e));
}
}

try {
fileName = extractResource(resourceAddr).getAbsolutePath();
} catch (IOException e) {
throw new SQLException(String.format("failed to load %s: %s", resourceName, e));
throw new SQLException("failed to load %s: %s".formatted(resourceName, e));
}
} else {
fileName = new File(fileName).getAbsolutePath();
Expand Down Expand Up @@ -286,7 +286,7 @@ private static File extractResource(URL resourceAddr) throws IOException {
}

String tempFolder = new File(System.getProperty("java.io.tmpdir")).getAbsolutePath();
String dbFileName = String.format("sqlite-jdbc-tmp-%s.db", UUID.randomUUID());
String dbFileName = "sqlite-jdbc-tmp-%s.db".formatted(UUID.randomUUID());
File dbFile = new File(tempFolder, dbFileName);

if (dbFile.exists()) {
Expand Down Expand Up @@ -525,8 +525,7 @@ protected static String extractPragmasFromFilename(String url, String filename,
if (SQLiteConfig.pragmaSet.contains(key)) {
if (kvp.length == 1) {
throw new SQLException(
String.format(
"Please specify a value for PRAGMA %s in URL %s", key, url));
"Please specify a value for PRAGMA %s in URL %s".formatted(key, url));
}
String value = kvp[1].trim();
if (!value.isEmpty()) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/sqlite/SQLiteErrorCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,6 @@ public static SQLiteErrorCode getErrorCode(int errorCode) {
/** @see java.lang.Enum#toString() */
@Override
public String toString() {
return String.format("[%s] %s", this.name(), message);
return "[%s] %s".formatted(this.name(), message);
}
}
15 changes: 6 additions & 9 deletions src/main/java/org/sqlite/SQLiteJDBCLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import java.net.URLConnection;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.security.DigestInputStream;
import java.security.MessageDigest;
Expand Down Expand Up @@ -99,7 +98,7 @@ static void cleanup() {
.startsWith(searchPattern))
.forEach(
nativeLib -> {
Path lckFile = Paths.get(nativeLib + LOCK_EXT);
Path lckFile = Path.of(nativeLib + LOCK_EXT);
if (Files.notExists(lckFile)) {
try {
Files.delete(nativeLib);
Expand Down Expand Up @@ -186,11 +185,11 @@ private static boolean extractAndLoadLibraryFile(
// when multiple JVMs with different architectures running at the same time
String uuid = UUID.randomUUID().toString();
String extractedLibFileName =
String.format("sqlite-%s-%s-%s", getVersion(), uuid, libraryFileName);
"sqlite-%s-%s-%s".formatted(getVersion(), uuid, libraryFileName);
String extractedLckFileName = extractedLibFileName + LOCK_EXT;

Path extractedLibFile = Paths.get(targetFolder, extractedLibFileName);
Path extractedLckFile = Paths.get(targetFolder, extractedLckFileName);
Path extractedLibFile = Path.of(targetFolder, extractedLibFileName);
Path extractedLckFile = Path.of(targetFolder, extractedLckFileName);

try {
// Extract a native library file into the target directory
Expand All @@ -217,8 +216,7 @@ private static boolean extractAndLoadLibraryFile(
InputStream extractedLibIn = Files.newInputStream(extractedLibFile)) {
if (!contentsEquals(nativeIn, extractedLibIn)) {
throw new FileException(
String.format(
"Failed to write a native library file at %s",
"Failed to write a native library file at %s".formatted(
extractedLibFile));
}
}
Expand Down Expand Up @@ -362,8 +360,7 @@ private static void loadSQLiteNativeLibrary() throws Exception {

extracted = false;
throw new NativeLibraryNotFoundException(
String.format(
"No native library found for os.name=%s, os.arch=%s, paths=[%s]",
"No native library found for os.name=%s, os.arch=%s, paths=[%s]".formatted(
OSInfo.getOSName(),
OSInfo.getArchName(),
StringUtils.join(triedPaths, File.pathSeparator)));
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/sqlite/core/CoreDatabaseMetaData.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ protected static String quote(String tableName) {
if (tableName == null) {
return "null";
} else {
return String.format("'%s'", tableName);
return "'%s'".formatted(tableName);
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/sqlite/core/CorePreparedStatement.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ public long[] executeLargeBatch() throws SQLException {
return new long[] {};
}

if (this.conn instanceof JDBC3Connection) {
((JDBC3Connection) this.conn).tryEnforceTransactionMode();
if (this.conn instanceof JDBC3Connection connection) {
connection.tryEnforceTransactionMode();
}

return this.withConnectionTimeout(
Expand Down Expand Up @@ -120,11 +120,11 @@ protected void setDateByMilliseconds(int pos, Long value, Calendar calendar)

case REAL:
// long to Julian date
batch(pos, new Double((value / 86400000.0) + 2440587.5));
batch(pos, Double.valueOf((value / 86400000.0) + 2440587.5));
break;

default: // INTEGER:
batch(pos, new Long(value / config.getDateMultiplier()));
batch(pos, Long.valueOf(value / config.getDateMultiplier()));
}
}
}
8 changes: 4 additions & 4 deletions src/main/java/org/sqlite/core/CoreStatement.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ protected boolean exec() throws SQLException {
if (sql == null) throw new SQLException("SQLiteJDBC internal error: sql==null");
if (rs.isOpen()) throw new SQLException("SQLite JDBC internal error: rs.isOpen() on exec.");

if (this.conn instanceof JDBC3Connection) {
((JDBC3Connection) this.conn).tryEnforceTransactionMode();
if (this.conn instanceof JDBC3Connection connection) {
connection.tryEnforceTransactionMode();
}

boolean success = false;
Expand Down Expand Up @@ -113,8 +113,8 @@ protected boolean exec(String sql) throws SQLException {
if (sql == null) throw new SQLException("SQLiteJDBC internal error: sql==null");
if (rs.isOpen()) throw new SQLException("SQLite JDBC internal error: rs.isOpen() on exec.");

if (this.conn instanceof JDBC3Connection) {
((JDBC3Connection) this.conn).tryEnforceTransactionMode();
if (this.conn instanceof JDBC3Connection connection) {
connection.tryEnforceTransactionMode();
}

boolean rc = false;
Expand Down
32 changes: 16 additions & 16 deletions src/main/java/org/sqlite/core/DB.java
Original file line number Diff line number Diff line change
Expand Up @@ -882,20 +882,20 @@ final synchronized int sqlbind(long stmt, int pos, Object v) throws SQLException
pos++;
if (v == null) {
return bind_null(stmt, pos);
} else if (v instanceof Integer) {
return bind_int(stmt, pos, (Integer) v);
} else if (v instanceof Short) {
return bind_int(stmt, pos, ((Short) v).intValue());
} else if (v instanceof Long) {
return bind_long(stmt, pos, (Long) v);
} else if (v instanceof Float) {
return bind_double(stmt, pos, ((Float) v).doubleValue());
} else if (v instanceof Double) {
return bind_double(stmt, pos, (Double) v);
} else if (v instanceof String) {
return bind_text(stmt, pos, (String) v);
} else if (v instanceof byte[]) {
return bind_blob(stmt, pos, (byte[]) v);
} else if (v instanceof Integer integer) {
return bind_int(stmt, pos, integer);
} else if (v instanceof Short short1) {
return bind_int(stmt, pos, short1.intValue());
} else if (v instanceof Long long1) {
return bind_long(stmt, pos, long1);
} else if (v instanceof Float float1) {
return bind_double(stmt, pos, float1.doubleValue());
} else if (v instanceof Double double1) {
return bind_double(stmt, pos, double1);
} else if (v instanceof String string) {
return bind_text(stmt, pos, string);
} else if (v instanceof byte[] bytes) {
return bind_blob(stmt, pos, bytes);
} else {
throw new SQLException("unexpected param type: " + v.getClass());
}
Expand Down Expand Up @@ -1175,9 +1175,9 @@ public static SQLiteException newSQLException(int errorCode, String errorMessage
SQLiteErrorCode code = SQLiteErrorCode.getErrorCode(errorCode);
String msg;
if (code == SQLiteErrorCode.UNKNOWN_ERROR) {
msg = String.format("%s:%s (%s)", code, errorCode, errorMessage);
msg = "%s:%s (%s)".formatted(code, errorCode, errorMessage);
} else {
msg = String.format("%s (%s)", code, errorMessage);
msg = "%s (%s)".formatted(code, errorMessage);
}
return new SQLiteException(msg, code);
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/sqlite/date/FastDateFormat.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package org.sqlite.date;

import java.io.Serial;
import java.text.DateFormat;
import java.text.FieldPosition;
import java.text.Format;
Expand Down Expand Up @@ -70,7 +71,7 @@ public class FastDateFormat extends Format implements DateParser, DatePrinter {
*
* @see java.io.Serializable
*/
private static final long serialVersionUID = 2L;
@Serial private static final long serialVersionUID = 2L;

/** FULL locale dependent date or time style. */
public static final int FULL = DateFormat.FULL;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/sqlite/date/FastDateParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.Serial;
import java.io.Serializable;
import java.text.DateFormatSymbols;
import java.text.ParseException;
Expand Down Expand Up @@ -71,7 +72,7 @@ public class FastDateParser implements DateParser, Serializable {
*
* @see java.io.Serializable
*/
private static final long serialVersionUID = 2L;
@Serial private static final long serialVersionUID = 2L;

static final Locale JAPANESE_IMPERIAL = new Locale("ja", "JP", "JP");

Expand Down
18 changes: 9 additions & 9 deletions src/main/java/org/sqlite/date/FastDatePrinter.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.Serial;
import java.io.Serializable;
import java.text.DateFormat;
import java.text.DateFormatSymbols;
Expand Down Expand Up @@ -89,7 +90,7 @@ public class FastDatePrinter implements DatePrinter, Serializable {
*
* @see java.io.Serializable
*/
private static final long serialVersionUID = 1L;
@Serial private static final long serialVersionUID = 1L;

/** FULL locale dependent date or time style. */
public static final int FULL = DateFormat.FULL;
Expand Down Expand Up @@ -372,12 +373,12 @@ protected NumberRule selectNumberRule(final int field, final int padding) {
*/
public StringBuffer format(
final Object obj, final StringBuffer toAppendTo, final FieldPosition pos) {
if (obj instanceof Date) {
return format((Date) obj, toAppendTo);
} else if (obj instanceof Calendar) {
return format((Calendar) obj, toAppendTo);
} else if (obj instanceof Long) {
return format(((Long) obj).longValue(), toAppendTo);
if (obj instanceof Date date) {
return format(date, toAppendTo);
} else if (obj instanceof Calendar calendar) {
return format(calendar, toAppendTo);
} else if (obj instanceof Long long1) {
return format(long1.longValue(), toAppendTo);
} else {
throw new IllegalArgumentException(
"Unknown class: " + (obj == null ? "<null>" : obj.getClass().getName()));
Expand Down Expand Up @@ -1180,8 +1181,7 @@ public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof TimeZoneDisplayKey) {
final TimeZoneDisplayKey other = (TimeZoneDisplayKey) obj;
if (obj instanceof TimeZoneDisplayKey other) {
return mTimeZone.equals(other.mTimeZone)
&& mStyle == other.mStyle
&& mLocale.equals(other.mLocale);
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/sqlite/jdbc3/JDBC3Connection.java
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public Savepoint setSavepoint() throws SQLException {
getConnectionConfig().setAutoCommit(false);
}
Savepoint sp = new JDBC3Savepoint(savePoint.incrementAndGet());
getDatabase().exec(String.format("SAVEPOINT %s", sp.getSavepointName()), false);
getDatabase().exec("SAVEPOINT %s".formatted(sp.getSavepointName()), false);
return sp;
}

Expand All @@ -255,7 +255,7 @@ public Savepoint setSavepoint(String name) throws SQLException {
getConnectionConfig().setAutoCommit(false);
}
Savepoint sp = new JDBC3Savepoint(savePoint.incrementAndGet(), name);
getDatabase().exec(String.format("SAVEPOINT %s", sp.getSavepointName()), false);
getDatabase().exec("SAVEPOINT %s".formatted(sp.getSavepointName()), false);
return sp;
}

Expand All @@ -266,7 +266,7 @@ public void releaseSavepoint(Savepoint savepoint) throws SQLException {
throw new SQLException("database in auto-commit mode");
}
getDatabase()
.exec(String.format("RELEASE SAVEPOINT %s", savepoint.getSavepointName()), false);
.exec("RELEASE SAVEPOINT %s".formatted(savepoint.getSavepointName()), false);
}

/** @see java.sql.Connection#rollback(java.sql.Savepoint) */
Expand All @@ -277,7 +277,7 @@ public void rollback(Savepoint savepoint) throws SQLException {
}
getDatabase()
.exec(
String.format("ROLLBACK TO SAVEPOINT %s", savepoint.getSavepointName()),
"ROLLBACK TO SAVEPOINT %s".formatted(savepoint.getSavepointName()),
getAutoCommit());
}

Expand Down
Loading