Cannot connect to AWS RDS database using SQL Workbench - jdbc

I am trying to connect to a free AWS RDS PostgreSQL database I created using SQL Workbench/J, I am following the instructions provided from AWS.
When I get to the end of Step 4, connecting to the PostgreSQL database, I keep receiving this error:
The connection attempt failed. [SQL State=08001]
I am using a Mac.

I fixed this by adding an Inbound connection rule for the database. From the AWS RDS portal goto: databases -> <your_database>. Then scroll down and ensure the 'Connectivity & security' tab is chosen. Scroll down to 'Security group rules' then follow the link for the 'EC2 Security Group - Inbound' rule. On this page, select the 'Inbound rules' tab and select the 'Edit inbound rules' button. Select 'Add Rule', the type for me was PostgreSQL, protocol TCP, I used the port the database instance is supposed to operate on (found on the AWS RDS - Connectivity & security tab for the particular database) -- i.e. 5432. Next, for Source open the drop down menu and choose 'My IP', then save changes. That was it for me.

To solve this error, go to your RDS database on AWS and click on "Modify". Now go to Connectivity and click on "Choose Security Group". Click on any of the launch-wizard options there for example "launch-wizard-1". Now save the changes. Then go to sqlworkbench and connect again. Your error will get solved.

Related

How do I create DSN of Azure databricks?

I'm trying to connect Azure databricks from another application. I need to create a databricks DSN as per the connection steps mentioned in the application. So I'm trying to create the Databricks DSN mentioning the steps given here But I'm getting following error message [Simba][ThriftExtension] (14) Unexpected response from server during a HTTP connection: Unauthorized/Forbidden error response returned, but no token expired message received.
Sorry I couldn't share with the parameters that I'm using as it's connecting to client's data. Can you suggest me what could be the possible reason for error?
I downloaded and installed odbc driver from this page.
Image for reference:
searched for open data source on start menu and opened it and selected Simba Spark under System DSN.
Image for reference:
filled the required details from azure Databricks, for that
we need to follow below steps:
Navigate to azure Databricks compute option and select the cluster.
Click on at cluster configuration advanced options and select JDBC/ODBC option.
Copy host name, port and http path.
Go to username at left top of data bricks page and select user settings
Generate access token
Copy and save the access token.
By clicking on Simba Spark system DSN
we will get below page
Enter Data source name, description and Enter Server Hostname of Databricks as Host, enter port of Databricks, select Username and password option enter token as username and enter access token of Databricks as password
select HTTP and enter HTTP Path of Databricks as HTTP path click OK.
After above setting I tested the connection I go below error
I selected SSL Option and enabled SSL
I tested again the connection is successful.
In this way I created DSN for Databricks.

An error happened while reading data from the provider. The remote certificate is invalid according to the validation procedure

I'm trying to connect Postgres Database on AWS EC2 instance to Microsoft PowerBI. I tried various method available on internet but its showing the above error. Although I've done this connection on AWS RDS. I installed required dependencies (GAC) and all the certificates required for PowerBI.
Following worked for me:
File / Options and settings / Data source settings
then select data source
and Edit Permissions and uncheck encrypt connections
I've came across the same issue, unfortunately I didn't find solution to resolve it. But I found an alternative.
You can connect PostgreSQL using ODBC Connection.
Setup ODBC for PostgreSQL: https://www.postgresql.org/ftp/odbc/versions/msi/
After Installation, Select ODBC Connection under "Get Data"
Select "None" under Data Source Name and
add following statement under connection string:
Driver={PostgreSQL ANSI(x64)};Server=<host>;Port=5432;Database=<dbname>
Click "Next"
Enter Username and Password, Click Connect.
If credentials are correct, you will see list of tables available in database.
Follow this reference for detailed description:
http://niftit.com/connecting-power-bi-to-postgresql/
Two hours wasted, so writing in full.
Download and install postgresql ODBC driver
Goto below URL
URL: https://www.postgresql.org/ftp/odbc/versions/msi/
Scroll down
Click on a zip file to download (i took psqlodbc_12_00_0000-x64.zip)
Unzip file
Run the .MSI file
Take all defaults given and install it
Create ODBC data source
Find the ODBC data source using below (I took "ODBC Data Sources (64-bit)"):
Windows > Start button > search for "ODBC Data Sources"
User DSN > PostgreSQL ANSI(x64) > Finish
Give details
Data source name : PostgreSQL30 ###
DB name *** , server, port, username, pwd
SSL mode = disabled (default)
click on Test button
"Connection successful" message will come, else re-check details above.
We now have a new User DS, with PostgreSQL30 created
Download Power BI
Windows > Start button > Microsoft Store
Search for "Power BI Desktop" > Get/Install
Source: https://learn.microsoft.com/en-us/power-bi/desktop-get-the-desktop#download-power-bi-desktop
Running the Power BI
Get Data (On the left)
Search for "odbc" > Select "ODBC" on right pane > Connect
DSN > PostgreSQL30 ( --- this is same as above ### --- )
OK
"Navigator" dialog is shown, with "Display Options"
ODBC ... PostgreSQL30
> DB name ( --- this is same as above *** --- )
Open the > button on left of DB name
select the tables
click "Load" button
Done.
You have successfully connected Power BI (PBI) to your postgres or other database.
Hope this helps.
For AWS look at this case https://community.powerbi.com/t5/Desktop/The-remote-certificate-is-invalid-according-to-the-validation/td-p/531475
For non-AWS issue you should configure SSL according to Npgsql documentation https://www.npgsql.org/doc/security.html or you can disable SSL option in postgresql.conf on postgresql server.
adding onto #chirag sanghvi answer
You may get an error
ERROR: character 0xefbfbd of encoding "UTF8" has no equivalent in "WIN1252"
because your database is encoded in UTF-8
Install this driver
https://github.com/npgsql/npgsql/releases/tag/v4.1.3
then in your connection string use the Unicode driver
Driver={PostgreSQL Unicode(x64)};Server=;Port=5432;Database=

Connect with remote MySQL Database from Herokou

I am installing WordPress on Herokou app, I want to use external MySQL database that is hosted on Google SQL Cloud. I need a static IP or IP pool to enable on Goolges side firewall I can't figure out how to do so? or if this is a valid option using Herokou
Love to hear your thoughts
Using the Google Developer Console, select your Cloud SQL instance, go to 'ACCESS CONTROL' tab and add your application static IP Address/IP pool to the 'Authorize Networks' section. This will enable access to Cloud SQL instance from those IP addresses.

Cannot connect to AWS EC2 from visual studio (or anywhere actually)

I have an AWS server (MS SQL SERVER EXPRESS 2008 R2 with IIS), with an elastic IP of 54.214.8.111, security groups configured with HTTP, MS SQL and FTP, and I can connect to the remote virtual machine using the rdp file that amazon gives you in the console.
However when I try to connect via visual studio to test if the database is working, it gives me a "Login failed for user 'dbuser' error. I have a user called dbuser on my SQL Server (on the server side of course) with full access permissions etc. I also cannot connect to an ftp on the server, despite all guides and help doc. Something seems to be simply blocking my connection. I have tried the same thing on multiple computers.
Everything seems to be configured correctly except I suspect the server instance.
Can anyone help? PS I'm fairly new to web development, this is my first AWS EC2 server.
[UPDATE] I just tried to create a new instance in a different location, same error, maybe I don't know how to configure the SQL Server on the EC2?
I recently had the same connectivity issue to AWS/SQL Server, I finally have it resolved.
Connecting to SQL Server remotely on AWS involves 3 main factors:
AWS --> Windows Security --> SQL Server Settings/Security.
Connections can easily fail because each area has specific requirements. I'll go through the check-list:
AWS:
In AWS management console, go to Security Groups, click on the group that applies to your windows server, make sure MS SQL TCP port 1433 is open to your specific client IP. If not, you'll need to add it.
*UPDATE 5/10/22: In the inbound-security in AWS, if you enter 0.0.0.0 for source IP it will open that port publicly, you should not open the port to everyone. Only open this port to specific IP addresses and take additional security measures to protect it, allowing only authenticated users to access. Read up on security and how to configure to protect your SQL server.
Note the Public IP of your server
WINDOWS:
RDP to the Amazon Windows server, Start > Administrative Tools > Local Security Policy
Click Windows Firewall with Advanced Security, Windows Firewall Properties, Click the "Public Profile" tab, set Firewall State to "ON", Inbound to Block, Outbound to Allow (or block depending on your application). OK.
Expand the Windows Firewall (on the left Pane), R-Click the Inbound Rule, Click New Rule.
Click Port option, Next > , for TCP, enter 1433 Next >, Allow the connection, Next >, Next > , give it a name (SQL-PORT-ACCESS)
SQL-SERVER:
Login to SQL Server with SSMS (SQL Server Management Studio) using the default windows authentication.
On the left-pane, R-click the top server listing (with the database icon, the very first listing), and select "Properties"
Properties window, click Security on the left pane, choose the "SQL Server and Windows Auth"
Click Connections, check the "Allow Remote Connections" option ... Click OK.
Open the SQL Configuration Manager, Start > Programs > Microsoft SQL Server > Configuration Tools > SQL Server Configuration Manager
SQL Server Network Configuration (Expand), select Protocols for MSSQL, R-Click TCP , select Properties (TCP should be enabled)
Click IP Addresses tab, check that IP1 is enabled, Dynamic Ports is 0, TCP port is 1433
Scroll all the way down to IPAll section, Enter 0 in TCP Dynamic Ports, and 1433 in TCP Port. OK...
Back on the left pane, click, SQL Server Services, R-Click the SQL Server option, and select "Restart".
(NOTE: SQL Browser server does not impact connectivity, browser service only lists available servers, with your specific connection parms, no need to start or worry about the browser)
TESTING:
You don't have go to your remote client to test, start by trying to connect from the same SSMS window on the server. This reduces all the other things that can go wrong at first, if you can connect here, you have some confirmation that it works. If it doesn't work from your own server, the issues are related to Windows security and SQL security and setup.
Under the Object Explorer (SQL server Management Studio), click "Connect" > Database Engine...
In the Server name:, enter your PUBLIC IP, a comma, then 1433. Example, if your public IP is 54.4.4.4 , enter 54.4.4.4,1433,
Select the authentication as "SQL Server", enter the login user and password.
If you're using "sa", remember to change the password.
If your connection works locally, then you can try your remote client connection.
At this point you know your SQL server and user settings are correct.
Next, try using SSMS on another computer. If that fails, probably the firewall needs a 2nd look...
Good place to understand issues, is the SQL logs easily accessible from SSMS, on the left pane, expand Management, then SQL Server Logs, current log will list any problems.
So, those are all the parts involved -- miss one and you'll be frustrated, but start by reducing the pieces when testing.
I was able to connect to my database on AWS Windows Server/SQL Express from a Windows device...
Good Luck!

Connecting to database on web host in Visual Studio or Sql Server Management Studio

I have a web site developed locally with a local Sql Server database. I also have a web host that provides one Sql Server database for my site. Now I want to deploy the application, and I would like to be able to manage the remote database from the Server Explorer in Visual Studio. I have the connection string used in the application, which works fine for adding, say, a datasource to a control etc. But I don't know if there's any way to use it to connect the database inside the Server Explorer so that I can add tables etc. I have read that you're supposed to be able to this instead of using the Sql Server Management Studio, but I have'nt read anything about how to connect to the remote database in it.
What I have tried so far is this: I have selected Add database in Server Explorer. This brings up first a dialog where I choose Sql Server. And then I get a dialog where I can set Server name (which I tried using the ip address in the connection string below), and Authentication (where I chose Sql Server Authentication, with the user id and password from below). But when I test the connection it fails.
Here's the connection string, which works fine when used for datasources in the application (obviously with different user name and password):
Any help appreciated!
EDIT:
Well, I've done everything suggested by lewiguez below now, but it doesn't make any difference. I can't believe this should be so hard... I keep getting this error message in Sql Server Management Studio:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) (Microsoft SQL Server, Error: 53)
Here's the process I follow for working with remote databases:
In VS 2008 under the Server
Explorer tab, right-click on "Data
Connections" and then click "Add
Connection"
Change the Data Source to
"Microsoft Sql Server"
Put in your fully-qualified
"Server Name" (be it IP Address, domain name, etc.), select "Sql Server
Authentication" and put in "User
Name" and "Password" for the database user
Select the database you want to connect to under "Select or enter a database name"
Hit "Test Connection" to test and then "OK" to accept
You should be able to interact with the database at this point by expanding the connection and then the "Tables" folder. For example, right-click on the Tables folder and you'll be presented with an "Add Table" option in the dialog. Right-clicking an existing table will bring up the "Open Table Definition" options where you can change any columns, etc.
If you're not getting to this point (and it sounds like you're not), I'd recommend checking your Sql Server connection from whatever machine you're using.
I generally do this by going into the Management Studio and connect with whatever credentials I'm trying to use. If they don't work, make sure they are, in fact, added as a Sql Server user and a database user (they have to be both).
Also, I would check in the Sql Server Surface Area Configuration Manager. You have to allow TCP connections and you have to be set up to allow Sql Server Authentication connections as well from remote hosts. If THAT'S all set up, but you still can't connect, I'd double-check to make sure your firewall is allowing Sql Server connections. The default port is 1433.
Also, if you can connect, but then can't write to anything, double-check your table permissions. Hope this helps!
I finally understood the problem: as I suspected the settings in my own installation was not the problem, but rather it was the settings on the Sql Server installation on my web host. And in fact I found a place in the control panel on my web host where I could set an exception to my ip address so that my ip would be granted access to the port 1433 for Sql Server, which is otherwise closed by default for security reasons.
I've had no luck finding any information about this at all on the internet, which I find strange. All the information I could find had to do with changing these settings on your own local installation of Sql Server. But I'm sure there are loads of people out there who like me use a web host for deploying their web site, and then that info doesn't seem to apply. (Perhaps apart from the TCP setting, which I think must be set, and there's detailed info about that here: http://www.linglom.com/2009/03/28/enable-remote-connection-on-sql-server-2008-express/ )
Hope this helps someone else who like me uses a web host. Now everything works fine for me at least, both in Management Studio and in Visual Studio Server Explorer.

Resources