-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
31 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package phoenix; | ||
|
||
import java.sql.Connection; | ||
import java.sql.DriverManager; | ||
import java.sql.PreparedStatement; | ||
import java.sql.ResultSet; | ||
|
||
/** | ||
* 直接使用原生jdbc访问Phoenix | ||
*/ | ||
public class PhoenixTest { | ||
|
||
public static void main(String[] args) throws Exception { | ||
Class.forName("org.apache.phoenix.jdbc.PhoenixDriver"); | ||
// 写上zookeeper地址 | ||
Connection connection = DriverManager.getConnection("jdbc:phoenix:localhost:2181"); | ||
|
||
PreparedStatement statement = connection.prepareStatement("select * from TEST"); | ||
|
||
ResultSet resultSet = statement.executeQuery(); | ||
|
||
while (resultSet.next()) { | ||
System.out.println(resultSet.getString("MYCOLUMN")); | ||
} | ||
|
||
statement.close(); | ||
connection.close(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters