Hi,
I am trying to connect oracle database 11G. the persistence.xml file looks like this :<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/ ... ce_2_0.xsd">
<persistence-unit name="VenteEnLigneClientJavaSE" transaction-type = "RESOURCE_LOCAL">
<class>com.eni.dvtejb.metier.entities.Adresse</class>
<class>com.eni.dvtejb.metier.entities.Article</class>
<class>com.eni.dvtejb.metier.entities.Catalogue</class>
<class>com.eni.dvtejb.metier.entities.Commande</class>
<class>com.eni.dvtejb.metier.entities.Lignecommande</class>
<class>com.eni.dvtejb.metier.entities.Produit</class>
<class>com.eni.dvtejb.metier.entities.Stock</class>
<class>com.eni.dvtejb.metier.entities.Utilisateur</class>
<properties>
<property name = "hibernate.connection.driver_class" value = "oracle.jdbc.driver.OracleDriver"/>
<property name="hibernate.connnection.username" value="HR"/>
<property name="hibernate.connnection.password" value="IG10122008"/>
<property name = "hibernate.connection.url" value = "jdbc.oracle.thin:@PCool:1522/RH" />
<property name="hibernate.dialect" value="org.hibernate.dialect.OracleDialect"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="hibernate.show_sql" value="true"/>
</properties>
</persistence-unit>
</persistence>
the oracle jdbc driver I uses is : ojdbc6.jarCode to access database is : @Override
protected void setUp() throws Exception {
super.setUp();
try {
logger.info("JPA EntityManager pour tests unitaires DEBUT");
// --------------------------------------------------------------------------------
// Utilise, va lire le fichier persistence.xml
// --------------------------------------------------------------------------------
emFactory = Persistence.createEntityManagerFactory("VenteEnLigneClientJavaSE");
em = emFactory.createEntityManager();
logger.info("JPA EntityManager pour tests unitaires FIN");
} catch (Exception ex) {
ex.printStackTrace();
fail("Exception pendant l'instantiation du JPA EntityManager.");
}
}
@Override
protected void tearDown() throws Exception {
super.tearDown();
logger.info("Fermeture de la couche Hibernate JPA. DEBUT");
if (em != null) {
em.close();
logger.info("Fermeture de la couche Hibernate JPA. FIN");
}
if (emFactory != null) {
emFactory.close();
}
}
public void testPersistence() {
try {
logger.info("debut de testPersistence()");
try {
em.getTransaction().begin();
} catch (Exception zz) {
logger.info("Erreur Get TRANSACTION ");
zz.printStackTrace();
}
logger.info("em.getTransaction().begin()");
Utilisateur client = new Utilisateur();
client.setNom("renard");
client.setPrenom("lulu");
BigDecimal fax = new BigDecimal("1115333");
client.setFax(fax);
client.setLogin("renard");
..........................
When I launch this program as a junit test, I receive the error message : ... 20 more
Caused by: java.sql.SQLException: No suitable driver found for jdbc.oracle.thin:@//127.0.0.1:1521/RH
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:133)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:446)
... 25 more
ojdbc6.jar is in the buildpath. I tried with ojdbc145.jar with the same result.
I created a database connection with eclipse helios using ojdbc6.jar and it works well.
Can somebody help me ?