1.在database.properties中配置数据源
###全国在逃数据库
DBMSQGZT_IP=10.56.5.31
DBMSQGZT_DB=u570p1
DBMSQGZT_DRIVER=oracle.jdbc.driver.OracleDriver
DBMSQGZT_URL=jdbc:oracle:thin:@${DBMSQGZT_IP}:1521:${DBMSQGZT_DB}
DBMSQGZT_USER=ztrycx
DBMSQGZT_PASS=ztrycx20140319
2.在spring-config.xml中配置
<!-- 此bean告诉Spring去哪找数据库的配置信息,因为有此Bean才出现下面用${}标记来取变量的语句 -->
<bean id="propertyConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="classpath:htjs-ptcore3.properties" />
</bean>
<!-- 全国在逃 -->
<bean id="dataSourceQGZTBase" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<!-- oracle连接配置 -->
<property name="driverClassName" value="${DBMSQGZT_DRIVER}" />
<property name="url" value="${DBMSQGZT_URL}" />
<property name="username" value="${DBMSQGZT_USER}" />
<property name="password" value="${DBMSQGZT_PASS}" />
<property name="maxActive" value="100" />
<property name="maxIdle" value="30" />
<property name="maxWait" value="1000" />
<property name="defaultAutoCommit" value="true" />
<property name="removeAbandoned" value="true" />
<property name="removeAbandonedTimeout" value="60" />
</bean>
<!-- 全国在逃 -->
<bean id="sqlMapClientQGZTBase" name="sqlMapQGZTClient"
class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="configLocations">
<list>
<value>classpath:sqlmap-oracle-old.xml</value>
</list>
</property>
<property name="dataSource" ref="dataSourceQGZTBase" />
</bean>
3.在bo中初始化对象
private static SqlMapClient sqlMapClient=null;
private static ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("spring-config.xml");
直接用该数据库对象调用方法
sqlMapClient = (SqlMapClient)ctx.getBean("sqlMapClientQGZTBase");
List list_qgzt=sqlMapClient.queryForList("QGZT_SOURCE.select_QGZT_JBXX_LRRY", map);
###全国在逃数据库
DBMSQGZT_IP=10.56.5.31
DBMSQGZT_DB=u570p1
DBMSQGZT_DRIVER=oracle.jdbc.driver.OracleDriver
DBMSQGZT_URL=jdbc:oracle:thin:@${DBMSQGZT_IP}:1521:${DBMSQGZT_DB}
DBMSQGZT_USER=ztrycx
DBMSQGZT_PASS=ztrycx20140319
2.在spring-config.xml中配置
<!-- 此bean告诉Spring去哪找数据库的配置信息,因为有此Bean才出现下面用${}标记来取变量的语句 -->
<bean id="propertyConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="classpath:htjs-ptcore3.properties" />
</bean>
<!-- 全国在逃 -->
<bean id="dataSourceQGZTBase" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<!-- oracle连接配置 -->
<property name="driverClassName" value="${DBMSQGZT_DRIVER}" />
<property name="url" value="${DBMSQGZT_URL}" />
<property name="username" value="${DBMSQGZT_USER}" />
<property name="password" value="${DBMSQGZT_PASS}" />
<property name="maxActive" value="100" />
<property name="maxIdle" value="30" />
<property name="maxWait" value="1000" />
<property name="defaultAutoCommit" value="true" />
<property name="removeAbandoned" value="true" />
<property name="removeAbandonedTimeout" value="60" />
</bean>
<!-- 全国在逃 -->
<bean id="sqlMapClientQGZTBase" name="sqlMapQGZTClient"
class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="configLocations">
<list>
<value>classpath:sqlmap-oracle-old.xml</value>
</list>
</property>
<property name="dataSource" ref="dataSourceQGZTBase" />
</bean>
3.在bo中初始化对象
private static SqlMapClient sqlMapClient=null;
private static ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("spring-config.xml");
直接用该数据库对象调用方法
sqlMapClient = (SqlMapClient)ctx.getBean("sqlMapClientQGZTBase");
List list_qgzt=sqlMapClient.queryForList("QGZT_SOURCE.select_QGZT_JBXX_LRRY", map);