xml Configurar Datasource con DBCP para utilizar Spring JDBC,namedParameters y varias cositas mas

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了xml Configurar Datasource con DBCP para utilizar Spring JDBC,namedParameters y varias cositas mas相关的知识,希望对你有一定的参考价值。

# Habilitar para produccion
production = 0

# Tareas en background
cronEnabled = 0

# Driver utilizado para conexion db
driverClass = org.firebirdsql.jdbc.FBDriver

# props utilizadas por fbDatasource
jdbc.driverClassName=org.firebirdsql.jdbc.FBDriver
jdbc.db_url=jdbc:firebirdsql://localhost:3050/academia?encoding=ISO8859_1
jdbc.username=sysdba
jdbc.password=masterkey
jdbc.maxPoolSize=50
jdbc.minPoolSize=5
jdbc.maxStatements=100
jdbc.removeAbandoned=true
jdbc.removeAbandonedTimeout=300 
jdbc.testConnection=true

#bin path
binPath=c:\\threads\\proyectos\\academia_web\\bin\\inschlp\\


# configuracion mail
host=smtp.gmail.com
port=587
username=mcthreadssrl@gmail.com
password=ni4Diche
from=mcthreadssrl@gmail.com
mail.smtp.auth=true
mail.smtp.starttls.enable=true
mail.debug=false
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd ">
 <!-- aca le indicamos el archivo de propiedades que utilizaremos -->
    <bean id="mailProperties" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="location" value="classpath:web.properties" />
    </bean>     
             
<!-- bean de configuracion del DataSource -->             
<bean id="dbcpDatasource" class="org.apache.commons.dbcp.BasicDataSource">
    <property name="driverClassName" value="${jdbc.driverClassName}"/>
    <property name="url" value="${jdbc.db_url}" />
    <property name="username" value="${jdbc.username}" />
    <property name="password" value="${jdbc.password}" />

    <!-- The number of connections created when the pool is started. 
    (actually created when first connection is opened)-->
    <property name="initialSize" value="${jdbc.minPoolSize}"/>

    <!-- The maximum number of connections that can be allocated from the pool 
        at the same time. If zero, there’s no limit. -->
    <property name="maxActive" value="${jdbc.maxPoolSize}"/>

    <!-- The maximum number of connections that can be idle in the pool without 
        extras being released. If zero, there’s no limit. -->
    <property name="maxIdle" value="5"/>
        
     <!-- The minimum number of connections that can remain idle in the pool 
     without new connections being created.-->
    <property name="minIdle" value="5"/>
    
    <!-- The maximum number of prepared statements that can be allocated from 
        the statement pool at the same time. If zero, there’s no limit. -->
    <property name="maxOpenPreparedStatements" value="${jdbc.maxStatements}"/>

    <!-- How long the pool will wait for a connection to be returned to the 
        pool (when there are no available connections) before an exception is thrown. 
        If -1, wait indefinitely. -->
    <property name="maxWait" value="-1"/>

    <!-- How long a connection can remain idle in the pool before it’s eligible 
        for eviction. -->
    <property name="minEvictableIdleTimeMillis" value="600000"/>

    <!-- Whether or not to pool prepared statements (Boolean). -->
    <property name="poolPreparedStatements" value="true"/>
    
</bean>            
            
<!-- el transactionManager sera utilizado por txTemplate, que es como jdbcTemplate, pero permite 
     realizar todo dentro de transacciones -->            
	<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
	  <property name="dataSource" ref="dbcpDatasource"></property>
	</bean>
	
	<bean id="txTemplate" class="org.springframework.transaction.support.TransactionTemplate">
	  <property name="transactionManager" ref="transactionManager"></property>
	</bean>            
            
<!-- jdbcTemplate es lo que le inyectaremos a cada DAO para realizar los accesos a DB -->                                   
    <bean id="jdbcTemplate" class="org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate">
       <constructor-arg ref="dbcpDatasource" />
    </bean>
      
</beans>

以上是关于xml Configurar Datasource con DBCP para utilizar Spring JDBC,namedParameters y varias cositas mas的主要内容,如果未能解决你的问题,请参考以下文章