标签:phoenix 4.3.0 jdbc hbase 0.98
<dependency> <groupId>org.apache.phoenix</groupId> <artifactId>phoenix-core</artifactId> <version>4.3.0</version> </dependency> <dependency> <groupId>commons-dbcp</groupId> <artifactId>commons-dbcp</artifactId> <version>1.4</version> </dependency>
192.168.199.242 develop5
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd <bean id="phoenixJdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"> <constructor-arg ref="phoenixDataSource"/> <qualifier value="phoenixJdbcTemplate"></qualifier> </bean> <bean id="baseInterfacePonenixImpl" class="com.eric.monitor.dao.impl.HBaseBaseDAOImpl"> <property name="jdbcTemplate" ref="phoenixJdbcTemplate"/> </bean> <context:component-scan base-package="com.eric.monitor.dao.impl"/> <context:component-scan base-package="com.eric.monitor.service.impl"/> <bean id="phoenixDataSource" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName" value="org.apache.phoenix.jdbc.PhoenixDriver"/> <property name="url" value="jdbc:phoenix:develop5"/> <property name="username" value=""/> <property name="password" value=""/> <property name="initialSize" value="20"/> <property name="maxActive" value="0"/> <!--因为Phoenix进行数据更改时不会自动的commit,必须要添加defaultAutoCommit属性,否则会导致数据无法提交的情况--> <property name="defaultAutoCommit" value="true"/> </bean> </beans>
import com.eric.common.framework.dao.HBaseDao; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.RowMapper; import org.springframework.stereotype.Repository; import java.util.List; /** * 类描述 * * @author aihua.sun * @date 2015/3/9 * @since V1.0 */ @Repository public class HBaseBaseDAOImpl implements HBaseDao { private JdbcTemplate jdbcTemplate; public HBaseBaseDAOImpl(JdbcTemplate template) { this.jdbcTemplate = template; } public HBaseBaseDAOImpl() { super(); } public List query(String querySql) { return jdbcTemplate.query(querySql); } @Override public void update(String querySql) { System.out.println(querySql); jdbcTemplate.update(querySql); } @Override public void batchUpdate(String updateSQL) { System.out.println("##########BATCH UPDATE:"+updateSQL); jdbcTemplate.batchUpdate(updateSQL); } public JdbcTemplate getJdbcTemplate() { return jdbcTemplate; } @Autowired public void setJdbcTemplate(JdbcTemplate jdbcTemplate) { this.jdbcTemplate = jdbcTemplate; }
Apache Phoenix JDBC 驱动和Spring JDBCTemplate的集成
标签:phoenix 4.3.0 jdbc hbase 0.98
原文地址:http://blog.csdn.net/eric_sunah/article/details/44494321