forked from Limework/skript-db
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| cf61d7589b | |||
| 4d4af1622e | |||
| af25e695f0 | |||
| 54e260e56b | |||
| 587f303ba5 | |||
| 8586aeefcd |
11
README.md
11
README.md
@@ -5,12 +5,13 @@
|
|||||||
|
|
||||||
### Difference from original skript-db
|
### Difference from original skript-db
|
||||||
- Fixed local variables disappearance in newer Skript versions (very hacky fix, but it works, so that's good!)
|
- Fixed local variables disappearance in newer Skript versions (very hacky fix, but it works, so that's good!)
|
||||||
- Thread-pool size is now automatically increasing on demand with use of CachedThreadPool, instead of a fixed hard-coded number
|
|
||||||
- Uses newer versions of dependencies (Increased performance and security)
|
- Uses newer versions of dependencies (Increased performance and security)
|
||||||
- Replaced `synchronously execute` with `quickly execute`, which allows to speed up queries by 50ms with some risk
|
- Replaced `synchronously execute` with `quickly execute`, which allows to speed up queries by 50ms with some risk
|
||||||
- SQL Driver is configurable
|
- If a sql query is detected to be running on non-main thread, it becomes synchronous automatically
|
||||||
|
- SQL Driver is configurable, comes with shaded MariaDB and PostgreSQL drivers
|
||||||
- A few variable type related bugs fixed
|
- A few variable type related bugs fixed
|
||||||
- Uses Java 11 instead of Java 8
|
- Uses Java 11 instead of Java 8
|
||||||
|
- Configurable max-connection-lifetime
|
||||||
|
|
||||||
### Installation
|
### Installation
|
||||||
1. Use 1.8+ Minecraft server version.
|
1. Use 1.8+ Minecraft server version.
|
||||||
@@ -21,7 +22,8 @@
|
|||||||
Stores the connection information for a data source. This should be saved to a variable in a
|
Stores the connection information for a data source. This should be saved to a variable in a
|
||||||
`script load` event or manually through an effect command.
|
`script load` event or manually through an effect command.
|
||||||
|
|
||||||
The url format for your database may vary! The example provided uses a MySQL database.
|
The url format for your database may vary depending on database you are using.
|
||||||
|
MariaDB/PostgreSQL users: make sure to check `config.yml` to use the correct driver.
|
||||||
#### Syntax
|
#### Syntax
|
||||||
```
|
```
|
||||||
[the] data(base|[ ]source) [(of|at)] %string%
|
[the] data(base|[ ]source) [(of|at)] %string%
|
||||||
@@ -30,6 +32,9 @@ Stores the connection information for a data source. This should be saved to a v
|
|||||||
#### Examples
|
#### Examples
|
||||||
```
|
```
|
||||||
set {sql} to the database "mysql://localhost:3306/mydatabase?user=admin&password=12345&useSSL=false"
|
set {sql} to the database "mysql://localhost:3306/mydatabase?user=admin&password=12345&useSSL=false"
|
||||||
|
set {sql} to the database "mariadb://localhost:3306/mydatabase?user=admin&password=12345&useSSL=false"
|
||||||
|
set {sql} to the database "postgresql://localhost:3306/mydatabase?user=admin&password=12345&ssl=false"
|
||||||
|
set {sql} to the database "sqlite:database.db"
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|||||||
9
pom.xml
9
pom.xml
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>com.btk5h</groupId>
|
<groupId>com.btk5h</groupId>
|
||||||
<artifactId>skript-db</artifactId>
|
<artifactId>skript-db</artifactId>
|
||||||
<version>1.3.8</version>
|
<version>1.3.9</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
@@ -103,6 +103,13 @@
|
|||||||
<version>3.0.9</version>
|
<version>3.0.9</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- https://mvnrepository.com/artifact/org.postgresql/postgresql -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.postgresql</groupId>
|
||||||
|
<artifactId>postgresql</artifactId>
|
||||||
|
<version>42.5.1</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -73,8 +73,14 @@ public final class SkriptDB extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (out == null) return;
|
if (out == null) return;
|
||||||
out.write("# Only change this if you wish to use a different driver than Java's default, like MariaDB driver.\n");
|
|
||||||
out.write("# If you use MariaDB, its driver is shaded together with skript-db, so you can just specify:" + "\"org.mariadb.jdbc.Driver\"" + ".\n");
|
out.write("# How many connections can be awaited for simultaneously, may be useful to increase if SQL database is hosted on a separate machine to account for ping.\n");
|
||||||
|
out.write("# If it is hosted within the same machine, set it to the count of cores your processor has or the count of threads your processor can process at once.\n");
|
||||||
|
out.write("thread-pool-size: " + (Runtime.getRuntime().availableProcessors() + 2) + "\n");
|
||||||
|
out.write("# How long SQL connections should be kept alive in HikariCP. Default: 1800000 (30 minutes)");
|
||||||
|
out.write("max-connection-lifetime: 1800000");
|
||||||
|
out.write("# Only change this if you wish to use a different driver than Java's default, like MariaDB/PostgreSQL driver.\n");
|
||||||
|
out.write("# If you use MariaDB or PostgreSQL, its driver is shaded together with skript-db, so you can just specify:" + "\"org.mariadb.jdbc.Driver\"" + " or " + "\"org.postgresql.Driver\"" + ".\n");
|
||||||
out.write("sql-driver-class-name: " + "\"default\"" + "\n");
|
out.write("sql-driver-class-name: " + "\"default\"" + "\n");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
@@ -44,8 +44,7 @@ import java.util.concurrent.Executors;
|
|||||||
* @since 0.1.0
|
* @since 0.1.0
|
||||||
*/
|
*/
|
||||||
public class EffExecuteStatement extends Effect {
|
public class EffExecuteStatement extends Effect {
|
||||||
private static final ExecutorService threadPool =
|
private static final ExecutorService threadPool = Executors.newFixedThreadPool(SkriptDB.getInstance().getConfig().getInt("thread-pool-size", 10));
|
||||||
Executors.newCachedThreadPool();
|
|
||||||
static String lastError;
|
static String lastError;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
|||||||
@@ -55,7 +55,9 @@ public class ExprDataSource extends SimpleExpression<HikariDataSource> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
HikariDataSource ds = new HikariDataSource();
|
HikariDataSource ds = new HikariDataSource();
|
||||||
|
ds.setMaximumPoolSize(SkriptDB.getInstance().getConfig().getInt("thread-pool-size", 10));
|
||||||
|
// 30 minutes by default
|
||||||
|
ds.setMaxLifetime(SkriptDB.getInstance().getConfig().getInt("max-connection-lifetime", 1800000));
|
||||||
//allow specifying of own sql driver class name
|
//allow specifying of own sql driver class name
|
||||||
if (!SkriptDB.getInstance().getConfig().getString("sql-driver-class-name", "default").equals("default")) {
|
if (!SkriptDB.getInstance().getConfig().getString("sql-driver-class-name", "default").equals("default")) {
|
||||||
ds.setDriverClassName(SkriptDB.getInstance().getConfig().getString("sql-driver-class-name"));
|
ds.setDriverClassName(SkriptDB.getInstance().getConfig().getString("sql-driver-class-name"));
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
name: skript-db
|
name: skript-db
|
||||||
version: 1.3.5
|
version: 1.3.9
|
||||||
main: com.btk5h.skriptdb.SkriptDB
|
main: com.btk5h.skriptdb.SkriptDB
|
||||||
depend: [Skript]
|
depend: [Skript]
|
||||||
authors: [btk5h, FranKusmiruk, Govindas, TPGamesNL]
|
authors: [btk5h, FranKusmiruk, Govindas, TPGamesNL]
|
||||||
|
|||||||
Reference in New Issue
Block a user