File tree Expand file tree Collapse file tree
src/main/java/me/axeno/hommr/managers Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -21,18 +21,20 @@ public class DatabaseManager {
2121 private Dao <Home , Integer > homeDao ;
2222
2323 public void init (String dbUrl , String dbUser , String dbPassword ) {
24- try {
25- Class .forName ("com.mysql.cj.jdbc.Driver" );
26- } catch (ClassNotFoundException e ) {
27- Hommr .getInstance ().getSLF4JLogger ().error ("MySQL database driver not found. Please ensure the MySQL driver is included in the classpath." );
28- throw new RuntimeException (e );
24+ if (dbUrl == null || dbUrl .isEmpty ()) {
25+ throw new IllegalStateException ("Database URL is not configured. Please set 'database.connection.url' in config.yml" );
2926 }
3027
31- try {
32- if (dbUrl == null || dbUrl .isEmpty ()) {
33- throw new IllegalStateException ("Database URL is not configured. Please set 'database.connection.url' in config.yml" );
28+ if (dbUrl .startsWith ("jbdc:mysql:" )) {
29+ try {
30+ Class .forName ("com.mysql.cj.jdbc.Driver" );
31+ } catch (ClassNotFoundException e ) {
32+ Hommr .getInstance ().getSLF4JLogger ().error ("MySQL database driver not found. Please ensure the MySQL driver is included in the classpath." );
33+ throw new RuntimeException (e );
3434 }
35+ }
3536
37+ try {
3638 connectionSource = new JdbcPooledConnectionSource (dbUrl , dbUser , dbPassword );
3739
3840 homeDao = DaoManager .createDao (connectionSource , Home .class );
You can’t perform that action at this time.
0 commit comments