Load SQLite drivers

Discussion in 'BungeeCord Plugin Development' started by MaTaMoR_, Jun 29, 2016.

  1. I was wondering how i can load SQLite driver from a file on bungeecord.
     
  2. Use this code:
    Code (Text):
    File file = new File("YOUR FILE");
    URLClassLoader loader = new URLClassLoader(new URL[]{file.toURI().toURL()});
    Method m = DriverManager.class.getDeclaredMethod("getConnection", String.class, Properties.class, Class.class);
    m.setAccessible(true);
    this.connection = (Connection) m.invoke(null, "jdbc:sqlite:" + this.file.getPath(), new Properties(), Class.forName("org.sqlite.JDBC", true, loader));
    :)