0

I'm using openshift hosting for java web application. My database server and web application is running on two different openshift account with different mail ids. Now when web-application is trying to connect with database server it is throwing below exception -

2017-11-22 01:41:22,123 [http-apr-8080-exec-1] ERROR org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/].[dispatcher]- Servlet.service() for servlet [dispatcher] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is org.hibernate.exception.JDBCConnectionException: Unable to acquire JDBC Connection] with root cause
java.net.ConnectException: Connection refused (Connection refused)
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)

I can guess may be it can be done by port forwarding but don't have idea about it. Please help me.

Noman Akhtar
  • 690
  • 1
  • 12
  • 17

1 Answers1

0

Do you mean in two different projects? It isn't really accounts which provides separation but projects.

You need to look at pod networks:

Graham Dumpleton
  • 57,726
  • 6
  • 119
  • 134
  • No, it's account with two different mail ids. – Noman Akhtar Nov 23 '17 at 06:06
  • That is still two separate projects then as each separate user will have their own project. Note that if you are doing this in OpenShift Online, you cannot join projects using a pod network as you need to be admin to do it in current OpenShift setup. – Graham Dumpleton Nov 23 '17 at 07:41
  • I'm admin of both the projects. I created two account because of the limited space in starter account, I was unable to run Web server,DB server and phpMyAdmin on the same account.Can i still access DB server from web-application? If yes please advise me how can i do that. – Noman Akhtar Nov 24 '17 at 03:04
  • Nope. As I said, in OpenShift Online you cannot create pod networks between projects. If your web server and phpMyAdmin can each run in 256MB, you could run all in one project, you just need to make sure you set deployment strategy for each to Recreate instead of Rolling. MySQL would need to be left as 512MB as it wants more memory. – Graham Dumpleton Nov 24 '17 at 07:46
  • The other thing you can do if you do not need phpMyAdmin all the time, is not to use it and use port forwarding only when you need it, to expose MySQL to a port on your local computer, and run any database admin tool on your local computer just when need to, putting it at the forwarded port. – Graham Dumpleton Nov 24 '17 at 07:48
  • your second solution is quite efficient, Now I'm proceeding with this. thank you so much Graham :) – Noman Akhtar Nov 25 '17 at 01:43