Précédent   Forum des professionnels en informatique > Java > Général Java > JDBC
JDBC Forum d'entraide sur l'API JDBC (Java Database Connectivity) et l'accès aux bases de données. Avant de poster -> FAQ JDBC
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 17/01/2012, 12h16   #1
Membre du Club
 
Avatar de POKOU
 
Homme
Inscription : décembre 2008
Messages : 86
Détails du profil
Informations personnelles :
Sexe : Homme
Âge : 50
Localisation : France, Finistère (Bretagne)

Informations forums :
Inscription : décembre 2008
Messages : 86
Points : 55
Points : 55
Par défaut Utilisation de 2 drivers différents dans applicationContext ?

Bonjour
j'utilise 2 drivers différents pour accéder à 2 tables différentes:
l'un pour accéder a db2400 et l'autre pour accéder à MySQL.
les modèles respectifs de ces 2 tables n'utilisent qu'un seul EntityManager :
Code :
1
2
3
4
	@PersistenceContext
	public void setEntityManager(EntityManager entityManager) {
		this.entityManager = entityManager;
	}
dans mon applicationContext j'ai mis mes beans en double
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
 
<bean 	id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
		<property name="driverClassName" value="com.mysql.jdbc.Driver" />
		<property ...	
</bean>
<bean 	id="entityManagerFactory"	class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" >
		<property name="dataSource" ref="dataSource" />
		<property name="jpaVendorAdapter">
			<bean ...
</bean>
<bean 	id="transactionManager"
		class="org.springframework.orm.jpa.JpaTransactionManager">
		<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
 
<bean 	id="dataSource2" 
	class="org.springframework.jdbc.datasource.DriverManagerDataSource">
		<property name="driverClassName" value="com.ibm.as400...	
</bean>
<bean 	id="entityManagerFactory2"
 
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" >
<property name="dataSource" ref="dataSource2" />
		<property ...
</bean>
<bean 	id="transactionManager2"
		class="org.springframework.orm.jpa.JpaTransactionManager">
		<property name="entityManagerFactory" ref="entityManagerFactory2" />
</bean>
 
<tx:annotation-driven transaction-manager="transactionManager" />
et la JVM renvoie l'erreur
[QUOTE]Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [javax.persistence.EntityManagerFactory] is defined: expected single bean but found 2[/QUOT]

Où et quand faire la différence entre ces 2 drivers ?
POKOU est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 21h34.


 
 
 
 
Partenaires

Hébergement Web