Skip to content

Commit

Permalink
Switched from H2 to HyperSQL (H2 does not work in CheerpJ)
Browse files Browse the repository at this point in the history
  • Loading branch information
lfgaleota committed Mar 18, 2024
1 parent 93f1533 commit e7e3d0b
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
9 changes: 5 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,12 @@
<artifactId>appdirs</artifactId>
<version>1.1.0</version>
</dependency>
<!-- H2 -->
<!-- HyperSQL DB -->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>2.2.220</version>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>2.7.2</version>
<classifier>jdk8</classifier>
</dependency>
</dependencies>

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ece/ing3/java/projet/database/Database.java
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ private static Path getEmbeddedUserDatabasePath() {
public static String getEmbeddedUserDatabaseUrl() {
Path dbPath = getEmbeddedUserDatabasePath();
if( dbPath != null ) {
return "jdbc:h2:file:" + dbPath.toAbsolutePath();
return "jdbc:hsqldb:file:" + dbPath.toAbsolutePath() + ";shutdown=true;sql.syntax_mys=true";
}
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ece/ing3/java/projet/enums/JDBCDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
public enum JDBCDriver {
MySQL( "com.mysql.cj.jdbc.Driver" ),
Embedded( "org.h2.Driver" );
Embedded( "org.hsqldb.jdbc.JDBCDriver" );

private static Map<String, JDBCDriver> valueMap;
private String className;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ece/ing3/java/projet/utils/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public class Constants {
public static final int UI_INPUTLIST_MAXVISIBLEENUMITEMS = 5;
public static final Border UI_INPUTLIST_INVALIDVALUE_BORDER = BorderFactory.createMatteBorder( 1, 1, 1, 1, Color.RED );

public final static String DB_EMBEDDED_DATABASE_FILENAME = "hopitaldb.h2";
public final static String DB_EMBEDDED_DATABASE_FILENAME = "hopitaldb.hsql";

public final static String DB_VALIDATION_QUERY = "select count(numero) from employe;\n" +
"select count(numero) from docteur;\n" +
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/init.sql
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ create table if not exists service
nom varchar(30) not null unique,
batiment char(1) not null,
directeur decimal(4),
constraint employe_uk unique (nom),
foreign key (directeur) references docteur (numero) on delete set null on update cascade
);

Expand Down

0 comments on commit e7e3d0b

Please sign in to comment.