IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Spring Java Discussion :

Augmentation connexion transactions


Sujet :

Spring Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Profil pro
    Inscrit en
    Septembre 2006
    Messages
    24
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2006
    Messages : 24
    Par défaut Augmentation connexion transactions
    J'utilise ibatis et spring dans une API.
    Le pb est que j'ouvre des connexions sans les fermer.
    Le pb ne se produit pas à distance sur win32 mais sous Linux en local ?!?

    voici ma conf:
    applicationContext.xml
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
     
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
     
    <beans>
     
    	<!-- BASE DE DONNEES -->
    	<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
    		destroy-method="close">
    		<property name="driverClassName">
    			<value>oracle.jdbc.driver.OracleDriver</value>
    		</property>
    		<!--
    			attention : ne pas laisser d'espaces entre les deux balises <value>
    			de l’url
    		-->
    		<property name="url">
    			<value>jdbc:oracle:thin:@10.121.200.242:1521:dev</value>
    		</property>
    		<property name="username">
    			<value>****</value>
    		</property>
    		<property name="password">
    			<value>****</value>
    		</property>
    	</bean>
     
    	<!-- SQLMAQCLIENT -->
    	<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
    		<property name="dataSource">
    			<ref local="dataSource" />
    		</property>
    		<property name="configLocation">
    			<value>conf/SqlMapConfig.xml</value>
    		</property>
    	</bean>
     
    	<!-- TRANSACTIONS -->
    	<bean id="transactionManager"
    		class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    		<property name="dataSource">
    			<ref local="dataSource" />
    		</property>
    	</bean>
     
    	<!-- DAO -->
    	<bean id="ka05DAO"
    		class="****.business.ibatis.dao.Ka05DAOImpl">
    		<property name="sqlMapClient">
    			<ref local="sqlMapClient" />
    		</property>
    	</bean>
    	<bean id="ka10DAO"
    		class="****.business.ibatis.dao.Ka10DAOImpl">
    		<property name="sqlMapClient">
    			<ref local="sqlMapClient" />
    		</property>
    	</bean>
    	<bean id="ka20DAO"
    		class="****.business.ibatis.dao.Ka20DAOImpl">
    		<property name="sqlMapClient">
    			<ref local="sqlMapClient" />
    		</property>
    	</bean>
     
    	<!-- SERVICES -->
    	<bean id="KA05Manager"
    		class="****.api.services.KA05Manager">
    		<property name="ka05DAO">
    			<ref local="ka05DAO" />
    		</property>
    	</bean>
    	<bean id="KA10Manager"
    		class="****.api.services.KA10Manager">
    		<property name="ka10DAO">
    			<ref local="ka10DAO" />
    		</property>
     
    	</bean>
     
    	<bean id="KA20Manager"
    		class="*****.api.services.KA20Manager">
    		<property name="ka20DAO">
    			<ref local="ka20DAO" />
    		</property>
    	</bean>
     
    	<bean id="KAALLManager"
    		class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
    		<property name="transactionManager">
    			<ref local="transactionManager" />
    		</property>
    		<property name="target">
    			<bean class="****.api.services.KAALLManager">
    				<property name="KA20Manager">
    					<ref local="KA20Manager" />
    				</property>
    				<property name="KA10Manager">
    					<ref local="KA10Manager" />
    				</property>
    				<property name="KA05Manager">
    					<ref local="KA05Manager" />
    				</property>
    			</bean>
    		</property>
    		<property name="transactionAttributes">
    			<props>
    				<prop key="insertValuesWithTransaction">PROPAGATION_REQUIRED</prop>
    			</props>
    		</property>
    	</bean>
     
    </beans>
    SqlMapConfig.xml:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
     
    <sqlMapConfig>
     
    	<settings enhancementEnabled="true"	useStatementNamespaces="true" />
     
    	<sqlMap
    		resource="*****/business/ibatis/sql/KA05_SqlMap.xml" />
    	<sqlMap
    		resource="*****/business/ibatis/sql/KA10_SqlMap.xml" />
    	<sqlMap
    		resource="*****/business/ibatis/sql/KA20_SqlMap.xml" />
     
     
    </sqlMapConfig>
    la méthode:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
     
     public void insertValuesWithTransaction(Ka05 ka05, List<Ka10> listeKa10, List<Ka20> listeKa20) {
     
    	if (ka05 != null) {
    	    kA05Manager.insert(ka05);
    	}
    	if (listeKa10 != null && listeKa10.size() > 0) {
    	    for (Iterator<Ka10> iterator = listeKa10.iterator(); iterator.hasNext();) {
    		Ka10 ka102 = (Ka10) iterator.next();
    		kA10Manager.insert(ka102);
    	    }
    	}
    	if (listeKa20 != null && listeKa20.size() > 0) {
    	    for (Iterator<Ka20> iterator = listeKa20.iterator(); iterator.hasNext();) {
    		Ka20 ka202 = (Ka20) iterator.next();
    		kA20Manager.insert(ka202);
    	    }
     
    	}
     
        }

  2. #2
    Membre averti
    Profil pro
    Inscrit en
    Septembre 2006
    Messages
    24
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2006
    Messages : 24
    Par défaut
    Le probléme est résolu avec un org.springframework.jdbc.datasource.DriverManagerDataSource
    mais celui si ne crée pas de pool.
    Il ouvre et referme la connexion apres chaque commit...
    Comment réutiliser la même connexion ? sans la fermer ?

  3. #3
    Membre Expert
    Avatar de Patriarch24
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Septembre 2003
    Messages
    1 047
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Industrie

    Informations forums :
    Inscription : Septembre 2003
    Messages : 1 047
    Par défaut
    Utilise une lib de pools de connexions (au choix : Proxool, DBCP, c3p0).

Discussions similaires

  1. Réponses: 0
    Dernier message: 15/09/2009, 15h19
  2. Réponses: 3
    Dernier message: 09/03/2009, 09h22
  3. Augmenter le nombre de connexion - PROCESS / SESSIONS
    Par 6bil1 dans le forum Administration
    Réponses: 9
    Dernier message: 12/02/2009, 11h36
  4. Réponses: 2
    Dernier message: 02/12/2008, 12h22
  5. [9.2] Augmenter le nombre de connexions d'une pool EJB
    Par dingoth dans le forum Weblogic
    Réponses: 1
    Dernier message: 03/07/2008, 15h55

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo