Skip to content
Snippets Groups Projects
Verified Commit 2d31f50b authored by Jan Kožusznik's avatar Jan Kožusznik
Browse files

Run H2 in server mode.

parent 8150ad7e
Branches 2023_use_H2
No related merge requests found
package lab; package lab;
import java.sql.SQLException;
import javafx.application.Application; import javafx.application.Application;
import javafx.fxml.FXMLLoader; import javafx.fxml.FXMLLoader;
import javafx.scene.Scene; import javafx.scene.Scene;
...@@ -13,7 +15,8 @@ import javafx.stage.WindowEvent; ...@@ -13,7 +15,8 @@ import javafx.stage.WindowEvent;
*/ */
public class App extends Application { public class App extends Application {
public static void main(String[] args) { public static void main(String[] args) throws SQLException {
org.h2.tools.Server.createWebServer("-webAllowOthers","-webPort", "8082").start();
launch(args); launch(args);
} }
......
...@@ -121,7 +121,7 @@ public class ScoreDAO { ...@@ -121,7 +121,7 @@ public class ScoreDAO {
private Connection getConnection() { private Connection getConnection() {
try { try {
return DriverManager.getConnection("jdbc:h2:./scoreDBh2"); return DriverManager.getConnection("jdbc:h2:./scoreDBh2;AUTO_SERVER=TRUE", "sa","");
} catch (SQLException e) { } catch (SQLException e) {
e.printStackTrace(); e.printStackTrace();
return null; return null;
......
...@@ -2,6 +2,7 @@ module lab01 { ...@@ -2,6 +2,7 @@ module lab01 {
requires transitive javafx.controls; requires transitive javafx.controls;
requires javafx.fxml; requires javafx.fxml;
requires java.sql; requires java.sql;
requires com.h2database;
opens lab to javafx.fxml; opens lab to javafx.fxml;
exports lab; exports lab;
} }
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment