JDBC : connexion impossible à POSTGRE
Je n'arrive pas à me connecter sur une base POSTGRE 9.4 avec jdbc.
J'ai l'erreur ci dessous:
Citation:
org.hibernate.exception.GenericJDBCException: Could not open connection
avec une exception :
Citation:
Cannot create PoolableConnectionFactory (Method org.postgresql.jdbc4.Jdbc4Connection.isValid(int) is not yet implemented.)
Mon code est le suivant :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
import java.util.Date;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Repository;
@PersistenceContext
private EntityManager entityManager;
private static final Log LOG = LogFactory.getLog( LoggingInfoDaoImpl.class );
@Override
public List<TabLog> findByDates(Date startDate, Date endDate)
{
LOG.info("Lancement requete SQL");
return entityManager.createNamedQuery("TabLog.FIND_LOGS_BY_DATES", TabLog.class)
.setParameter("startDate", startDate)
.setParameter("endDate", endDate)
.getResultList();
} |
et une classe tablog avec les paramètres ci-dessous:
Code:
1 2 3 4 5 6 7 8
| @Entity
@Table(name="TBL_LOG", schema = "logdb")
@NamedQueries({
@NamedQuery(name = "TabLog.FIND_LOGS_BY_DATES",
query = " SELECT t FROM TabLog t WHERE date_trunc('day',t.dated) BETWEEN :startDate AND :endDate")
}) |
enfin un fichier xml context.xml dans lequel je récupère ma connexion:
Code:
1 2 3 4 5
| <Resource
name="jdbc/logdb" auth="Container"
type="javax.sql.DataSource" driverClassName="org.postgresql.Driver"
url="jdbc:postgresql://localhost:5432/database"
username="postgres" password="xxxx" maxActive="20" maxIdle="500" maxWait="-1"/> |
Une idée de ce qui se passe ?