Database Reference
In-Depth Information
Now, go to the Phoenix shell and perform the following step:
mark@mark-7:~/ThirdParty/bin$ ./sqlline.sh localhost
34/34 (100%) Done
0: jdbc:phoenix:localhost>
To exit from the Phoenix shell, type the following command (nothing
else works):
!quit.
Let's test some more examples:
mark@mark-7:~/ThirdParty/bin$ ./sqlline.sh localhost
../examples/stock_symbol.sql
34/34 (100%) Done
+------------+------------+
| SYMBOL | COMPANY |
+------------+------------+
| CRM | SalesForce.com |
+------------+------------+
Now, we are almost ready. Here is how you can run the Java code in Phoenix.
The crown jewel of JDBC, the connection line, looks like this:
Connection conn =
DriverManager.getConnection("jdbc:phoenix:localhost");
After this, your Java code treats HBase as any other SQL database.
Summary
In this chapter, we started writing Java code to read/write to HBase. We have also
seen how to control HBase with the help of the HBase shell. The most important step
though was our introduction to the Phoenix project, which permits SQL over HBase,
a smart sort of SQL at that. It allows you to operate through SQL statements in a
manner familiar to all SQL database users. It also allows you to read/write in a more
standard way even when you use Java code. Since SQL is the lingua franca of the
database world, we have laid the foundation to explain the HBase design principles
in a simple and easy manner.
In the next chapter, we will do a number of enhancements. We will give you the
power user way of addressing Phoenix, and show you how easy it makes things.
With this, we will be able to introduce the first design pattern.
 
Search WWH ::




Custom Search