I am new to spring, I am trying a simple web dynamic application getting data from database and showing on front end using impala. This is connector class :
private static final String IMPALAD_HOST = "host";
private static final String IMPALAD_JDBC_PORT = "port";
private static final String CONNECTION_URL = "jdbc:hive2://" + IMPALAD_HOST + ':' + IMPALAD_JDBC_PORT + "/;auth=noSasl";
private static final String JDBC_DRIVER_NAME = "org.apache.hive.jdbc.HiveDriver";
public Connection getConnection() throws ClassNotFoundException{
Connection con = null;
try {
Class.forName(JDBC_DRIVER_NAME);
con = DriverManager.getConnection(CONNECTION_URL,"","");
}catch (SQLException e) {
e.printStackTrace();
}
return con;
}`
HIve-connector jar is added in the java build path in eclipse. getConnection() works if i call it from a main method of a java class, but getConnection() gives hive driver not found exception if i call this method from jsp page. :
java.lang.ClassNotFoundException: org.apache.hive.jdbc.HiveDriver
You are not having the hive-jdbc.jar
in your webapplication archive. i.e. war file. it is being missed while packaging the application.You should place it in the WEB-INF/lib
directory. Please also ensure that you also add it in the deployment assembly of the eclipse project.
It works when you run the main class because the hive-jdbc.jar
is configured in the build path. It is different from webapplication perspective.
Note: ClassNotFoundException
shouldn't be thrown unless you are going to handle it. You should have all the required jars in your application package during runtime in classpath.
You are using the wrong Driver-Class. Use org.apache.hadoop.hive.jdbc.HiveDriver
instead.
I am new to spring, I am trying a simple web dynamic application getting data from database and showing on front end using impala. This is connector class :
private static final String IMPALAD_HOST = "host";
private static final String IMPALAD_JDBC_PORT = "port";
private static final String CONNECTION_URL = "jdbc:hive2://" + IMPALAD_HOST + ':' + IMPALAD_JDBC_PORT + "/;auth=noSasl";
private static final String JDBC_DRIVER_NAME = "org.apache.hive.jdbc.HiveDriver";
public Connection getConnection() throws ClassNotFoundException{
Connection con = null;
try {
Class.forName(JDBC_DRIVER_NAME);
con = DriverManager.getConnection(CONNECTION_URL,"","");
}catch (SQLException e) {
e.printStackTrace();
}
return con;
}`
HIve-connector jar is added in the java build path in eclipse. getConnection() works if i call it from a main method of a java class, but getConnection() gives hive driver not found exception if i call this method from jsp page. :
java.lang.ClassNotFoundException: org.apache.hive.jdbc.HiveDriver
You are not having the hive-jdbc.jar
in your webapplication archive. i.e. war file. it is being missed while packaging the application.You should place it in the WEB-INF/lib
directory. Please also ensure that you also add it in the deployment assembly of the eclipse project.
It works when you run the main class because the hive-jdbc.jar
is configured in the build path. It is different from webapplication perspective.
Note: ClassNotFoundException
shouldn't be thrown unless you are going to handle it. You should have all the required jars in your application package during runtime in classpath.
You are using the wrong Driver-Class. Use org.apache.hadoop.hive.jdbc.HiveDriver
instead.
0 commentaires:
Enregistrer un commentaire