Posted November 21, 20195 yr 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); } } Edited November 21, 20195 yr by ratquaza
November 21, 20195 yr Author 26 minutes ago, diesieben07 said: https://github.com/h2database/h2database/blob/master/h2/src/main/META-INF/services/java.sql.Driver This file will no longer be correct after your relocation. What does that mean then? Do I have to reference the driver using Class.forName() and include the "shaded" part?
November 21, 20195 yr Author Realised my build.gradle was missing some things that lead to it not properly shading. It's fixed now!
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.