proxool数据源

web.xml配置如下:
<!-- proxool 配置档 -->
	<servlet>
		<servlet-name>proxoolServletConfigurator</servlet-name>
		<servlet-class>
			org.logicalcobwebs.proxool.configuration.ServletConfigurator 
		</servlet-class>
		<init-param>
			<param-name>xmlFile</param-name>
			<param-value>WEB-INF/proxool.xml</param-value>
		</init-param>
		<load-on-startup>1</load-on-startup>
	</servlet>
	<servlet>
		<servlet-name>proxooladmin</servlet-name>
		<servlet-class> org.logicalcobwebs.proxool.admin.servlet.AdminServlet 
		</servlet-class>
	</servlet>
	<servlet-mapping>
		<servlet-name>proxooladmin</servlet-name>
		<url-pattern>/proxooladmin</url-pattern>
	</servlet-mapping>
	<!-- proxool配置结束 -->


proxool.xml,跟web.xml放在同级目录中
<?xml version="1.0" encoding="UTF-8"?>
<something-else-entirely>
	<proxool>
		<alias>testDB</alias>
	 
		<driver-url>jdbc:mysql://127.0.0.1:3306/test</driver-url>
		<driver-class>com.mysql.jdbc.Driver</driver-class>
	<!-- 
		<driver-url>jdbc:jtds:sqlserver://127.0.0.1:1433/test</driver-url>
		<driver-class>net.sourceforge.jtds.jdbc.Driver</driver-class>
		 -->
		<driver-properties>
			<property name="user" value="root" />
			<property name="password" value="password" />
		</driver-properties>
		  <maximum-connection-count>10</maximum-connection-count>
    	  <minimum-connection-count>5</minimum-connection-count>
          <house-keeping-sleep-time>180000</house-keeping-sleep-time>
          <prototype-count>5</prototype-count>
		<house-keeping-test-sql>select CURRENT_DATE</house-keeping-test-sql>
	</proxool>
</something-else-entirely>


Java中调用:
Connection con = DriverManager.getConnection("proxool.testDB");


如果用Spring,配置如下:
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
		<!-- 
		<property name="driverClassName">
			<value>com.mysql.jdbc.Driver</value>
		</property>
		<property name="url">
			<value>
				jdbc:mysql://127.0.0.1:3306/test
			</value>
		</property>
		<property name="username">
			<value>root</value>
		</property>
		<property name="password">
			<value>password</value>
		</property>
		-->
		<property name="driverClassName">   
              <value>org.logicalcobwebs.proxool.ProxoolDriver</value>   
          </property>   
          <property  name="url">   
              <value>proxool.testDB</value>   <!--proxool是proxool.xml的文件名,testDB是proxool.xml中配置的别名-->
          </property>   
		
	</bean>

	<bean id="connectionProvider" class="com.test.dbutil.ConnectionProvider">
		<property name="dataSource">
			<ref bean="dataSource" />
		</property>
	</bean>

你可能感兴趣的:(java,spring,xml,mysql,jdbc)