标签:
1.配置applicationContext.xml
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:hdp="http://www.springframework.org/schema/hadoop" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/hadoop http://www.springframework.org/schema/hadoop/spring-hadoop.xsd">
//配置Phoenix数据源 <bean id="phoenixDataSource" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName" value="org.apache.phoenix.jdbc.PhoenixDriver"/> <property name="url" value="jdbc:phoenix:master"/> <property name="initialSize" value="15"/> <property name="maxActive" value="0"/> </bean> //选择JDBC模板 <bean id="phoenixJdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"> <constructor-arg ref="phoenixDataSource"/> <qualifier value="phoenixJdbcTemplate"/> </bean> <bean id="travelDao" class="com.mobin.dao.impl.TravelDaoImpl"> <property name="jdbcTemplate" ref="phoenixJdbcTemplate"/> </bean> </beans>
2.JDBC代码模板
public class TravelDaoImpl implements TravelDao{ private JdbcTemplate jdbcTemplate; jdbcTemplate.xxx()//通过调用jdbcTemplate封装的方法访问Phoenix并进行相关的操作如查询,更新等 public JdbcTemplate getJdbcTemplate() { return jdbcTemplate; } public void setJdbcTemplate(JdbcTemplate jdbcTemplate) { this.jdbcTemplate = jdbcTemplate; } }
HBase JDBC驱动Phoenix与SpringJDBCTemplate的集成
标签:
原文地址:http://www.cnblogs.com/MOBIN/p/5234816.html