Can not connect to Heroku's database remotely (Java) - java

I am trying to connect to my database remotely:
connection = DriverManager.getConnection(URL);
URL is of following format (all XXX values copied from Heroku's website):
jdbc:postgresql://XXX:XXX/XXXX?sslmode=require&user=XXX&password=XXXXX
I am getting:
org.postgresql.util.PSQLException: FATAL: no pg_hba.conf entry for host "213......, SSL off
I had run (it didn't change "SSL off" status):
heroku config:set PGSSLMODE=require --app XXXXXX
and even added this to the URL as suggested in older posts (althought I didn't see any of it in Heroku's doc):
sslfactory=org.postgresql.ssl.NonValidatingFactory

Make sure you are using PG JDBC client 9.4 or higher. Your JDBC connection URL will need to include the URL param:
sslmode=require
For example:
jdbc:postgresql://<host>:<port>/<dbname>?sslmode=require&user=<username>&password=<password>
For more info see Heroku docs on Connecting to a database remotely.

Related

How to connect to MSSQL from Pentaho?

I am trying to connect Pentaho to my local MSSQL server.
I start Microsoft SQL Server Management Studio and I am promted with this window and then just click Connect:
I am using Java 8 Update 261 and Pentaho 7.1. I have downloaded MSSQL JDBC driver from following link:
https://learn.microsoft.com/en-us/sql/connect/jdbc/download-microsoft-jdbc-driver-for-sql-server?view=sql-server-ver15
and put mssql-jdbc-8.4.1.jre8.jar into pdi-ce-7.1.0.0-12\data-integration\lib folder. Also I have coppied file mssql-jdbc_auth-8.4.1.x64.dll into C:\Program Files\Java\jre1.8.0_261\bin...
Now when I start Pentaho via Spoon.bat file, and try to add MSSQL connection, I get errors, furthermore I have no idea what I am supposed to enter into fields:
HOSTNAME: ?
DATABASE NAME: (name of database is PROFIT)
INSTANCE NAME: ?
PORT: 1433
USERNAME: ?
PASSWORD: ?
From the picture you can see what I have entered. I also checked Use Integrated Security box.
I get following error:
Error connecting to database: (using class com.microsoft.sqlserver.jdbc.SQLServerDriver)
The TCP/IP connection to the host DESKTOP-CS70NHL, port 1433 has failed. Error: "Socket operation on nonsocket: configureBlocking. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.".

Configuration of AWS with Sequel Pro

I am using Sequel Pro 1.1.2 in MacOS Mojave, when trying to configure the AWS database instance getting error as
" Unable to connect to host vinay-awsdb.cinbpy8tpejb.eu-west-1.rds.amazonaws.com, or the request timed out.
Be sure that the address is correct and that you have the necessary privileges, or try increasing the connection timeout (currently 10 seconds).
MySQL said: Can't connect to MySQL server on 'vinay-awsdb.cinbpy8tpejb.eu-west-1.rds.amazonaws.com' (4)"
In the standard connection mac for Sequel Pro,I am entering the following:
Name: (used my instance name which is vinns, and also tried leaving it with the default of 'optional')
Host:vinay-awsdb.cinbpy8tpejb.eu-west-1.rds.amazonaws.com
Username: (used my master user name)
Password: (used my master users password)
Database: (used database name mydbname, and also tried leaving it with the default of 'optional')
Port:3306
I am not able to connect.
I also tried by changing the Inbound rules to anywhere and increased connection timeout to 60 but did not worked

Unable to connect to the MySQL server

In admin properties, the paths are correct but, this error always appears whenever I try to connect to MySQL server from NetBeans.
Unable to connect to the MySQl server:
org.netbeans.api.db.explorer.DatabaseException:Cannot establish a connection to jdbc:mysql://localhost:3306 for user root"
You need to install Download Connector/J (This is the official JDBC driver for MySQL.)
Official Download Page: http://dev.mysql.com/downloads/connector/j/

Error while trying to connect to database through eclipse database development perspective

This is error stack trace i am getting...
Could not connect to mydb.
Error creating SQL Model Connection connection to mydb. (Error: oracle.jdbc.OracleDriver)
oracle.jdbc.OracleDriver
Error creating JDBC Connection connection to mydb. (Error: oracle.jdbc.OracleDriver)
oracle.jdbc.OracleDriver.
I am using oracle thin driver to connect to database..
SID: db
Host: localhost
Port number 1521
User name: system
Password:
Connection URL: jdbc:oraclethin:©lccalhost:1521:db
I can't even able to ping the database...
There is a typo in your connection URL. It says lccalhost instead of localhost. Try:
jdbc:oraclethin:©localhost:1521:db
Furthermore, your log says mydb instead of db as stated in your connection settings. So, this may be another possible cause of fault.
I think you are using xpress edition 11-g and if so then try changing the SID from db to xe and then it should work fine .
If you are using the standard edition then you must check with the odbc jars .
Try adding odbc6 jar

Connection JDBC SQL Server Error

I've tryed to create a connection with a Microsoft SQl Server 2008 database through JDBC on Eclipse SDK. I've dowloaded JDBC driver from microsoft and I've installed it, then I've added at my System environment variables CLASSPATH the path of sqljdbc4.jar file. After icluding in the Eclipse project the jar file I've tryed to create the connection using:
String connectionUrl = "jdbc:sqlserver://localhost;integratedSecurity=true";
Connection con = DriverManager.getConnection(connectionUrl);
but it doesn't works, and launch me this exception:
com.microsoft.sqlserver.jdbc.SQLServerException: TCP/IP connection
at host localhost, port 1433 failed. Error: "Connection refused:
connect. Verify connection properties and make sure an instance of SQL
Server is running on the host and is accepting TCP/IP connections at
the port. Be sure no firewall blocks connections at the port.
I'm working on a JRE 1.6 so a sqljdbc4 should work, and I've created a working ODBC, so the server is responding, and the error should be in java command or JDBC installation.
Can anyone help me?
At the risk of stating the obvious, this looks to me as if TCP connections haven't been enabled on SQL Server. You have to manually enable them, they don't come enabled by default.
There's an article on MSDN here which explains how to enable TCP protocols for SQL 2005/2008.
Following are the quick trouble shooters:
Try to connect to your server using external front end.
Check if your firewall blocks the connection to the port
Check to see if server is really up.
A Suggestion :
If you are using eclipse , you don't need to add the jar into CLASSPATH variable , you can just add it in library of your project to make it available at runtime

Categories