Hskctity
Hskctity

Reputation: 33

Could not open connection [n/a] java.sql.SQLException: No suitable driver found

I am trying to make it work the jdbc connection. Following my connection to the data source.

<beans profile="devRemote">
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="com.mysql.jdbc.Driver" />
    <property name="url" value="jdbc:mariadb://192.168.0.59:3307/DEVDB" />
    <property name="username" value="maria" />
    <property name="password" value="maria" />
</bean>
</beans>
<beans profile="live">
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="com.mysql.jdbc.Driver" />
    <property name="url" value="jdbc:mariadb://127.0.0.1:3307/DEVDB" />
    <property name="username" value="root" />
    <property name="password" value="" />
</bean> 
</beans>

Funny thing is that my "devRemote" profile works with this configuration whereas my connection using the "live" profiles does not.

What I am doing is deploying my webapp (using tomcat container) in this server (192.168.0.59) which is also my database server (where mariadb is running).

The error I am getting for the connection is:

 2017-07-02 20:15:55 DEBUG SqlExceptionHelper:139 - Could not open connection [n/a]
java.sql.SQLException: No suitable driver found for jdbc:mariadb://127.0.0.1:3307/DEVDB

I checked the deployed package and it includes the JAR (mariadb-java-client-2.0.3.jar)

I am confused, I do not understand the error because having only one database, the driver should be the same for both configurations (devRemote and live)

I also double checked the privileges of the root user which I verified accessing mysql command line with usr="root" and pwd="".

Any help is appreciated.

Upvotes: 0

Views: 771

Answers (1)

bacem ounis
bacem ounis

Reputation: 86

The driverClassName of mariadb is org.mariadb.jdbc.Driverand not com.mysql.jdbc.Driver. the last one is for MySQL database.

Upvotes: 1

Related Questions