Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setup spring-boot project with mysql database using mysql driver

MySQL connector is a part of maven dependencies and all the database properties like url,username,password are mentioned in the application.properties.

Getting a RuntimeException, like:

Driver com.mysql.jdbc.Driver claims to not accept jdbcUrl, jdbc/mysql://10.53.235.141:3306/hms.

Please help with the solution.

application.properties

 spring.datasource.url=jdbc/mysql://10.53.235.141:3306/hms
 spring.datasource.username="root"
 spring.datasource.password="password"
 spring.datasource.driverClassName=com.mysql.jdbc.Driver
 spring.jpa.database = MYSQL

[![Project setup structure][1]][1]

Exception in the console

like image 965
Rakesh .p Avatar asked Jan 08 '19 12:01

Rakesh .p


People also ask

What is MySQL driver dependency in spring boot?

The spring-boot-starter-data-jpa is a starter for using Spring Data JPA with Hibernate. The mysql-connector-java dependency is for the MySQL database driver. The spring-boot-maven-plugin provides Spring Boot support in Maven, allowing us to package executable JAR or WAR archives.

How do I connect to a MySQL driver?

Driver. Connection URL: The connection URL for the mysql database is jdbc:mysql://localhost:3306/sonoo where jdbc is the API, mysql is the database, localhost is the server name on which mysql is running, we may also use IP address, 3306 is the port number and sonoo is the database name.

Can we configure MySQL with spring boot?

Spring Boot has support for MySQL and a number of other popular relational databases. Out of the box, Spring Boot is very easy to use with the H2 Database. If the H2 database is found on your classpath, Spring Boot will automatically set up an in memory H2 database for your use.


2 Answers

Format of URL is wrong, use below URL

spring.datasource.url=jdbc:mysql://10.53.235.141:3306/hms

instead of

spring.datasource.url=jdbc/mysql://10.53.235.141:3306/hms
like image 144
Santosh Avatar answered Nov 14 '22 22:11

Santosh


Your url is wrong use this

jdbc:mysql://10.53.235.141:3306/hms"
like image 37
Shubh Avatar answered Nov 14 '22 23:11

Shubh