#Why I cant connect to cloud database when testing my servlet locally?

12 messages · Page 1 of 1 (latest)

shell cloak
#

I am testing my servlet locally on Tomcat with Netbeans as my IDE. I am trying to connect to Azure Database for MySQL through the servlet after getting the user's email and password. However, when I run the servlet, it stops executing at this line of code

Connection conn = DriverManager.getConnection(url, user, password);

I have obscured the url, user and password in the screenshot, but I am sure that those credentials are correct during test. I have added the JDBC connector to my project's classpath. My database's firewall is also allowed for all ip address (ik, just ignore about the security for now).
What is the problem here?

spark tokenBOT
#

This post has been reserved for your question.

Hey @shell cloak! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

gaunt night
#

and can you connect from (something like) sql workbench?

shell cloak
#

i am afraid no, I need to use the servlet to create the backend logic for my web app

gaunt night
#

so you can check if the issue is specific to connecting from a servlet or just a general "not able to connect to the DB" issue

#

though i will say, usually cloud DBs like this have network access rules so that you have to allow access from a specific IP or range of IPs

shell cloak
#

i am trying to use mysql workbench now

shell cloak
#

@gaunt night i figured it out! the error has to do with two servlets in two different projects having the same url pattern in their own web.xml file, once i removed one of them, it works