Losing database connection. Postgress, Glassfish

Asked

Viewed 319 times

0

After about 15 minutes my system stops communicating with the database.

Log Entry Detail Close-up

Timestamp 05/09/2016 21:22:30.287 Log Level ERROR Logger org.hibernate.engine.jdbc.spi.Sqlexceptionhelper Name-Value Pairs {levelValue=1000, timeMillis=1473110550287} Record Number 2130 Message ID Complete Message This Connection has been closed.

local problem does not happen. After setting up remote bank problem already begins. Searching, I found that it is necessary to create the connection pool when working with glassfish, I tried to create but not ping with my bank.

I’m working with jpa, glassfish 4.1

 <persistence-unit name="meusistema" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
  <property name="javax.persistence.jdbc.url" value="jdbc:postgresql://...:5432/..."/>
  <property name="javax.persistence.jdbc.user" value="postgres"/>
  <property name="javax.persistence.jdbc.password" value="root"/>
  <property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver"/>
  <property name="hibernate.show_sql" value="true"/>
  <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>


  <property name="hibernate.hbm2ddl.auto" value="update"/>

</properties>

Error shown when creating the pool

Ping Connection Pool failed for juridicoPool. Class name is wrong or classpath is not set for : org.postgresql.ds.PGConnectionPoolDataSource Please check the server.log for more details.
  • Created Datasource and Pool ?

  • How do you connect to the database? you are using jndi or the properties are in persistence.xml?

  • @Giulianabezerra I am using the properties in xml. Posted in the question.

  • @Dilneicunha was trying to create the pool but could not. I put all the information but not the ping. Searching saw that you need to create a pool in glassfish, is correct?

  • 1

    This, you need to create the datasource + the Pool and test the ping, when using the management of connections by the container your persistence.xml changes to JTA, ex: transaction-type="JTA", I do not remember well but in glassfish you will need to add the jar(JDBC) from the bank you want, I don’t think I’m sure it was in lib/ext, I haven’t used this server for years, but if you can’t let me know that I see in Docs, hugging.

  • @Dilneicunha means I don’t have to use the container to manage my connections. When I don’t use the container the managed is done by entityManager? I’m using CDI. I’ll study more deeply about it. Thank you!

  • the evening I will install a glassfish, take prints and put here how to create, but like this: I do not want infrastructure matters to be managed by my application, I prefer that you stay on account of the container, in a good software design is not good the application manage these resources, based on this also has the fact Spring-Security X JAAS prefer JAAS because I do not take libraries into my software take care of matters that are also infrastructure, in case I let the container take care of it for me, but everything has exception to rule.

  • Yes you can let the application manage everything.

  • @Dilneicunha changed my database and the error did not occur anymore. I was using a bank of Uolhost, I switched to Mazon and the problem of disconnecting did not happen again. Anyway I will configure the connection pool. Thanks for the help!

  • sorry I haven’t posted yet how it sets up, I’m below bad weather :) and had helping others but I’ll do :)

  • @Dilneicunha Relax. I researched the subject and saw some examples on the net. I saved the postg drive in my glassfish and the error changed, it is with port error, but the door was released. I did not test in the new bank of Amazon. I will test and put the result. Thank you!

Show 6 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.