我在cloudera集群上安装了ApachePhoenix。我正在尝试连接到数据库并运行一些简单的sql命令。我的代码在下面。我正在本地创建一个可执行jar文件,并在集群上运行它。
我收到以下警告。有人知道他们是什么吗。
log4j:WARN No appenders could be found for logger (org.apache.hadoop.conf.Configuration.deprecation).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
package mysqljbdctest;
import java.sql.*
public class PhoenixJDBC {
public static void main(String args[]) {
String connectionURL = "jdbc:phoenix:52.153.31.118:2181,52.153.111.8:2181,52.134.169.130:2181";
try {
//Register JDBC Driver
Class.forName("org.apache.phoenix.jdbc.PhoenixDriver").newInstance();
Connection conn = DriverManager.getConnection("jdbc:phoenix:54.154.34.128","","");
//Create a Statement class to execute the SQL statement
Statement stmt = conn.createStatement();
//Execute the SQL statement and get the results in a Resultset
ResultSet rs = stmt.executeQuery("select * from STOCK_SYMBOL");
// Iterate through the ResultSet, displaying two values
// for each row using the getString method
while (rs.next())
System.out.println("Name= " + rs.getString("host"));
}
catch (SQLException e) {
e.printStackTrace();
}
catch (Exception e) {
e.printStackTrace();
}
}
}
1条答案
按热度按时间n3schb8v1#
在类路径中添加log4j.xml或log4j.properties,然后重试,对于独立的java应用程序,请确保log4j.properties文件位于java web应用程序的project/classes目录下,确保log4j.properties文件位于下面的web inf/classes目录下是一个示例