Skip to content

Commit 2b91b69

Browse files
author
TheProgramSrc
committed
Running some tests to fix bugs with SQLite
1 parent 1114bbc commit 2b91b69

File tree

6 files changed

+246
-11
lines changed

6 files changed

+246
-11
lines changed

SuperCoreAPI.iml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,10 @@
4141
<orderEntry type="library" scope="PROVIDED" name="Maven: io.netty:netty-resolver:4.1.49.Final" level="project" />
4242
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot:1.15.2-R0.1-SNAPSHOT" level="project" />
4343
<orderEntry type="library" name="Maven: org.slf4j:slf4j-nop:1.7.30" level="project" />
44-
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.30" level="project" />
44+
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.25" level="project" />
4545
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.6" level="project" />
4646
<orderEntry type="library" name="Maven: commons-io:commons-io:2.6" level="project" />
4747
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.8.6" level="project" />
48-
<orderEntry type="library" name="Maven: org.xerial:sqlite-jdbc:3.23.1" level="project" />
4948
<orderEntry type="library" name="Maven: com.zaxxer:HikariCP:3.4.5" level="project" />
5049
</component>
5150
</module>

dependency-reduced-pom.xml

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>xyz.theprogramsrc</groupId>
5+
<artifactId>SuperCoreAPI</artifactId>
6+
<name>SuperCoreAPI</name>
7+
<version>3.1.0</version>
8+
<build>
9+
<sourceDirectory>src/main/java</sourceDirectory>
10+
<defaultGoal>clean package</defaultGoal>
11+
<resources>
12+
<resource>
13+
<filtering>true</filtering>
14+
<directory>src/main/resources</directory>
15+
</resource>
16+
</resources>
17+
<finalName>${artifactId}</finalName>
18+
<plugins>
19+
<plugin>
20+
<artifactId>maven-compiler-plugin</artifactId>
21+
<version>3.7.0</version>
22+
<configuration>
23+
<source>${java.version}</source>
24+
<target>${java.version}</target>
25+
</configuration>
26+
</plugin>
27+
<plugin>
28+
<artifactId>maven-shade-plugin</artifactId>
29+
<version>3.1.0</version>
30+
<executions>
31+
<execution>
32+
<phase>package</phase>
33+
<goals>
34+
<goal>shade</goal>
35+
</goals>
36+
<configuration>
37+
<transformers>
38+
<transformer>
39+
<resource>META-INF/services/java.sql.Driver</resource>
40+
</transformer>
41+
</transformers>
42+
<createDependencyReducedPom>true</createDependencyReducedPom>
43+
<minimizeJar>true</minimizeJar>
44+
</configuration>
45+
</execution>
46+
</executions>
47+
</plugin>
48+
</plugins>
49+
</build>
50+
<repositories>
51+
<repository>
52+
<id>spigotmc-repo</id>
53+
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
54+
</repository>
55+
<repository>
56+
<id>nms-repo</id>
57+
<url>https://repo.codemc.io/repository/nms/</url>
58+
</repository>
59+
<repository>
60+
<id>CodeMC</id>
61+
<url>https://repo.codemc.org/repository/maven-public</url>
62+
</repository>
63+
<repository>
64+
<id>sonatype</id>
65+
<url>https://oss.sonatype.org/content/groups/public/</url>
66+
</repository>
67+
</repositories>
68+
<dependencies>
69+
<dependency>
70+
<groupId>org.spigotmc</groupId>
71+
<artifactId>spigot-api</artifactId>
72+
<version>1.15.2-R0.1-SNAPSHOT</version>
73+
<scope>provided</scope>
74+
<exclusions>
75+
<exclusion>
76+
<artifactId>commons-lang</artifactId>
77+
<groupId>commons-lang</groupId>
78+
</exclusion>
79+
<exclusion>
80+
<artifactId>guava</artifactId>
81+
<groupId>com.google.guava</groupId>
82+
</exclusion>
83+
<exclusion>
84+
<artifactId>bungeecord-chat</artifactId>
85+
<groupId>net.md-5</groupId>
86+
</exclusion>
87+
<exclusion>
88+
<artifactId>snakeyaml</artifactId>
89+
<groupId>org.yaml</groupId>
90+
</exclusion>
91+
</exclusions>
92+
</dependency>
93+
<dependency>
94+
<groupId>net.md-5</groupId>
95+
<artifactId>bungeecord-api</artifactId>
96+
<version>1.15-SNAPSHOT</version>
97+
<scope>provided</scope>
98+
<exclusions>
99+
<exclusion>
100+
<artifactId>bungeecord-config</artifactId>
101+
<groupId>net.md-5</groupId>
102+
</exclusion>
103+
<exclusion>
104+
<artifactId>bungeecord-event</artifactId>
105+
<groupId>net.md-5</groupId>
106+
</exclusion>
107+
<exclusion>
108+
<artifactId>bungeecord-protocol</artifactId>
109+
<groupId>net.md-5</groupId>
110+
</exclusion>
111+
<exclusion>
112+
<artifactId>netty-transport-native-unix-common</artifactId>
113+
<groupId>io.netty</groupId>
114+
</exclusion>
115+
<exclusion>
116+
<artifactId>bungeecord-chat</artifactId>
117+
<groupId>net.md-5</groupId>
118+
</exclusion>
119+
<exclusion>
120+
<artifactId>snakeyaml</artifactId>
121+
<groupId>org.yaml</groupId>
122+
</exclusion>
123+
<exclusion>
124+
<artifactId>guava</artifactId>
125+
<groupId>com.google.guava</groupId>
126+
</exclusion>
127+
</exclusions>
128+
</dependency>
129+
<dependency>
130+
<groupId>org.spigotmc</groupId>
131+
<artifactId>spigot</artifactId>
132+
<version>1.15.2-R0.1-20200509.094844-17</version>
133+
<scope>provided</scope>
134+
</dependency>
135+
</dependencies>
136+
<distributionManagement>
137+
<repository>
138+
<id>codemc-releases</id>
139+
<url>https://repo.codemc.io/repository/maven-releases/</url>
140+
</repository>
141+
<snapshotRepository>
142+
<id>codemc-snapshots</id>
143+
<url>https://repo.codemc.io/repository/maven-snapshots/</url>
144+
</snapshotRepository>
145+
</distributionManagement>
146+
<properties>
147+
<java.version>1.8</java.version>
148+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
149+
</properties>
150+
</project>
151+

pom.xml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
</properties>
2323

2424
<build>
25+
<finalName>${artifactId}</finalName>
26+
<sourceDirectory>src/main/java</sourceDirectory>
2527
<defaultGoal>clean package</defaultGoal>
2628
<plugins>
2729
<plugin>
@@ -44,7 +46,13 @@
4446
<goal>shade</goal>
4547
</goals>
4648
<configuration>
47-
<createDependencyReducedPom>false</createDependencyReducedPom>
49+
<transformers>
50+
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
51+
<resource>META-INF/services/java.sql.Driver</resource>
52+
</transformer>
53+
</transformers>
54+
<createDependencyReducedPom>true</createDependencyReducedPom>
55+
<minimizeJar>true</minimizeJar>
4856
</configuration>
4957
</execution>
5058
</executions>
@@ -122,6 +130,11 @@
122130
<version>1.7.30</version>
123131
<scope>compile</scope>
124132
</dependency>
133+
<dependency>
134+
<groupId>org.slf4j</groupId>
135+
<artifactId>slf4j-api</artifactId>
136+
<version>1.7.25</version>
137+
</dependency>
125138
<!-- COMMONS -->
126139
<dependency>
127140
<groupId>commons-codec</groupId>
@@ -142,12 +155,6 @@
142155
<version>2.8.6</version>
143156
<scope>compile</scope>
144157
</dependency>
145-
<!-- SQLite -->
146-
<dependency>
147-
<groupId>org.xerial</groupId>
148-
<artifactId>sqlite-jdbc</artifactId>
149-
<version>3.23.1</version>
150-
</dependency>
151158
<!-- HikariCP -->
152159
<dependency>
153160
<groupId>com.zaxxer</groupId>
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
package xyz.theprogramsrc.plugin;
2+
3+
import xyz.theprogramsrc.supercoreapi.bungee.BungeePlugin;
4+
import xyz.theprogramsrc.supercoreapi.global.storage.*;
5+
6+
import java.sql.ResultSet;
7+
8+
public class MyPlugin extends BungeePlugin {
9+
@Override
10+
public void onPluginLoad() {
11+
12+
}
13+
14+
@Override
15+
public void onPluginEnable() {
16+
DataBase db = new SQLiteDataBase(this) {
17+
@Override
18+
public DataBaseSettings getDataBaseSettings() {
19+
return null;
20+
}
21+
};
22+
23+
exe(db);
24+
db = new MySQLDataBase(this) {
25+
@Override
26+
public DataBaseSettings getDataBaseSettings() {
27+
return new DataBaseSettings() {
28+
@Override
29+
public String host() {
30+
return "localhost";
31+
}
32+
33+
@Override
34+
public String database() {
35+
return "test";
36+
}
37+
38+
@Override
39+
public String username() {
40+
return "test";
41+
}
42+
43+
@Override
44+
public String password() {
45+
return "test";
46+
}
47+
};
48+
}
49+
};
50+
exe(db);
51+
}
52+
53+
private void exe(DataBase db){
54+
db.connect(c->{
55+
try{
56+
c.createStatement().executeUpdate("CREATE TABLE IF NOT EXISTS users (id VARCHAR(50), username VARCHAR(100))");
57+
if(!c.createStatement().executeQuery("SELECT * FROM users;").next()){
58+
c.createStatement().executeUpdate("INSERT INTO users (identifier, username) VALUES ('1', 'theprogramsrc')");
59+
}
60+
61+
ResultSet rs = c.createStatement().executeQuery("SELECT * FROM users");
62+
while(rs.next()){
63+
log("ID=" + rs.getInt("id"));
64+
log("NAME=" + rs.getString("username"));
65+
log("========================");
66+
}
67+
}catch (Exception ex){
68+
ex.printStackTrace();
69+
}
70+
});
71+
}
72+
73+
@Override
74+
public void onPluginDisable() {
75+
76+
}
77+
}

src/main/resources/bungee.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
main: xyz.theprogramsrc.plugin.MyPlugin
2+
name: SuperCoreAPI
3+
version: 3.1.0

src/test/java/DataBaseTests.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
import xyz.theprogramsrc.supercoreapi.global.storage.SQLiteDataBase;
2-
31
public class DataBaseTests {
42
}

0 commit comments

Comments
 (0)