In one of my project, we are trying to connect to Postgres server via Java application. It gives an error when try to open connection. Stack trace is below -
{"timestamp":"2016-03-17T06:57:18.853Z",
"level":"ERROR",
"thread":"main",
"logger":"com.abc.messaging.status.configuration.ValidateDatabaseConfiguration",
"message":"Failed to initialize data source: \n
### Error opening session. Cause: java.lang.NullPointerException\n
### Cause: java.lang.NullPointerException","context":"default"}
While we have tried following -
Ping db server from application server - it's successful
Telnet db server and port (from app server)- it's also successful
We also tried a simple python script that connects to postgre server. It also connects to db successfully.
We then moved back to our staging server and tried to connect production db server from there. This is also done successfully.
We tried connecting staging db server from production app server, which also we COULDN'T.
We are assuming that we don't have any issue in our application. This is because, from staging server, application can connect to both staging db and production db. There by, it must be some application server issue or something.
PostgreSQL version - Production - 9.4.5 Staging - 9.4.4
Java version - 1.8.31
Any kind of help would be much appreciated.
Thanks in advance.
Related
im trying to make a java springboot project using Neo4j in DataBase , when i try to execute and test my Api in postman this error it diplayed to me :
Connection to the database terminated. Please ensure that your database is listening on the correct host and port and that you have compatible encryption settings both on Neo4j server and driver. Note that the default encryption setting has changed in Neo4j 4.0.
i had verified what it want for the encryption by adding this line in the application.properties:
spring.data.neo4j.uri=bolt://localhost:7687
spring.data.neo4j.username=Example1
spring.data.neo4j.password=secret
spring.data.neo4j.database =stud
org.neo4j.driver.config.encrypted=true
how can i find a solution for my problem
Thanks
currently, I am facing some odd behavior.
I have a Java EE Web Application that I am deploying to a wildfly server. This Java EE Application needs a database to which we need to connect via vpn. We are using OpenVPN. When I am using SSMS I have no problems connecting to the database. When I am using pure JDBC, there also is no problem.
But if I am creating a datasource in wildfly (and I am using the exact same jdbc connection url) it does not working. I am using the wildfly admin ui and click the test-button.
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host 10.1.115.51, port 1433 has failed. Error: "connect timed out. 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.".
I mean, the stack trace is pretty clear. However, the connection should be possbile as I connect via ssms and pure jdbc. Just wildfly datasource is not working.
Furhtermore, I have installed a MS SQL Server on the same mashine the wildfly is running on and using this MS SQL instance the datasource is working fine.
The jdbc url connection url is the following:
jdbc:sqlserver://< ip >:1433;databaseName=projdat;user= ** ;password= **
I have compared the jdbc url connection urls multiple times. Both in the pure jdbc and in the datasource they are the same.
Does anybody have any ideas? Is possible that I need to configure openvpn in a special way that wildfly can connect or do I need to configure Wildfly to be able to connect via vpn. Or do I have to configure the MS SQL Server in special way?
Version of MS SQL Server: 12
Version Wildfly: 19.0.0.Final
SQL Server driver: mssql-jdbc-8.2.2.jre8.jar
I apreciate any hint or advise.
Apparently, I was using an older version of Wildfly (in fact, it was wildfly 16). After I upgraded to Wildfly 19, it is now working. However, I have no clue why it was not working with wildfly 16.
I'm new to h2, but I read a lot of documentation,
I successfully created embeded H2 mem or file database.
But I'm still not able to use server mode or mixed mode :
I launch my Web server and tcp server like this :
java -jar h2-1.4.196.jar -web -webAllowOthers -tcp -tcpAllowOthers -browser -tcpPort 9092
Trying server mode :
I create file database like this :
I open H2 console and enter following :
jdbc:h2:~/maBaseH2FichierTCP
username: sa
password:
Database is created, and I see a lock file
In my java application
url: jdbc:h2:tcp://localhost:9092/~/maBaseH2FichierTCP
same username and pwd
--> When I launch my java application properties file, it stays sticked at the phase of datasource creation.
I tried to change url: jdbc:h2:tcp://localhost:9092/~/maBaseH2FichierTCP
to jdbc:h2:tcp://localhost/~/maBaseH2FichierTCP, but no effect.
Trying mixed mode :
In H2 console, I created jdbc:h2:C:/data/maBaseFichierAutoServeur;AUTO_SERVER=TRUE
In java, url: jdbc:h2:tcp://192.168.1.152:55000/file:c:/data/maBaseFichierAutoServeur;AUTO_SERVER=TRUE
--> Behaviour is the same, application start, but when at datasource creation, it waits, and nothing more happen ...
Does someone take has a idea to make one of orther server mode work ?
I solved this first problem : It was caused by a incompatibility between h2 version of h2 console, and my h2 client in application. 1.4.196 vs 1.4.192; when debuging, we can see an exception is launched, but nothing is writen on debug or even trace I think, and programme try to execute a rollback on a connection. It ended in a infinite loop here, even if I don't understand why. When changing version, I can connect my remote base.
Howerver now, when application update the database, the updated data cannot been seen in h2 console. Does someone know why ?
Using SQL Server Management Studio, I can log on to a local server, the name is:
BOB14630\SQL2012
(named instance of SQL2012 as I have SQL Server 2008 R2 and SQL Server 2012 on the same machine).
It logs in fine.
I also have a webapp and am trying to connect to a database called 'Repserv' on that server and am using a properties file to store the config parameters:
If I say:
dbConnectString=jdbc:jtds:sqlserver://BOB14630/Repserv;instance=SQL2012
it gives:
java.sql.SQLException: Server BOB14630 has no instance named SQL2012
If I say:
dbConnectString=jdbc:jtds:sqlserver://BOB14630\\SQL2012/Repserv
it gives:
java.sql.SQLException: Unknown server host name 'BOB14630\SQL2012'
What is the correct way to specify these parameters to get the web app to connect?
Thanks.
The link in the comment by Berger above gave the solution (the tcp/ip protocol was disabled). After enabling it and changing the connection string to the following, it worked:
dbConnectString=jdbc:jtds:sqlserver://BOB14630/Repserv;instance=SQL2012
I have a machine with CentOS and mysql server on it (let's call it 'Server'). And another(my desktop) machine with Debian (let's call it 'Desktop'). I tried to launch java program on Desktop machine. Application connects to Server's mysql database without any troubles.
When I finished development of this application (it's still works and connects to DB well) I tried to deploy this app to Server machine. I'v built it the app on the server and tried to launch, using database, which still hosted on Server machine. So now it seems to be local database for my application. But it fails during connection to DB using Server IP address or "localhost" or 127.0.0.1. I have only:
java.sql.SQLException: null, message from server: "Host '82.192.90.179' is not allowed to connect to this MySQL server".
In my.cnf file on Server I've set "bind-address=0.0.0.0".
PS:The most interesting thing, I do everything on server using ssh, and if I try to connect to database with "mysql" console tool, it connects OK either with -h82.192.90.179 and without -h option(seems to be localhost as a dafault)
To know it is permission issue try GRANT ALL ON . TO 'someuser'#%;
http://dev.mysql.com/doc/refman/4.1/en/grant.html
Then modify the above statement by replacing % with '82.192.90.179' should work.
If you feel difficult to connect JDBC means try using mysql workbench MySQL WORKBENCH
1.Make sure you have to host your server code to local server or public server
2.If you host Local Server means it will not work
3.Make sure your server is alive or not
DB_URL = "jdbc:mysql://localhost:portnumber/databasename"
eg.DB_URL = "jdbc:mysql://localhost:3306/cmes"
Maintain Your Session configuration like this in your server side in Web.xml
<session-config>
<session-timeout>-1</session-timeout>
</session-config>