Erro no JPA ,Oracle 11 g ,Hibernate

Pessoal estou querendo desenvolver um projeto em Oracle ,porém não estou conseguindo,pois consegui com PostgresSQL,mas com oracle esta dando erro.

Estou utilziando o oracle11g e quero saber se ele criar as tabelas automaticamente.

Segue a classe de teste


package br.com.caelum.financas.jpa;

import java.math.BigDecimal;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

import br.com.caelum.financas.modelo.Conta;

public class TesteJPA {

	public static void main(String[] args) {

		Conta conta = new Conta();
		conta.setTitular("Jose da Silva ");
		conta.setBanco("Banco do Brasil");
		conta.setAgencia("05428");
		conta.setNumero("287377");
        conta.setSaldo(new BigDecimal(2800));
		/**
		 * Usando HSQLDB
		 */

		// EntityManagerFactory emf = Persistence
		// 		.createEntityManagerFactory("contas-hsqldb");

		/**
		 * Usando PostgreSQL
		 */
	//	 EntityManagerFactory emf = Persistence
		// 		.createEntityManagerFactory("contas-postgres");

		/**
		 * Usando MySQL
		 */
	//	EntityManagerFactory emf = Persistence
		//		.createEntityManagerFactory("contas-mysql");


		 /**
			 * Usando o oracle 
			 */	 
	
		 EntityManagerFactory emf = Persistence
					.createEntityManagerFactory("contas-oracle");
		 
	
		 EntityManager em = emf.createEntityManager();
		em.getTransaction().begin();

		em.persist(conta);

		em.getTransaction().commit();
		em.close();
	}
}

Erro no console.

[color=red]
Set 13, 2014 10:58:39 PM org.hibernate.annotations.common.Version
INFO: HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
Set 13, 2014 10:58:39 PM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.1.9.Final}
Set 13, 2014 10:58:39 PM org.hibernate.cfg.Environment
INFO: HHH000206: hibernate.properties not found
Set 13, 2014 10:58:39 PM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
Set 13, 2014 10:58:40 PM org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000402: Using Hibernate built-in connection pool (not for production use!)
Exception in thread “main” javax.persistence.PersistenceException: [PersistenceUnit: contas-oracle] Unable to build EntityManagerFactory
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:915)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:890)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:57)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:63)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:47)
at br.com.caelum.financas.jpa.TesteJPA.main(TesteJPA.java:46)
Caused by: org.hibernate.service.classloading.spi.ClassLoadingException: Specified JDBC Driver oracle.jdbc.OracleDriver class not found
at org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl.configure(DriverManagerConnectionProviderImpl.java:107)
at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:75)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:159)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131)
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.buildJdbcConnectionAccess(JdbcServicesImpl.java:223)
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:89)
at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:75)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:159)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:77)
at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2283)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2279)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1748)
at org.hibernate.ejb.EntityManagerFactoryImpl.(EntityManagerFactoryImpl.java:94)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:905)
… 5 more
Caused by: org.hibernate.service.classloading.spi.ClassLoadingException: Unable to load class [oracle.jdbc.OracleDriver]
at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:141)
at org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl.configure(DriverManagerConnectionProviderImpl.java:104)
… 19 more
Caused by: java.lang.ClassNotFoundException: Could not load requested class : oracle.jdbc.OracleDriver
at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl$1.findClass(ClassLoaderServiceImpl.java:99)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:138)
… 20 more

[/color]

Segue a configuração do hibernate.



	<persistence-unit name="contas-oracle">
		<provider>org.hibernate.ejb.HibernatePersistence</provider>
		<class>br.com.caelum.financas.modelo.Conta</class>
		<properties>
			  <property name="javax.persistence.jdbc.driver" value="oracle.jdbc.OracleDriver" />
            <property name="javax.persistence.jdbc.url" value="jdbc:oracle:thin:@localhost:1521:CONTAS" />
            <property name="javax.persistence.jdbc.user" value="system" />
            <property name="javax.persistence.jdbc.password" value="system" />	
			<property name="hibernate.hbm2ddl.auto" value="update" />	
			<property name="hibernate.show_sql" value="true" />
		    <property name="hibernate.dialect" value="org.hibernate.dialect.OracleDialect" />	
 		    <property name="hibernate.format_sql" value="true" />   
			<property name="hibernate.hbm2ddl.auto" value="create" />
       </properties>
	</persistence-unit>

O que pode esta acontecendo ?No aguardo.

Adicionou o jar da Oracle no projeto?

Sim amigo fiz isso ,porém o erro continua.

Tente configurar como esse tutoria.

Nele o dialect está org.hibernate.dialect.Oracle10gDialect.

Olha o erro ai:

 Specified JDBC Driver oracle.jdbc.OracleDriver class not found 

o caminho do driver ta errado, acho que é esse aqui

<property name="javax.persistence.jdbc.driver" value="oracle.jdbc.driver.OracleDriver" /> 

Amigo consegui inserir dentro do oracle acredito que seja por conta do driver mesmo que não estava no local certo e o schema que não tinha definido.

Agora ficou certo.

 <property name="javax.persistence.jdbc.driver" value="oracle.jdbc.OracleDriver"/>
   <property name="javax.persistence.jdbc.url" value="jdbc:oracle:thin:@localhost:1521:XE" /> 
  <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" />   
   <property name="hibernate.default_schema" value="CONTAS"/>

Obrigado.Problema resolvido.

Agora queria saber como faço para ele inserir dados nos dois bancos de dados ao mesmo tempo oracle e postgreSQL.Ele funciona somente com um dos dois ou Oracle ou PostgresSql.

segue minhas classes


package br.com.caelum.financas.util;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

public class JPAUtil {

	private static EntityManagerFactory entityManagerFactory = Persistence
			.createEntityManagerFactory("financas");

	public EntityManager getEntityManager() {
		return entityManagerFactory.createEntityManager();
	}
	
		
}
package br.com.caelum.financas.util;

import javax.persistence.EntityManager;

import br.com.caelum.financas.modelo.Conta;

public class PopulaConta {

	public static void main(String[] args) {

		EntityManager manager = new JPAUtil().getEntityManager();
 
		
    
      manager.getTransaction().begin();

		Conta conta1 = new Conta();
		Conta conta2 = new Conta();
		Conta conta3 = new Conta();
		Conta conta4 = new Conta();
		Conta conta5 = new Conta();

		conta1.setBanco("001 - BANCO DO BRASIL");
		conta1.setNumero("16987-8");
		conta1.setAgencia("6543");
		conta1.setTitular("Maria dos Santos");

		conta2.setBanco("237 - BANCO BRADESCO");
		conta2.setNumero("86759-1");
		conta2.setAgencia("1745");
		conta2.setTitular("Paulo Roberto Souza");

		conta3.setBanco("341 - BANCO ITAU UNIBANCO");
		conta3.setNumero("46346-3");
		conta3.setAgencia("4606");
		conta3.setTitular("Antonio Duraes");

		conta4.setBanco("033 - BANCO SANTANDER");
		conta4.setNumero("12345-6");
		conta4.setAgencia("9876");
		conta4.setTitular("Leandra Marques");

		conta5.setBanco("104 - CAIXA ECONOMICA FEDERAL");
		conta5.setNumero("98654-3");
		conta5.setAgencia("1234");
		conta5.setTitular("Alexandre Duarte");

		// persistindo as contas
		manager.persist(conta1);
		manager.persist(conta2);
		manager.persist(conta3);
		manager.persist(conta4);
		manager.persist(conta5);

		manager.getTransaction().commit();

		manager.close();

	}
}

arquivo persistence.xml

<persistence 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/persistence_2_0.xsd"
	version="2.0">

	<!-- unidade de persistencia com o nome financas -->

		
		
		<persistence-unit name="financas">  
    <provider>org.hibernate.ejb.HibernatePersistence</provider>  
    <class>br.com.caelum.financas.modelo.Conta</class>  
    <properties>  
         <property name="javax.persistence.jdbc.driver" value="oracle.jdbc.OracleDriver"/>
           <property name="javax.persistence.jdbc.url" value="jdbc:oracle:thin:@localhost:1521:XE" />  
           <property name="javax.persistence.jdbc.user" value="system" />  
           <property name="javax.persistence.jdbc.password" value="system" />   
        <property name="hibernate.hbm2ddl.auto" value="update" />   
        <property name="hibernate.show_sql" value="true" />  
        <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" />   
         
         <property name="hibernate.default_schema" value="CONTAS"/>
            <property name="hibernate.format_sql" value="true" />     
        <property name="hibernate.hbm2ddl.auto" value="create" />  
      </properties>  
</persistence-unit>
		
		
		
		<persistence-unit name="financas">

		<!-- Implementação do JPA, no nosso caso Hibernate -->
		<provider>org.hibernate.ejb.HibernatePersistence</provider>

		<!-- Aqui são listadas todas as entidades -->
		<class>br.com.caelum.financas.modelo.Conta</class>
		<properties>
			<property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver" />
			<property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost/contas" />
			<property name="javax.persistence.jdbc.user" value="postgres" />
			<property name="javax.persistence.jdbc.password" value="postgres" />

			<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" />
			<property name="hibernate.hbm2ddl.auto" value="update" />
			<property name="hibernate.show_sql" value="true" />
			<property name="hibernate.format_sql" value="true" />
		</properties>
		
		</persistence-unit>
		
		

</persistence>