java - spring apache phoenix integration on Hbase steps -
i new apache phoenix .how use apache phoenix spring.what steps connect spring , apache phoenix.how configure jdbc template phoenix connection details.
1) first of add specific apache phoenix dependency pom.xml file
2) create data source object this:
<bean id="datasource" class="org.apache.commons.dbcp.basicdatasource"> <property name="driverclassname" value="org.apache.phoenix.jdbc.phoenixdriver" /> <property name="url" value="jdbc:phoenix:localhost" /> </bean>
3) inject datasource dao class
<bean id="somedao" class="com.stackoverlow.somedao"> <property name="datasource" ref="datasource" /> </bean>
4) implement dao
public class somedao extends namedparameterjdbcdaosupport { @override public void insert(final someentity someentity) { string sql = "upsert someentities(id, field) values (:id, :field)"; getnamedparameterjdbctemplate().update(sql, new beanpropertysqlparametersource(someentity)); } }
Comments
Post a Comment