Unable to connect to Database (Java application)

tchitos
TRIAL

5 months ago

Hello everyone,

I'm trying to deploy a Java Spring backend.

I've already created a database in Railway. I've register every environnement variables in VSCode (dburl, dbuser …) and it works perfectly. Tables got created in my Railway database.

However, when I deploy the application on Railway, the build completes successfully, but I encounter the following error at startup:

"
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
"

To debug, I added logs to print the database URL that the app retrieves at runtime, and it's correct—the exact same URL as the one I use locally (the public URL found under "Variables" in my Railway MySQL database settings).

Here is the project repo (a simple API for a demo):

https://github.com/Tchitos/Thilabank-backend/tree/master

I've tried many solutions (even with chatGPT suggestions), test every possible url in my shared variables, but now as it works in local, I don't know why it's not working on Railway.

I've tried multiple solutions (including suggestions from ChatGPT), tested different database URL formats in the environment variables, but since everything works locally, I don’t understand why it fails on Railway.

If anyone has a solution or an idea I haven't tried yet, I’d be really grateful for your help! 😃

Thanks in advance!

View Deploy details

ⓘ Deployment information is only viewable by project members and Railway employees.

0 Replies