not able to connect google cloud sql from google app engine
getting
logMessage: "[
j~gcp-ws-203608/20180510t123822.409615356828549281].<stdout>: 2018-05-10 07:20:08.036 ERROR 1 --- [Request5396402F] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Exception during pool initialization.
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_112-google-v7]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_112-google-v7]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_112-google-v7]
at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[na:1.8.0_112-google-v7]
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411) ~[jdbc-mysql-connector.jar:na]
at com.mysql.jdbc.Util.getInstance(Util.java:386) ~[jdbc-mysql-connector.jar:na]
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1014) ~[jdbc-mysql-connector.jar:na]
dependency used:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.google.cloud.sql</groupId>
<artifactId>mysql-socket-factory-connector-j-6</artifactId>
<version>1.0.5</version>
</dependency>
It seems that something might be wrong with the way you are setting up the connection to the database.
Please make sure that:
The proper service account for accessing Cloud SQL from App Engine is setup (if the App Engine application and the Cloud SQL instance are in different Google Cloud Platform projects)
You have an already created database in Cloud SQL
You have added all the correct parameter values (Cloud SQL instance connection name, database, user, and password) to the pom.xml file.
You are creating a connection URL and establishing a connection to the database in the same way it is done in this example
Related
I have developed an application in asp.net core EF, with MySql DB. Application is deployed on Google Cloud App Engine. I am trying Connecting Google Cloud App Engine application to Cloud MySql under same cloud project. Locally i am able to connect this database, but when deployed on google cloud i am getting error
MySqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
MySql.Data.Common.StreamCreator.GetTcpStream(MySqlConnectionStringBuilder settings)
MySqlException: Unable to connect to any of the specified MySQL hosts.**
MySql.Data.MySqlClient.NativeDriver.Open()
I am using below connecting string
"DefaultConnection": "host=33.444.**.**;port=3306;database=mYdb;user=root;password=pASS"
img
Take a look at the "Connecting from App Engine" page here on the Cloud SQL docs. You need to enable the Cloud SQL server in your app.yaml, and then connect via 127.0.0.1:5432.
I have set up 2 projects in my Google Cloud console. The following are the two projects that I have set up in my console.
1. Cloud SQL + App Engine
2. App Engine (New)
So the idea is App Engine (1) is running the same database as App Engine (2). I have already set up the IAM Permission Page and IAM Admin and Project Page.
I have given both projects as Project Editor role too, but still my (2) still can't connect to my (1) database.
Any help please?
Granting access to an application does not automatically enable a database user account to connect to the instance.
You may connect through a proxy, in which case you should follow these steps:
Enable the API
Install the proxy client on your local machine
Determine how you will authenticate the proxy
If required by your authentication method, create a service account
Determine how you will specify your instances for the proxy
Start the proxy
Update your application to connect to Cloud SQL using the proxy
You can find related details on the Connecting to Cloud SQL from External Applications.
This documents provides steps that cover configuring access for IP connections as well.
If you connect from within the app engine environment, you may have a look at Connecting from App Engine.
I'm trying configure a app in Spring Boot to connect with Azure DataBase using com.microsoft.sqlserver.jdbc.SQLServerDriver driver.
This is my configuration:
spring.datasource.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
spring.datasource.url=jdbc:sqlserver://hdonrns815.database.windows.net:1433;databaseName=code_dev
spring.datasource.username=user
spring.datasource.password=password
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.SQLServerDialect
spring.jpa.show-sql=true
this is my SQL Server pom.xml configuration:
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
</dependency>
And this is the error:
com.microsoft.sqlserver.jdbc.SQLServerException: SQL Server did not return a response. The connection has been closed. ClientConnectionId:d7304f30-4c29-4258-ac9f-4409dee20fdd
I can connect to the DB from Sql Server management.
I don't know what happend.
Thanks.
Allow Azure Services to access Azure SQL.
Reference: https://learn.microsoft.com/en-us/azure/sql-database/sql-database-firewall-configure#connecting-from-azure
I have two identical Windows 2012 R2 environments. One is for development and the other is for staging.
For my server-side language I am using PHP and the Laravel 4.1 Framework.
I have a service account that I use for both environments to connect to our MSSQL development database. I set the service account to the application pool and assign that application pool to the application within IIS 8.5. I have done this numerous times with no issues. This avoids us storing the password in the PHP database config file within Laravel.
Now, the application I built is running fine in development. I can connect to the database using the method described above. I copied the identical code over to staging, again using the same environment and the same service account, but I get the dreaded:
PDOException
SQLSTATE[28000]: [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'.
Because it is working in development with no issues and because I have other applications on my staging box that are successfully able to connect, I am at a complete loss as to why this application can't connect in test. I spent hours yesterday troubleshooting with no luck.
Any ideas?
The issue had to do with the ApplicationHost.config file. The other applications and app pools had an attribute of userName="" which the application that was causing the issue did not. I manually added the attribute and this resolved my issue.
<location path="Default Web Site/application-name">
<system.webServer>
<security>
<authentication>
<basicAuthentication enabled="false" />
<anonymousAuthentication enabled="true" userName="" />
</authentication>
</security>
<handlers>
I have what I thought would have been a pretty normal scenario...
I have a
-WCF Client
-WCF service hosted in AppFarbic within IIS7.5
-SQL Server 2008 r2
IIS is running using the App Pool Identity
I am connecting from the client using the following config file
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<client>
<endpoint
name="NetTcpBinding_IXXXService"
address="net.tcp://app02.xx.com/XXXService/XXXService.svc"
binding="netTcpBinding"
contract="XXXClient.IXXXService">
<identity>
<servicePrincipalName value="host/app02.xx.com" />
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>
IIS is running using the application pool identity.
I can get the service to connect to the database if I create a \$ login.
When using the application pool identity is this the only way of connecting to the database using Windows authentication?
I presume this is allowing the Network Service account on this machine to access the database. I also presume that this also means any service running as network can access the database?
Is there any of way of tying the application pool identity to the database login?
EDIT: When I change the user of the App Pool to be another user with access to the database I get an SSPI failed error
Please forgive me for taking a stab at this when I am not familiar with WCF or AppFarbic. Though I do know a little about IIS and authentication to SQL server on different server.
Can you connect to the database if you use username-based security with a password?
What authentication method are you using on the web site?
If you are trying to use integrated Windows authentication and your web authentication method is also integrated, then you have to use Kerberos security in IIS to allow delegation for the "second hop" over the network to the SQL server. Regular NT security is not enough because it can only do impersonation, which doesn't allow this. Getting delegation to work can be a pain in the butt, but you have to examine the SPN you're using and make sure it's properly registered on the SQL server, plus mess around with IIS to make sure that Kerberos is enabled and actually working instead of it silently slipping back to NTLM. The web server also has to be "trusted for delegation" in the domain group policy (assuming your web server is joined to a domain).