Win a copy of React Cookbook: Recipes for Mastering the React Framework this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

Configuring a Spring data source

 
Ranch Hand
Posts: 33
Netbeans IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One problem I currently have is that error:


Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
Reason: Failed to determine a suitable driver class
Action:
Consider the following:
If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).




I 've put the dependency of mariadb in pom.xml and I put this on an application.properties file

spring.datasource.url=jdbc:mysql://localhost:3306/webchat
spring.datasource.username=****
spring.datasource.password=****
spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
spring.jpa.hibernate.ddl-auto=create-drop



Do I need anything more?
 
Ranch Hand
Posts: 49
Eclipse IDE MySQL Database Fedora
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Greetings,

Have you included dependencies for the jdbc driver you are using?
Do you have the database instance initialized, i.e. in you case, is mariadb initialized??
Is the url correct??
 
Phil Niksen
Ranch Hand
Posts: 33
Netbeans IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have included dependencies in my pom.xml file.
Yes, it is.
The url is correct.
 
Mishra Saurabh
Ranch Hand
Posts: 49
Eclipse IDE MySQL Database Fedora
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay mate,
I asked those questions because they are the common errors that do happen, one more silly thing that happened with me at the start was that I put my application.properties in the wrong directory.

Coming to your question again, you are using mariadb right??

And you also have the mariadb java client instead of mysql connector


spring.datasource.driver-class-name=org.mariadb.jdbc.Driver



But your url here is for the mysql driver


spring.datasource.url=jdbc:mysql://localhost:3306/webchat



although mysql and mariadb are meant to interchangeable, but if you are using mariadb jdbc you need to use  the url specific to mariadb driver
something like this : -


spring.datasource.url=jdbc:mariadb://localhost:3306/webchat



Try this, I think it will work now.
 
Mishra Saurabh
Ranch Hand
Posts: 49
Eclipse IDE MySQL Database Fedora
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One more thing, and you should check this link for that

StackOverflow - Connecting to mariadb

Here is an excerpt :-


The default configuration for MariaDB under Mageia may include the skip-networking directive in /etc/my.cnf. You will need to remove (or comment out) that directive if you want to connect to the database via JDBC because JDBC connections always look like "network" connections to MySQL/MariaDB, even if they are connections from localhost. (You may need to tweak the bind-address value to something like 0.0.0.0 as well.)

 
Phil Niksen
Ranch Hand
Posts: 33
Netbeans IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Still doesn't work...

probably the error is something bigger.One thing that bugs me is that use both application.properties and persistence.xml.The connection properties I added are the same but do I need to use both?
 
Phil Niksen
Ranch Hand
Posts: 33
Netbeans IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
After I added persistence I don't get any error, the server starts but nothing is written in my database
 
Phil Niksen
Ranch Hand
Posts: 33
Netbeans IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have my model classes plus dto classes, do I need anything more to persist into database.
 
You guys haven't done this much, have ya? I suggest you study this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic