2011-02-20 11 views
0

なぜ私のmysqlデータベースに何度もログインしているように見えますか?春3起動時の奇妙な情報

INFO: Using JTA UserTransaction: [email protected] 
    INFO: Using JTA TransactionManager: [email protected] 
    INFO: Using JTA TransactionSynchronizationRegistry: com.su[email protected]18b5862 
    INFO: Root WebApplicationContext: initialization completed in 3354 ms 
    INFO: WEB0671: Loading application [com.g_mavenproject1_war_1.0-SNAPSHOT] at [/] 
    INFO: com._mavenproject1_war_1.0-SNAPSHOT was successfully deployed in 9,049 milliseconds. 
    INFO: Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver. 
    INFO: EclipseLink, version: Eclipse Persistence Services - 2.2.0.v20110202-r8913 
    CONFIG: connecting(DatabaseLogin(
      platform=>MySQLPlatform 
      user name=> "" 
      connector=>JNDIConnector datasource name=>null 
    )) 
    CONFIG: Connected: jdbc:mysql://localhost:3306/florblanca 
      User: [email protected] 
      Database: MySQL Version: 5.5.8 
      Driver: MySQL-AB JDBC Driver Version: mysql-connector-java-5.1.6 (Revision: ${svn.Revision}) 
    CONFIG: connecting(DatabaseLogin(
      platform=>MySQLPlatform 
      user name=> "" 
      connector=>JNDIConnector datasource name=>null 
    )) 
    CONFIG: Connected: jdbc:mysql://localhost:3306/florblanca 
      User: [email protected] 
      Database: MySQL Version: 5.5.8 
      Driver: MySQL-AB JDBC Driver Version: mysql-connector-java-5.1.6 (Revision: ${svn.Revision}) 
    INFO: file:/C:/Users/drewh/Desktop/mavenproject1/target/mavenproject1/WEB-INF/classes/_florblancaPU login successful 
    FINE: SELECT id, arrival, city, country, departure, email, guests, inserted, message, name, phone, sent, state, street, zip FROM contacts WHERE (id = ?) 
      bind => [1 parameter bound] 

春の設定:

<?xml version="1.0" encoding="windows-1252"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xmlns:aop="http://www.springframework.org/schema/aop" 
     xmlns:context="http://www.springframework.org/schema/context" 
     xmlns:tx="http://www.springframework.org/schema/tx" 
     xmlns:util="http://www.springframework.org/schema/util" 
     xmlns:p="http://www.springframework.org/schema/p" 

     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
      http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd 
      http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd 
      http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd 
      http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd 
"> 

    <context:component-scan base-package="com.atlanticpkg" /> 

    <tx:annotation-driven transaction-manager="txManager"/> 

    <bean id="entityManagerFactory" 
      class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> 
     <property name="persistenceUnitName" value="florblancaPU"/> 
     <property name="dataSource" ref="dataSource" /> 
     <property name="jpaVendorAdapter"> 
      <bean id="jpaAdapter" class="org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter"> 
       <property name="databasePlatform" value="org.eclipse.persistence.platform.database.MySQLPlatform" /> 
       <property name="showSql" value="true" />  
      </bean> 
     </property> 
    </bean> 

    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> 
     <property name="driverClassName" value="com.mysql.jdbc.Driver"/> 
     <property name="url" value="jdbc:mysql://localhost/florblanca"/> 
     <property name="username" value="root"/> 
     <property name="password" value="password"/> 
    </bean> 

    <bean id="txManager" class="org.springframework.transaction.jta.JtaTransactionManager" /> 

</beans> 

答えて

1

DriverManagerDataSourceは、接続プールを維持しません。 したがって、あなたはgetConnectionを実行するたびに、DBへの新しい物理接続を作成します。 これを解決するには、接続プールフレームワーク(例:C3P0)を使用します。

+0

しかし、私はエンティティマネージャを使用しています。それはすべてのハードワークをしないのですか?私はejb 3.1でこれを心配する必要はありません –

+0

あなたのエンティティマネージャは、Springの設定ファイルで定義されているようにDriverManagerDataSourceオブジェクトを使います。 –