I am new to Apache phoenix .How to use Apache phoenix with spring.what are the steps to connect to spring and Apache phoenix.how to configure jdbc Template with phoenix connection details.
Asked
Active
Viewed 2,138 times
1 Answers
2
1) First of all add specific Apache Phoenix dependency to your pom.xml file
2) Create data source object like 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 into your dao class
<bean id="someDao" class="com.stackoverlow.SomeDao">
<property name="dataSource" ref="dataSource" />
</bean>
4) Implement your dao
public class SomeDao extends NamedParameterJdbcDaoSupport {
@Override
public void insert(final SomeEntity someEntity) {
String sql = "upsert into someEntities(id, field) values (:id, :field)";
getNamedParameterJdbcTemplate().update(sql, new BeanPropertySqlParameterSource(someEntity));
}
}

IgorekPotworek
- 1,317
- 13
- 33
-
Thank for your reply. – kartik Sep 10 '15 at 11:16
-
Super:). If it works well for you, could you accept my answer? – IgorekPotworek Oct 21 '15 at 11:31
-
And how to add support for @Transactional? – sinujohn Jul 18 '16 at 11:49