@@ -59,7 +59,7 @@ private void open() throws SQLException {
59
59
private void createDatabase () {
60
60
Session session = factory .openSession ();
61
61
Transaction tx = session .beginTransaction ();
62
- if (this .databaseProductName .contains ("MySQL" )) {
62
+ if (this .databaseProductName .contains ("MySQL" ) || this . databaseProductName . contains ( "MariaDB" ) ) {
63
63
session .createSQLQuery ("CREATE DATABASE IF NOT EXISTS casbin" ).executeUpdate ();
64
64
session .createSQLQuery ("USE casbin" ).executeUpdate ();
65
65
} else if (this .databaseProductName .contains ("SQLServer" )) {
@@ -78,7 +78,7 @@ private void createDatabase() {
78
78
private void createTable () {
79
79
Session session = factory .openSession ();
80
80
Transaction tx = session .beginTransaction ();
81
- if (this .databaseProductName .contains ("MySQL" )) {
81
+ if (this .databaseProductName .contains ("MySQL" ) || this . databaseProductName . contains ( "MariaDB" ) ) {
82
82
session .createSQLQuery ("CREATE TABLE IF NOT EXISTS casbin_rule (" +
83
83
"id INT not NULL primary key," +
84
84
"ptype VARCHAR(100) not NULL," +
@@ -130,7 +130,7 @@ private void createTable() {
130
130
private void dropTable () {
131
131
Session session = factory .openSession ();
132
132
Transaction tx = session .beginTransaction ();
133
- if (this .databaseProductName .contains ("MySQL" )) {
133
+ if (this .databaseProductName .contains ("MySQL" ) || this . databaseProductName . contains ( "MariaDB" ) ) {
134
134
session .createSQLQuery ("DROP TABLE IF EXISTS casbin_rule" ).executeUpdate ();
135
135
} else if (this .databaseProductName .contains ("Oracle" )) {
136
136
session .createSQLQuery ("declare " +
@@ -356,6 +356,8 @@ private void setDatabaseProductName() {
356
356
this .databaseProductName = "Oracle" ;
357
357
} else if (this .driver .contains ("sqlserver" )) {
358
358
this .databaseProductName = "SQLServer" ;
359
+ } else if (this .driver .contains ("mariadb" )) {
360
+ this .databaseProductName = "MariaDB" ;
359
361
}
360
362
}
361
363
}
0 commit comments