Currently trying to add H2 Database support with my mod. I've shaded the h2 database engine in my build.gradle like so:
shadowJar {
dependencies {
include dependency("org.json:json:20180813"),
include dependency("com.h2database:h2:1.0.60")
}
relocate("org.json", "shaded.org.json")
relocate("com.h2database","shaded.com.h2database")
}
...
reobf {
shadowJar {
mappingType = 'SEARGE'
}
}
Issue is, everytime I attempt to establish a connection using my H2Connection class like so:
H2Connection db = new H2Connection("jdbc:h2:D:/H2db/test/test", "admin", "password");
I get an error saying: java.sql.SQLException: No suitable driver found for jdbc:h2:D:/H2db/test/test
Anyone know whats up? Am I doing this right?
This is my H2Connectionclass:
public class H2Connection {
private Connection conn;
public H2Connection() {}
public H2Connection(String url, String user, String pass) throws SQLException, ClassNotFoundException {
connect(url, user, pass);
}
public void connect(String url, String user, String pass) throws SQLException, ClassNotFoundException {
conn = DriverManager.getConnection(url,user,pass);
}
public ResultSet query(String query) throws SQLException {
return conn.createStatement().executeQuery(query);
}
}