当前位置:Gxlcms > 数据库问题 > HBase JDBC驱动Phoenix与SpringJDBCTemplate的集成

HBase JDBC驱动Phoenix与SpringJDBCTemplate的集成

时间:2021-07-01 10:21:17 帮助过:14人阅读

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的集成

标签:

人气教程排行