Patch H2 and Update H2 to 2.2.224
This commit is contained in:
parent
5155ab6302
commit
8aef3ceb06
9
pom.xml
9
pom.xml
@ -294,7 +294,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
<version>3.4.1</version>
|
<version>3.5.1</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<id>shaded-jar</id>
|
<id>shaded-jar</id>
|
||||||
@ -350,11 +350,6 @@
|
|||||||
<pattern>org.h2</pattern>
|
<pattern>org.h2</pattern>
|
||||||
<shadedPattern>fr.xephi.authme.libs.org.h2</shadedPattern>
|
<shadedPattern>fr.xephi.authme.libs.org.h2</shadedPattern>
|
||||||
</relocation>
|
</relocation>
|
||||||
|
|
||||||
<!-- <relocation>-->
|
|
||||||
<!-- <pattern>com.cryptomorin.xseries</pattern>-->
|
|
||||||
<!-- <shadedPattern>fr.xephi.authme.libs.com.cryptomorin.xseries</shadedPattern>-->
|
|
||||||
<!-- </relocation>-->
|
|
||||||
</relocations>
|
</relocations>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
@ -1133,7 +1128,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.h2database</groupId>
|
<groupId>com.h2database</groupId>
|
||||||
<artifactId>h2</artifactId>
|
<artifactId>h2</artifactId>
|
||||||
<version>2.1.214</version>
|
<version>2.2.224</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|||||||
@ -194,17 +194,26 @@ public class H2 extends AbstractSqlDataSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if a column is missing.
|
* Checks if a column is missing in the specified table.
|
||||||
* @deprecated Not working in H2 database(always true), replaced by statement "IF NOT EXISTS"
|
* @param columnName the name of the column to look for
|
||||||
* @return true/false
|
* @return true if the column is missing, false if it exists
|
||||||
|
* @throws SQLException if an error occurs while executing SQL or accessing the result set
|
||||||
|
* @deprecated Not work in H2, it always returns true
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
private boolean isColumnMissing(DatabaseMetaData metaData, String columnName) throws SQLException {
|
private boolean isColumnMissing(DatabaseMetaData metaData, String columnName) throws SQLException {
|
||||||
try (ResultSet rs = metaData.getColumns(null, null, tableName, columnName.toUpperCase())) {
|
String query = "SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = ? AND COLUMN_NAME = ?";
|
||||||
return !rs.next();
|
// try (PreparedStatement preparedStatement = con.prepareStatement(query)) {
|
||||||
}
|
// preparedStatement.setString(1, tableName);
|
||||||
|
// preparedStatement.setString(2, columnName.toUpperCase());
|
||||||
|
// try (ResultSet rs = preparedStatement.executeQuery()) {
|
||||||
|
// return !rs.next();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reload() {
|
public void reload() {
|
||||||
close(con);
|
close(con);
|
||||||
@ -384,11 +393,9 @@ public class H2 extends AbstractSqlDataSource {
|
|||||||
* @param st Statement object to the database
|
* @param st Statement object to the database
|
||||||
*/
|
*/
|
||||||
private void addRegistrationDateColumn(Statement st) throws SQLException {
|
private void addRegistrationDateColumn(Statement st) throws SQLException {
|
||||||
int affectedRows = st.executeUpdate("ALTER TABLE " + tableName
|
int affect = st.executeUpdate("ALTER TABLE " + tableName
|
||||||
+ " ADD COLUMN IF NOT EXISTS " + col.REGISTRATION_DATE + " BIGINT NOT NULL DEFAULT '0';");
|
+ " ADD COLUMN IF NOT EXISTS " + col.REGISTRATION_DATE + " BIGINT NOT NULL DEFAULT '0';");
|
||||||
|
if (affect > 0) {
|
||||||
// Use the timestamp from Java to avoid timezone issues in case JVM and database are out of sync
|
|
||||||
if (affectedRows != 0) {
|
|
||||||
long currentTimestamp = System.currentTimeMillis();
|
long currentTimestamp = System.currentTimeMillis();
|
||||||
int updatedRows = st.executeUpdate(String.format("UPDATE %s SET %s = %d;",
|
int updatedRows = st.executeUpdate(String.format("UPDATE %s SET %s = %d;",
|
||||||
tableName, col.REGISTRATION_DATE, currentTimestamp));
|
tableName, col.REGISTRATION_DATE, currentTimestamp));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user