Skip to content

Commit f1229c4

Browse files
author
weiye
committed
WeiYe-Jing#153 bug fixed
1 parent e02e509 commit f1229c4

File tree

2 files changed

+126
-122
lines changed

2 files changed

+126
-122
lines changed

datax-admin/pom.xml

+8-4
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,14 @@
468468
<artifactId>jersey-guice</artifactId>
469469
<groupId>com.sun.jersey.contribs</groupId>
470470
</exclusion>
471+
<exclusion>
472+
<artifactId>log4j-slf4j-impl</artifactId>
473+
<groupId>org.apache.logging.log4j</groupId>
474+
</exclusion>
475+
<exclusion>
476+
<artifactId>hive-shims-common</artifactId>
477+
<groupId>org.apache.hive.shims</groupId>
478+
</exclusion>
471479
</exclusions>
472480
</dependency>
473481

@@ -524,10 +532,6 @@
524532
<artifactId>hbase-annotations</artifactId>
525533
<groupId>org.apache.hbase</groupId>
526534
</exclusion>
527-
<exclusion>
528-
<artifactId>hbase-common</artifactId>
529-
<groupId>org.apache.hbase</groupId>
530-
</exclusion>
531535
<exclusion>
532536
<artifactId>hbase-protocol</artifactId>
533537
<groupId>org.apache.hbase</groupId>
Original file line numberDiff line numberDiff line change
@@ -1,118 +1,118 @@
1-
package com.wugui.datax.admin.tool.query;
2-
3-
4-
import com.wugui.datax.admin.util.ReflectionUtil;
5-
import org.apache.phoenix.compile.ColumnProjector;
6-
import org.apache.phoenix.compile.RowProjector;
7-
import org.apache.phoenix.util.SchemaUtil;
8-
import sqlline.SqlLine;
9-
import org.apache.phoenix.jdbc.PhoenixDriver;
10-
import java.io.IOException;
11-
import java.sql.*;
12-
import java.util.List;
13-
import java.util.Properties;
14-
15-
public class Hbase11xsqlToolTest {
16-
17-
public static void main(String[] args) throws Exception {
18-
String connectionString="jdbc:phoenix:hadoop1,hadoop2,hadoop3:2181";
19-
// String tableName = "SYSTEM.CATALOG";
20-
String tableName = "STOCK_SYMBOL";
21-
22-
// getPColumns(connectionString,tableName);
23-
24-
25-
showTables(connectionString);
26-
27-
getColumns(connectionString,tableName);
28-
29-
// showFields(connectionString,null);
30-
}
31-
32-
33-
private static int getSize(ResultSet rs) {
34-
try {
35-
if (rs.getType() == ResultSet.TYPE_FORWARD_ONLY) {
36-
return -1;
37-
}
38-
39-
rs.last();
40-
int total = rs.getRow();
41-
rs.beforeFirst();
42-
return total;
43-
} catch (SQLException sqle) {
44-
return -1;
45-
} catch (AbstractMethodError ame) {
46-
return -1;
47-
}
48-
}
49-
50-
51-
52-
private static void getColumns(String connectionString, String tableName) throws SQLException {
53-
Connection conn = DriverManager.getConnection(connectionString);
54-
DatabaseMetaData metaData = conn.getMetaData();
55-
ResultSet columns = metaData.getColumns(conn.getCatalog(), null, tableName, "%");
56-
57-
58-
try {
59-
int total = getSize(columns);
60-
int index = 0;
61-
62-
while (columns.next()) {
63-
64-
System.out.println(columns.getString("COLUMN_NAME")+" "+columns.getString("TYPE_NAME"));
65-
}
66-
67-
} finally {
68-
columns.close();
69-
}
70-
71-
72-
}
73-
74-
75-
76-
77-
// 查询所有的表
78-
private static void showTables(String connectionString) throws SQLException, IOException {
79-
Connection conn = DriverManager.getConnection(connectionString);
80-
DatabaseMetaData metaData = conn.getMetaData();
81-
ResultSet rs = metaData.getTables(conn.getCatalog(), null, "%", new String[] {"TABLE"});
82-
83-
try {
84-
while (rs.next()) {
85-
System.out.println(rs.getString("TABLE_NAME"));
86-
}
87-
} finally {
88-
try {
89-
rs.close();
90-
} catch (Exception e) {
91-
}
92-
}
93-
94-
}
95-
96-
97-
// 查询所有的表
98-
private static void showFields(String connectionString,String tableName) throws SQLException, NoSuchFieldException, IllegalAccessException {
99-
100-
Connection conn = DriverManager.getConnection(connectionString);
101-
102-
103-
104-
Statement stat = conn.createStatement();
105-
ResultSet rs = stat.executeQuery("select * from LKY_STOCK_SYMBOL limit 1");
106-
RowProjector row = (RowProjector) ReflectionUtil.getPrivateField(rs, "rowProjector");
107-
List<? extends ColumnProjector> column = row.getColumnProjectors();
108-
109-
for (int i = 0; i < column.size(); i++) {
110-
ColumnProjector columnProjector = column.get(i);
111-
System.out.println("这是字段信息 ====>" + column.get(i).getName());
112-
//arry[i] = column.get(i).getName();
113-
}
114-
stat.close();
115-
conn.close();
116-
}
117-
118-
}
1+
//package com.wugui.datax.admin.tool.query;
2+
//
3+
//
4+
//import com.wugui.datax.admin.util.ReflectionUtil;
5+
//import org.apache.phoenix.compile.ColumnProjector;
6+
//import org.apache.phoenix.compile.RowProjector;
7+
//import org.apache.phoenix.util.SchemaUtil;
8+
//import sqlline.SqlLine;
9+
//import org.apache.phoenix.jdbc.PhoenixDriver;
10+
//import java.io.IOException;
11+
//import java.sql.*;
12+
//import java.util.List;
13+
//import java.util.Properties;
14+
//
15+
//public class Hbase11xsqlToolTest {
16+
//
17+
// public static void main(String[] args) throws Exception {
18+
// String connectionString="jdbc:phoenix:hadoop1,hadoop2,hadoop3:2181";
19+
//// String tableName = "SYSTEM.CATALOG";
20+
// String tableName = "STOCK_SYMBOL";
21+
//
22+
//// getPColumns(connectionString,tableName);
23+
//
24+
//
25+
// showTables(connectionString);
26+
//
27+
// getColumns(connectionString,tableName);
28+
//
29+
//// showFields(connectionString,null);
30+
// }
31+
//
32+
//
33+
// private static int getSize(ResultSet rs) {
34+
// try {
35+
// if (rs.getType() == ResultSet.TYPE_FORWARD_ONLY) {
36+
// return -1;
37+
// }
38+
//
39+
// rs.last();
40+
// int total = rs.getRow();
41+
// rs.beforeFirst();
42+
// return total;
43+
// } catch (SQLException sqle) {
44+
// return -1;
45+
// } catch (AbstractMethodError ame) {
46+
// return -1;
47+
// }
48+
// }
49+
//
50+
//
51+
//
52+
// private static void getColumns(String connectionString, String tableName) throws SQLException {
53+
// Connection conn = DriverManager.getConnection(connectionString);
54+
// DatabaseMetaData metaData = conn.getMetaData();
55+
// ResultSet columns = metaData.getColumns(conn.getCatalog(), null, tableName, "%");
56+
//
57+
//
58+
// try {
59+
// int total = getSize(columns);
60+
// int index = 0;
61+
//
62+
// while (columns.next()) {
63+
//
64+
// System.out.println(columns.getString("COLUMN_NAME")+" "+columns.getString("TYPE_NAME"));
65+
// }
66+
//
67+
// } finally {
68+
// columns.close();
69+
// }
70+
//
71+
//
72+
// }
73+
//
74+
//
75+
//
76+
//
77+
// // 查询所有的表
78+
// private static void showTables(String connectionString) throws SQLException, IOException {
79+
// Connection conn = DriverManager.getConnection(connectionString);
80+
// DatabaseMetaData metaData = conn.getMetaData();
81+
// ResultSet rs = metaData.getTables(conn.getCatalog(), null, "%", new String[] {"TABLE"});
82+
//
83+
// try {
84+
// while (rs.next()) {
85+
// System.out.println(rs.getString("TABLE_NAME"));
86+
// }
87+
// } finally {
88+
// try {
89+
// rs.close();
90+
// } catch (Exception e) {
91+
// }
92+
// }
93+
//
94+
// }
95+
//
96+
//
97+
// // 查询所有的表
98+
// private static void showFields(String connectionString,String tableName) throws SQLException, NoSuchFieldException, IllegalAccessException {
99+
//
100+
// Connection conn = DriverManager.getConnection(connectionString);
101+
//
102+
//
103+
//
104+
// Statement stat = conn.createStatement();
105+
// ResultSet rs = stat.executeQuery("select * from LKY_STOCK_SYMBOL limit 1");
106+
// RowProjector row = (RowProjector) ReflectionUtil.getPrivateField(rs, "rowProjector");
107+
// List<? extends ColumnProjector> column = row.getColumnProjectors();
108+
//
109+
// for (int i = 0; i < column.size(); i++) {
110+
// ColumnProjector columnProjector = column.get(i);
111+
// System.out.println("这是字段信息 ====>" + column.get(i).getName());
112+
// //arry[i] = column.get(i).getName();
113+
// }
114+
// stat.close();
115+
// conn.close();
116+
// }
117+
//
118+
//}

0 commit comments

Comments
 (0)