Untitled
unknown
java
2 years ago
1.3 kB
6
Indexable
File libsFolder = new File(getDataFolder(), "libs"); if (!libsFolder.exists()) { libsFolder.mkdirs(); } File h2DriverFile = new File(libsFolder, "h2-2.1.214.jar"); if (!h2DriverFile.exists()) { try { URI h2DriverUri = new URI("https://repo1.maven.org/maven2/com/h2database/h2/2.1.214/h2-2.1.214.jar"); URL h2DriverUrl = h2DriverUri.toURL(); HttpURLConnection connection = (HttpURLConnection) h2DriverUrl.openConnection(); connection.setRequestMethod("GET"); try (InputStream in = connection.getInputStream(); FileOutputStream out = new FileOutputStream(h2DriverFile)) { byte[] buffer = new byte[4096]; int bytesRead; while ((bytesRead = in.read(buffer)) != -1) { out.write(buffer, 0, bytesRead); } } } catch (IOException | URISyntaxException e) { e.printStackTrace(); } } if (h2DriverFile.exists()) { url = "jdbc:h2:" + getDataFolder().getAbsolutePath() + "/test"; Database.initializeDatabase();
Editor is loading...