Java Access Phoenix Connection

Source: Internet
Author: User

Two methods, one is to use the JDBC connection directly, and one is to use the spring connection.

The JDBC connection and access Oracle steps are the same:

Test Phoenix connection///////////////string testsql = "SELECT \" 1\ ", \" 2\ "from  Fengji where rowid like ' 1-2017041 3% ' "; try {class.forname (" Org.apache.phoenix.jdbc.PhoenixDriver ");} catch (ClassNotFoundException E1) { System.out.println ("Org.apache.phoenix.jdbc.PhoenixDriver not Found");} List<integer>reslist = new arraylist<integer> (); Connection Con1 = drivermanager.getconnection ("Jdbc:phoenix:ccs01a:2181/hbase", "", "" "); Statement stmt = Con1.createstatement (); ResultSet RSet = Stmt.executequery (Testsql), while (Rset.next ()) {Reslist.add (Rset.getint ("1"));} System.out.println (Reslist.size ()); Stmt.close (); Con1.close ();/////////////////////////////////////

2, Spring and Oracle are basically the same, need to modify the configuration file:

1     <!--Phoenix Configuration -2     <BeanID= "Phoenixjdbctemplate"3 class= "Org.springframework.jdbc.core.JdbcTemplate">4         <Constructor-argref= "Phoenixdatasource"/>5         <Qualifiervalue= "Phoenixjdbctemplate"></Qualifier>6     </Bean>7     <BeanID= "Phoenixdatasource"class= "Org.apache.commons.dbcp.BasicDataSource">8         < Propertyname= "Driverclassname"value= "Org.apache.phoenix.jdbc.PhoenixDriver"/>9         < Propertyname= "url"value= "Jdbc:phoenix:ccs01a:2181/hbase"/>Ten         < Propertyname= "username"value=""/> One         < Propertyname= "Password"value=""/> A         < Propertyname= "InitialSize"value= " the"/> -         < Propertyname= "Maxactive"value= "0"/> -         <!--because Phoenix does not automatically commit when making data changes, you must add the Defaultautocommit property, otherwise it will cause the data to fail to commit - the         < Propertyname= "Defaultautocommit"value= "true"/> -     </Bean>

Java Access Phoenix Connection

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.