Multiple connection Problem

I have a project that uses two connections. It is working on the localhost (Developer PC) but when I deployed it on Webserver second connection seems to be not working and software throws an error

An error occurred while connecting to the database:
Connection attempt failed: SQLSTATE[HY000] [1045] Access denied for user ‘USERNAME’@‘localhost’ (using password: YES)

anybody has this problem before

Hi Naresh: assuming that you’re using the correct credentials to connect to the Webserver database, then it could be a security issue.

Did you create the connections using the production environment or did you created them in code?

Could you check both connections works using the production environment in the webserver?

Regards,

Hi @tfertil,

Thanks for coming back to me. I have used connection in production Environment.

Let me explain you all the working & not working scenarios:
Working Scenarios:
A) Connection1: localhost , Connection2: localhost
B) Connection1: localhost, Connection2 Remote server
Not working
A) Connection1: Webserver(remote) Connection2: Webserver Remote
Connection1 & Connection2 has same DB server, Different DB and Users for DB.
Connection1 is the main and it work but there are some application that use connection 2 but on its connetion it sends an error and which tries to map the connection2 on my localnetwork.

I ensure that I have assigned the correct information in both the connection.

I think it is a bug in scriptcase.

An error occurred while connecting to the database:
Connection attempt failed: SQLSTATE[HY000] [1045] Access denied for user ‘USERNAME’@‘MyNetworkIP’ (using password: YES)

How come I get the MyNetworkIP:: my router IP, my server is hosted in UKfast and how come it tried to get my localhost?

This is MySQL telling you that the user you are connecting with doesn’t have rights to connect.
When creating a user you either need to explicitly define the host (IP Address) or use a wildcard host, which in MySQL is the percent sign %
So USERNAME@% should work… but some hosts won’t let you do that so you need to find the external IP of where you are connecting from and use that as the host like USERNAME@123.123.123.123 using the external IP you found.

Also some hosts (most) require you allow “External MySQL” access through the firewall… MySQL uses port 3306 by default.

I hope this information sends you in the right direction to solving your problem.

Thank you @yourguide, I totally agree with your points above. I tried every possible connection but didn’t work. I even sent the copy of my projects and the connection detail of my Database server to scriptcase but they didn’t even look into it once. And I had to deliver my projects on time so I created API from the second connection and use the API in the system. I think Scriptcase should look into this problem seriously. As I mentioned you earlier it works on the localhost but as soon as you sent over the internet it doesn’t work.

This is a bug.

In case it helps anyone…

I just spent many frustrating hours on this… when I got to the bottom of the problem it was my own fault.

I’d created 2 connections in the IDE environment and got my app working perfectly.

When I transferred it to my production environment, the problem appeared.

As it turns out (Despite being sure I had done so), the second connection was not setup in the prod environment… hence the misleading SQL user message.

SO

Make sure that your connections are BOTH setup in the prod environment.