I am new to spring boot and I want to connect my database with jdbc to spring boot project. It is succeeding only for one database and when I change the name of database to another it won't work. In my project I have done only connecting database to spring boot. So I think it should work when database name change. I am grateful if someone can help me with my problem.
ERROR
Access denied for user ''@'localhost' to database 'daddycoffeeshop_db'.
and
Error creating bean with name 'jdbcConverter' defined in class path resource
application.properties
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/daddycoffeeshop_db
spring.datasource.username=root
spring.datasource.password=
Here daddycoffeeshop_db is not working but test database is working. Why is it?
Other codes... DaddyCoffeeShoApplication.java
package com.example.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class DaddyCoffeeeShopApplication {
public static void main(String[] args) {
SpringApplication.run(DaddyCoffeeeShopApplication.class, args);
}
}
TestData.java
package com.example.demo;
import javax.sql.DataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
@Component
public class TestData implements CommandLineRunner {
@Autowired
private JdbcTemplate jt;
@Autowired
private DataSource ds;
@Override
public void run(String... args) throws Exception {
String sql = "INSERT INTO RODUCT_DETAILS VALUES(?,?,?,?)" ;
int count = jt.update(sql, 10, "A", 234.45,"this is babysoap");
System.out.print("Inserted Rows" + count);
}
}