I'm new at Hive and Hadoop. In my tutorial, I want to create table as
import java.sql.SQLException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.DriverManager;
public class HiveCreateDb {
private static String driverName = "org.apache.hive.jdbc.HiveDriver";
public static void main(String[] args) {
// Register driver and create driver instance
try {
Class.forName(driverName);
// get connection
Connection con = DriverManager.getConnection("jdbc:hive2://localhost:10000/mydb", "root", "");
Statement stmt = con.createStatement();
stmt.executeQuery("CREATE TABLE IF NOT EXISTS " + " employee ( e_id int, name String, "
+ " salary String)" + " STORED AS TEXTFILE");
System.out.println("Operation done successfully.");
con.close();
} catch (ClassNotFoundException e) {
System.err.println("class not found!!!!");
e.printStackTrace();
} catch (SQLException e) {
System.err.println("sql exception!!!");
e.printStackTrace();
}
}
}
When I run code I get this error
sql exception!!! java.sql.SQLException: The query did not generate a result set! at org.apache.hive.jdbc.HiveStatement.executeQuery(HiveStatement.java:393)
at tr.com.vedat.hive.HiveCreateDb.main(HiveCreateDb.java:25)
So, I couldn't find solution. Can anyone help me to find bug and lead to me correct way?