初始化项目
This commit is contained in:
39
.gitignore
vendored
Normal file
39
.gitignore
vendored
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
target/
|
||||||
|
!.mvn/wrapper/maven-wrapper.jar
|
||||||
|
!**/src/main/**/target/
|
||||||
|
!**/src/test/**/target/
|
||||||
|
|
||||||
|
### IntelliJ IDEA ###
|
||||||
|
.idea/modules.xml
|
||||||
|
.idea/jarRepositories.xml
|
||||||
|
.idea/compiler.xml
|
||||||
|
.idea/libraries/
|
||||||
|
*.iws
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
.idea
|
||||||
|
|
||||||
|
### Eclipse ###
|
||||||
|
.apt_generated
|
||||||
|
.classpath
|
||||||
|
.factorypath
|
||||||
|
.project
|
||||||
|
.settings
|
||||||
|
.springBeans
|
||||||
|
.sts4-cache
|
||||||
|
|
||||||
|
### NetBeans ###
|
||||||
|
/nbproject/private/
|
||||||
|
/nbbuild/
|
||||||
|
/dist/
|
||||||
|
/nbdist/
|
||||||
|
/.nb-gradle/
|
||||||
|
build/
|
||||||
|
!**/src/main/**/build/
|
||||||
|
!**/src/test/**/build/
|
||||||
|
|
||||||
|
### VS Code ###
|
||||||
|
.vscode/
|
||||||
|
|
||||||
|
### Mac OS ###
|
||||||
|
.DS_Store
|
||||||
23
pom.xml
Normal file
23
pom.xml
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>com.bigdata</groupId>
|
||||||
|
<artifactId>phoenix0106</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>8</maven.compiler.source>
|
||||||
|
<maven.compiler.target>8</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.phoenix</groupId>
|
||||||
|
<artifactId>phoenix-client-hbase-2.4</artifactId>
|
||||||
|
<version>5.1.2</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
||||||
26
src/main/java/com/bigdata/phoenix/phoenixClient.java
Normal file
26
src/main/java/com/bigdata/phoenix/phoenixClient.java
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
package com.bigdata.phoenix;
|
||||||
|
|
||||||
|
import java.sql.*;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
public class phoenixClient {
|
||||||
|
public static void main(String[] args) throws SQLException {
|
||||||
|
// 标准的 JDBC 代码
|
||||||
|
// 1.添加链接
|
||||||
|
String url = "jdbc:phoenix:hadoop102,hadoop103,hadoop104:2181";
|
||||||
|
// 2. 创建配置
|
||||||
|
// 没有需要添加的必要配置 因为 Phoenix 没有账号密码
|
||||||
|
Properties properties = new Properties();
|
||||||
|
// 3. 获取连接
|
||||||
|
Connection connection = DriverManager.getConnection(url, properties);
|
||||||
|
// 5.编译 SQL 语句
|
||||||
|
PreparedStatement preparedStatement = connection.prepareStatement("select * from student");
|
||||||
|
// 1.执行语句
|
||||||
|
ResultSet resultSet = preparedStatement.executeQuery(); // 7.输出结果
|
||||||
|
while (resultSet.next ()){
|
||||||
|
System.out.println(resultSet.getString(2) );
|
||||||
|
}
|
||||||
|
// 8.关闭资源
|
||||||
|
connection.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user