Cannot connect to database through Intellij's Data Sources and Drivers - java

I have a problem with displaying my databse structure through Intellij's Data Sources and Drivers page. I can connect to my database which is hosted on a redhat server through using application.properties of my spring project:
spring.datasource.url=jdbc:postgresql://192.168.0.38:5432/cms_database
which works fine. Although, whenever I try to use Intellij's Data Sources and Drivers page I get an Error Message:
[3D000] FATAL: database "cms_database" does not exist.
I can test to connect to database "postgres" which returns a Connection:
DBMS: PostgreSQL (ver. 13.0) Case sensitivity: plain=lower,
delimited=exact Driver: PostgreSQL JDBC Driver (ver. 42.2.5, JDBC4.2)
Ping: 16 ms SSL: no
Any help would be appreciated. If you need any extra info I would be happy to post!

Try to connect with settings from this example
I think you will set hostname wrongly

Related

How to connect springboot with MSSQL Server using Hibernate

I try to connect my Springboot application to my local MSSQL Server with hibernate. For now I've set up a local ms sql server. I couldn't establish a connection to my database using IntelliJ CE and the JPA buddy.
On the net I found a guide that used IntelliJ UE. I installed the 30 day trial and with the ultimate version I could establish a connection with the database (using View->Tool Windows->Database, SSL is not enabled).
Even though the URL is kinda messy with "...server://./db". If I replace the '//./' with '//localhost/' it does not work anymore.
Now, I soon won't have access to the ultimate version anymore. So, my question is: How do I get the same behaviour with the JPA buddy and IntelliJ Community Edition?
I guess that it is related to the selected driver 'MS SQL Server ->LocalDB<-'.
When I use the following JPA settings, it does not work in the community version (it doesnt matter if I use the 'jtds' driver or not):
In both cases I get "Error during login for the user 'dbuser'". (The server is local and I don't have SSL enabled, therefore the ';encrypt=false')
I also tried to use the application.properties with the following content:
spring.datasource.driver-class-name=com.microsoft.sqlserver.jdbc.SQLServerDriver
spring.datasource.url=jdbc:sqlserver://localhost;encrypt=false
spring.datasource.username=dbuser
spring.datasource.password=...
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQLDialect
spring.jpa.hibernate.ddl-auto=update
But this didn't work either.
Any help is appreciated.

Mysql pool connection error with glassfish/payara server

Ping Connection Pool failed for MySQL Pool. Connection could not be allocated because: Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. Please check the server.log for more details.
In my case this problem got fixed by adding "useSSL" to the pool properties and setting it to false.
This solution works for payara 5 and Mysql 8
Select Mysql 8 as Database Driver Vendor
When you try create the connection pool remove all default propierties and write the properties manually as shown in the below image, something is wrong with default properties becuase the connection can't be reached so to avoid issues please remove them and try add them manually.
Note: don't forget add your mysql connector to
glassfish5\glassfish\lib
glassfish5\glassfish\domains\domain1\lib
If you are trying to connect to MySQL on cloud (Ex. Azure MySQL) make sure the SSL enforcement is off in addition to above and setting useSSL = false.
Azure MySQL
I just want to give solution here as I already read and view many solutions regarding this error but not anyone of them is good for me.
So please follow the step by step process:-
Download and Install Glassfish/Payara Server.
Download and Install latest mysql.
Install it as full and in mysql folder you can find an Connector j folder.
from there copy the executable jar file and paste it into two folders.
glassfish5\glassfish\lib
glassfish5\glassfish\domains\domain1\lib
Now restart the server from netbeans.
Open admin console and then goto JDBC and then select jdbc connection pool
Add particular property :-
Database name
Password
port :- 3306
ServerName :- localhost
Url :-jdbc:mysql://localhost:3306/test
User
6.Enable ping
save
Best of luck

How to connect to Oracle Database 12c HR schema from IntelliJ IDEA 14

I am new in Oracle Database. I have successfully done these:
Installed and configured Oracle Database 12c in Windows 10 VMware virtual machine.
Connected to HR schema from SQL*PLUS, SQL Developer, Navicat.
Created a ASP.NET web application project and connected to HR schema from Visual Studio 2015.
Now I want to connect to HR schema through JDBC from IntelliJ IDEA 14. Unfortunately I cannot connect though I have installed JDBC drivers. I have read the reference here but it does not work. I am getting the following error:
Connection to Oracle - HR#localhost failed
java.sql.SQLException: Listener refused the connection with the following error:
ORA-12514, TNS:listener does not currently know of service requested in connect descriptor
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:489)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:553)
...
For better demonstration, a screenshot is attached. Notice that I cannot define the service name (in this case "pdborcl") because there is no text field for this in Data Sources and Drivers window. Also notice that I can still connect to HR schema through SQL*PLUS after the error.
How to resolve this issue? Or, is it an IntelliJ IDEA bug or a JDBC bug?
You should be using "pdborcl" in the Database field. That is your service name, HR is just a schema in it.

Exception while connecting to DB2 in java using JDBC

I am trying to connect to a db2 database in Java. Below the driver and the connection string and the driver details i am giving
Class.forName("COM.ibm.db2.jdbc.net.DB2Driver");
String url="jdbc:db2://hostname:portnumber/databasename";
sourceConnection=DriverManager.getConnection(url,"username","password");
But I am getting the below exception
"COM.ibm.db2.jdbc.DB2Exception: [IBM][JDBC Driver] CLI0615E Error receiving from socket, server is not responding. SQLSTATE=08S01"
I also tried changing the connection string to
String url="jdbc:db2:hostname:portnumber/databasename";
Still it is resulting the same exception above while trying to get the Connection.
And i have tried the below option also using JDBC app driver
Class.forName("COM.ibm.db2.jdbc.app.DB2Driver");
DB2DataSource db2ds = new DB2DataSource();
db2ds.setServerName("hostname");
db2ds.setPortNumber(portnumber);
db2ds.setDatabaseName("databasename");
db2ds.setUser("username");
db2ds.setPassword("password");
sourceConnection=db2ds.getConnection();
For the above two connection I used the jar "db2java.jar"
And i have tried using the JCC driver:
Class.forName("com.ibm.db2.jcc.DB2Driver");
String url="jdbc:db2://hostname:portnumber/databasename";
sourceConnection=DriverManager.getConnection(url,"username","password");
For this connection i have added the below jars
1)db2jcc.jar
2)db2jcc_license_cu.jar
This time around I am getting the below error,
"com.ibm.db2.jcc.am.go: [jcc][t4][201][11237][3.57.82] Connection authorization failure occurred.
Reason: Security mechanism not supported. ERRORCODE=-4214, SQLSTATE=28000"
I tried to connect to the same db2 source using "Quest for DB2" tool and the connection was successful.
Am i missing something in the code and is it a problem with DB2 drivers or connection string?
Can someone please guide me.
Thanks in advance.
Cause:
If the DB2® instance where InfoSphere Optim Performance Manager is running has the authentication configuration parameter set to DATA_ENCRYPT, you cannot log in to the web console.
Resolving the problem:
Do the following steps:
On the DB2 instance where Optim Performance Manager is running, set the authentication configuration parameter to SERVER by issuing the following command:
db2 update dbm cfg using authentication server
Restart the DB2 instance and InfoSphere Optim Performance Manager.
For more details visit here.
Your first two attempts were not supposed to work. You're using the JCC driver URL format, so it wouldn't be valid for either "net" or "app" drivers, which are deprecated anyway.
Use the JCC driver (com.ibm.db2.jcc.DB2Driver) and the URL format of "jdbc:db2://hostname:portnumber/databasename" and see this technote for the solution to the "Security mechanism not supported" problem. In short, you need to use a supported JDK.

Cannot connect to heroku postgres database using Netbeans

I am trying to connect to a database hosted in https://postgres.heroku.com/databases using Netbeans (build-in) Services/Databases. I am getting this error
Cannot establish a connection to jdbc:postgresql://ec2-xx-xxx-xxx-xxx.compute-1.am
I tried this with no issues:
1. Netbeans connecting to a local postgres database.
2. Using PgAdmin III connecting to heroku postgres databases.
I tried downloading the latest postgres driver and use it in netbeans to create connection but the same error.
Thanks in advance!
When connecting outside of Heroku (e.g. locally), add this to the end of your JDBC connection URL:
?ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory

Categories

Resources