Skip to content

Commit

Permalink
WIP: add support for HSQLDB in PostreSQL mode (all tweaks to query st…
Browse files Browse the repository at this point in the history
…aements should remain compatible with SQLite)

Note: Currently, this will replace SQLite, but this commit should be refactored to add support for both databases.
  • Loading branch information
BLuFeNiX committed Jul 6, 2021
1 parent 6903088 commit a510ef1
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 8 deletions.
41 changes: 41 additions & 0 deletions NOTICE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
------------------
TeleportationRunes
------------------

Copyright 2013-2021 Chase Montgomery

Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -13,10 +16,48 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

--------
exp4j
--------

This software depends on the exp4j library, and is included in released JAR files, under the 'de.congrace.*' package name.
No copyright statement is provided with the exp4j software, so none can be reproduced here. However, the software
itself is Apache 2.0 licensed, and can be found at the following sites:
https://www.objecthunter.net/exp4j/
https://github.com/fasseg/exp4j

--------
HSQLDB
--------

Copyright © 2001-2010, The HSQL Development Group

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

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.

Neither the name of the HSQL Development Group nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

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 HSQL DEVELOPMENT GROUP, HSQLDB.ORG, 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.

For work originally developed by the Hypersonic SQL Group:

Copyright © 1995-2000 by the Hypersonic SQL Group.

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

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.

Neither the name of the Hypersonic SQL Group nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

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 HYPERSONIC SQL GROUP, 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.

This software consists of voluntary contributions made by many individuals on behalf of the Hypersonic SQL Group.
13 changes: 13 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@
<artifactId>exp4j</artifactId>
<version>0.3.11</version>
</dependency>

<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>2.6.0</version>
</dependency>

</dependencies>

<properties>
Expand Down Expand Up @@ -85,6 +92,12 @@
<exclude>META-INF/*.MF</exclude>
</excludes>
</filter>
<filter>
<artifact>org.hsqldb:*</artifact>
<excludes>
<exclude>META-INF/*.MF</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/net/blufenix/common/SimpleDatabase.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@ public class SimpleDatabase {

public SimpleDatabase(String filename) {
this.DB_FILE_PATH = BASE_PATH + "/" + filename;
this.DB_URL = "jdbc:sqlite:"+DB_FILE_PATH;
// this.DB_URL = "jdbc:sqlite:"+DB_FILE_PATH;
this.DB_URL = "jdbc:hsqldb:"+DB_FILE_PATH+";sql.syntax_pgs=true;hsqldb.lock_file=false";
loadDriver();
openConnections();
}

private static void loadDriver() {
try {
Class.forName("org.sqlite.JDBC");
// Class.forName("org.sqlite.JDBC");
Class.forName("org.hsqldb.jdbcDriver");
} catch (ClassNotFoundException e) {
Log.e("can't load JDBC driver", e);
}
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/net/blufenix/teleportationrunes/WaypointDB.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ private void createTables() {
"x INTEGER NOT NULL, " +
"y INTEGER NOT NULL, " +
"z INTEGER NOT NULL, " +
"north STRING NOT NULL, " +
"south STRING NOT NULL, " +
"east STRING NOT NULL, " +
"west STRING NOT NULL)"
"north TEXT NOT NULL, " +
"south TEXT NOT NULL, " +
"east TEXT NOT NULL, " +
"west TEXT NOT NULL)"
);
} catch (SQLException e) {
Log.e("query error", e);
Expand Down Expand Up @@ -121,7 +121,7 @@ protected Waypoint handle(ResultSet rs) throws SQLException {

public Waypoint getWaypointFromLocation(final Location loc) {
String sql = String.format(
"SELECT north, south, east, west FROM %s WHERE world = '%s' AND x = %d AND y = %d AND z = %d",
"SELECT north, south, east, west FROM %s WHERE %1$s.world = '%s' AND x = %d AND y = %d AND z = %d",
WAYPOINT_TABLE,
loc.getWorld().getName(), (int)loc.getX(), (int)loc.getY(), (int)loc.getZ());

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: TeleportationRunes
main: net.blufenix.teleportationrunes.TeleportationRunes
version: 2.0.1
version: 2.0.2-freebsd-dev
api-version: 1.13
commands:
tr:
Expand Down

0 comments on commit a510ef1

Please sign in to comment.