# Problem in MariaDB implementation?

**URL:** <https://discourse.hibernate.org/t/problem-in-mariadb-implementation/2531>\
**Category:** Hibernate ORM\
**Created:** [March 29, 2019, 2:14pm UTC](https://discourse.hibernate.org/t/problem-in-mariadb-implementation/2531 "2019-03-29T14:14:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![McFly](https://avatars.discourse-cdn.com/v4/letter/m/b4bc9f/32.png) [@McFly](https://discourse.hibernate.org/u/McFly)\
**Post date:** [March 29, 2019, 2:14pm UTC](https://discourse.hibernate.org/t/problem-in-mariadb-implementation/2531/1 "2019-03-29T14:14:20Z")

</div>

Hi all

I am currently implementing an application using Hibernate, Spring Boot and MariaDB. The connection to the DB is as follows:

```auto
application.yml ---------------------
spring:
  jpa:
    hibernate:
      ddl-auto: create-drop
      default_schema: mydb
  datasource:
    platform: mariadb
    driver-class-name: org.mariadb.jdbc.Driver
    url: jdbc:mariadb://localhost:3306/mydb
    username: mydb
    password: mysecretpassword
    initialization-mode: always

```

The objects are defined as follows:

```auto
MyObject.java ----------------------
@Entity
@Table(name = "my_object", schema = "otherdb")
public class MyObject {
...
}

```

Additionally, I have defined a SQL file where I make sure the two used schemas exists:

```auto
schema.sql ---------------------------
CREATE SCHEMA IF NOT EXISTS mydb;
CREATE SCHEMA IF NOT EXISTS otherdb;

```

Running this on the in-memory DB worked perfectly, I got messages like this:

```auto
...
2019-03-29 13:23:24.978 INFO 15876 --- [main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
Hibernate: drop table otherdb.my_object if exists
...

```

But when I switched to MariaDB, I got error messages like this:

```auto
2019-03-29 14:27:09.166 INFO 2084 --- [main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
Hibernate: drop table if exists my_object
2019-03-29 14:27:10.889 WARN 2084 --- [main] o.h.t.s.i.ExceptionHandlerLoggedImpl : GenerationTarget encountered exception accepting command : Error executing DDL "drop table if exists my_object" via JDBC Statement
org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "drop table if exists my_object" via JDBC Statement
...
Caused by: java.sql.SQLException: (conn=250) No database selected
	at org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.get(ExceptionMapper.java:258) ~[mariadb-java-client-2.3.0.jar:na]
...
Caused by: java.sql.SQLException: No database selected
Query is: drop table if exists my_object
java thread: main
...

```

Please note, that the schema name disappeared in the SQL command. From my point of view, this causes the problem.

Please forgive me if this is a spring boot problem as it is my first approach to report this problem.

Thanks for helping!

---

<div class="post-metadata">

**Author:** ![beikov](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/beikov/32/258_2.png) [@beikov](https://discourse.hibernate.org/u/beikov)\
**Post date:** [February 22, 2022, 9:21am UTC](https://discourse.hibernate.org/t/problem-in-mariadb-implementation/2531/3 "2022-02-22T09:21:55Z")

</div>

Which Hibernate version are you using? Why are you using the MySQL dialect if you want to connect to a MariaDB server?
