HiveServer2 doesn't recognize hive.aux.jars.path - java

I have several jar files listed in my hive-site.xml. I have a table that uses special FileInputFormat.
When I run hive, I can do something like: describe my-table. Works fine.
When I run hiveServer2 and connect from beeline. I can see the table, but when I do describe my-table I get:
Error: Error while processing statement: FAILED: RuntimeException java.lang.ClassNotFoundException: package.file.input.format.class.name (state=42000,code=40000)
What do I need to do to make sure hiveserver2 has access to the jar files?

Have you done the three steps: user-defined-function with HiveServer2

Related

Corrupt H2 Database. Failed to recovery using the Recovery Tool

Today one of my H2 database failed to connect and presented the following error message:
Unable to obtain connection from database (jdbc:h2:file:C:\Users\Username\.appfiles\db\appdb) for user 'sa': File corrupted while reading record: null. Possible solution: use the recovery tool [90030-200]
SQL State : 90030
Error Code : 90030
Message : File corrupted while reading record: null. Possible solution: use the recovery tool [90030-200]
As suggested I tried to use the recover tool as instructed by the documentation, the steps I executed were the following:
Go to your h2 data file directory
java -cp h2-1.4.200.jar org.h2.tools.Recover
Use SQL file generated by the recovery tool to recreate the database
The steps created two files: a .sql and a .txt file, but the SQL generated by the tool didn't have any data or DDL from the database, just some aliases and a bunch of comments. The content of the files are linked below, if they can help shed any light on what went wrong during the process.
This is the .sql file output: https://pastebin.com/DFfwPemP
This is the .txt file output: https://pastebin.com/6zwCgqN3
Is there any step I'm not doing right or is any other thing I can try to recover this db? Any suggestion is welcome.
Run that files with
java -cp h2-1.4.200.jar org.h2.tools.RunScript -url jdbc:h2:[path to destination db file]/[db name] -user [user] -password [password] -script [text file/sql file]

Java invoke Sqoop fails on hive import

I have a Java Program which run a Sqoop operation by Sqoop.runTool() method. Until now, I can successfully run this operation to get data from oracle to HDFS.
but when I add the parameter --hive-import, it reports an warning in hive's log file in /tmp/root/hive.log:
hive-site.xml not found on CLASSPATH
Mean while I noticed that,run by JavaAPI and by plain sqoop Command,the console message have a different output:
Logging initialized musing configuration in jar:file:/opt/cloudera/parcels/CDH/jars/hive-exec-1.1.0!hive-log4j.properties
Logging initialized musing configuration in jar:file:/opt/cloudera/parcels/CDH/jars/hive-common-1.1.0!hive-log4j.properties
Will be grateful for any help.

Use sqlite with Java on Raspberry pi

I have created small code of sqlite database in java.
Below is the code for connection with database,
Class.forName("org.sqlite.JDBC");
objConnection=DriverManager.getConnection("jdbc:sqlite:/etc/javaData/Test.db");
In this code the exception thrown in second line for getConnection(). I am trying this code on Raspberry pi. How to fix the exceptionrelated to this
Exception
SQLITE addDeviceInfo()-[SQLITE] SQL Exception occured. RetryCount:1 (MAX Retry: 2) ErrorCode: 27154 Exception Message: Error opening connection Stack Trace: java.sql.SQLException: Error opening connection
at org.sqlite.core.CoreConnection.open(CoreConnection.java:140)
at org.sqlite.core.CoreConnection.<init>(CoreConnection.java:66)
at org.sqlite.jdbc3.JDBC3Connection.<init>(JDBC3Connection.java:21)
at org.sqlite.jdbc4.JDBC4Connection.<init>(JDBC4Connection.java:23)
at org.sqlite.SQLiteConnection.<init>(SQLiteConnection.java:45)
at org.sqlite.JDBC.createConnection(JDBC.java:114)
at org.sqlite.JDBC.connect(JDBC.java:88)
at java.sql.DriverManager.getConnection(DriverManager.java:571)
at java.sql.DriverManager.getConnection(DriverManager.java:215)
at kmbt.DCA.SQLite.DCASQLiteUtility.getSQliteConnection(DCASQLiteUtility.java:152)
at kmbt.DCA.SQLite.ManagedDeviceSetting.SQLite_ManagedDeviceSettingManager.addDeviceInfo(SQLite_ManagedDeviceSettingManager.java:981)
at kmbt.DCA.DCAChildProcessMng.InitManagedDeviceInfo(DCAChildProcessMng.java:5726)
at kmbt.DCA.DCAChildProcessMng.InitSQLite(DCAChildProcessMng.java:4387)
at kmbt.DCA.DCAChildProcessMng.start(DCAChildProcessMng.java:365)
at kmbt.DCA.DCAChildProcess.main(DCAChildProcess.java:23)
Caused by: java.lang.Exception: Error loading native library: /org/sqlite/native/Linux/arm/libsqlitejdbc.so
at org.sqlite.SQLiteJDBCLoader.loadSQLiteNativeLibrary(SQLiteJDBCLoader.java:243) at org.sqlite.SQLiteJDBCLoader.initialize(SQLiteJDBCLoader.java:65)
at org.sqlite.core.NativeDB.load(NativeDB.java:53)
at org.sqlite.core.CoreConnection.open(CoreConnection.java:136)
... 14 more
Your code seems correct and the exception thrown seems don't have nothing to do with some library's problem.
The only thing that sound me a little bit strange, is that you put your database in /etc folder. First of all it is not very correct, because the /etc folder is used to store config file and not data. In addition to this, maybe there could be some kind of issue with r/w folder's permissions. Try to move your database to your home directory or to other any directory owned by your user and not from root.
Hope this will be usefull for you.
-- EDIT --
Ok, the problem is that you have downloaded the wrong library:
Error loading native library: /org/sqlite/native/Linux/arm/libsqlitejdbc.so
You have to use the ARM build of the sqlite library. Try to take a look at this:
Error opening connection SQLite on Raspberry pi
and this: Sqlite4java on Raspberry Pi
I also faced java.lang.Exception: Error loading native library: /org/sqlite/native/Linux/arm/libsqlitejdbc.so
Looking into sqlite-jdbc-3.8.6.jar I found that /org/sqlite/native/Linux/ contains no arm folder -> sqlite is not compiled for arm.
With these changes I've managed to build on the pi: https://bitbucket.org/kidmose/sqlite-jdbc/commits/cb7a7ef62c034938e8ecb737b148e5c80877c083
pi#raspberry ~/sqlite-jdbc $ export JAVA_HOME=/usr/lib/jvm/jdk-7-oracle-armhf/
pi#raspberry ~/sqlite-jdbc $ chmod 755 ./amalgamation_version.sh
pi#raspberry ~/sqlite-jdbc $ make
Replacing the old jar with the newly built one solved my problem.
All credit goes to: https://pidome.wordpress.com/2013/10/01/java-goes-hard-on-the-raspberry-pi-so-does-pidome/

SQOOP SQLSERVER Failed to load driver " appropriate connection manager is not being set"

I downloaded sqljdbc4.jar. I'm invoking sqoop like so from the folder (where the jar is stored):
sqoop list-tables --driver com.microsoft.jdbc.sqlserver.SQLServerDriver --connect jdbc:sqlserver://localhost:1433;user=me;password=myPassword; -libjars=./sqljdbc4.jar
I'm getting the following warning & error:
13/10/25 18:38:13 WARN sqoop.ConnFactory: Parameter --driver is set to an explicit driver however appropriate connection manager is not being set (via --connection-manager). Sqoop is going to fall back to org.apache.sqoop.manager.GenericJdbcManager. Please specify explicitly which connection manager should be used next time.
13/10/25 18:38:13 INFO manager.SqlManager: Using default fetchSize of 1000
13/10/25 18:38:13 ERROR sqoop.Sqoop: Got exception running Sqoop: java.lang.RuntimeException: Could not load db driver class: com.microsoft.jdbc.sqlserver.SQLServerDriver
java.lang.RuntimeException: Could not load db driver class: com.microsoft.jdbc.sqlserver.SQLServerDriver
at org.apache.sqoop.manager.SqlManager.makeConnection(SqlManager.java:727)
at org.apache.sqoop.manager.GenericJdbcManager.getConnection(GenericJdbcManager.java:52)
at org.apache.sqoop.manager.SqlManager.listTables(SqlManager.java:418)
at org.apache.sqoop.tool.ListTablesTool.run(ListTablesTool.java:49)
at org.apache.sqoop.Sqoop.run(Sqoop.java:145)
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
at org.apache.sqoop.Sqoop.runSqoop(Sqoop.java:181)
at org.apache.sqoop.Sqoop.runTool(Sqoop.java:220)
at org.apache.sqoop.Sqoop.runTool(Sqoop.java:229)
at org.apache.sqoop.Sqoop.main(Sqoop.java:238)
UPDATE
I changed the command line to reflect the comments below, I get the same error:
sqoop list-databases -libjars=<ABSOLUTE_PATH>/jars/sqljdbc4.jar --connect jdbc:sqlserver://localhost:1433;user=me;password=password
13/10/28 17:00:33 ERROR sqoop.Sqoop: Got exception running Sqoop: java.lang.RuntimeException: Could not load db driver class: com.microsoft.sqlserver.jdbc.SQLServerDriver
java.lang.RuntimeException: Could not load db driver class: com.microsoft.sqlserver.jdbc.SQLServerDriver
at org.apache.sqoop.manager.SqlManager.makeConnection(SqlManager.java:727)
at org.apache.sqoop.manager.GenericJdbcManager.getConnection(GenericJdbcManager.java:52)
at org.apache.sqoop.manager.CatalogQueryManager.listDatabases(CatalogQueryManager.java:57)
at org.apache.sqoop.tool.ListDatabasesTool.run(ListDatabasesTool.java:49)
at org.apache.sqoop.Sqoop.run(Sqoop.java:145)
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
at org.apache.sqoop.Sqoop.runSqoop(Sqoop.java:181)
at org.apache.sqoop.Sqoop.runTool(Sqoop.java:220)
at org.apache.sqoop.Sqoop.runTool(Sqoop.java:229)
at org.apache.sqoop.Sqoop.main(Sqoop.java:238)
When I look at the listing of sqljdbc4.jar, I do see the class in that path... Is it possible that libjars option isn't doing what I think it is supposed to do?
In vast majority of cases using parameter --driver is not required and even more will lead to an undesirable behaviour. I would strongly recommend dropping this argument entirely from your command line. Check out Connectors vs Drivers blog post for more details.
Also in addition you are specifying a nonexistent JDBC Driver class. The correct one is:
com.microsoft.sqlserver.jdbc.SQLServerDriver
You can see it in the official docs, whereas you are specifying
com.microsoft.jdbc.sqlserver.SQLServerDriver
Notice the different order of jdbc and sqlserver packages. This is one of the reasons why it's recommended to not use the --driver option at all.
You need to put sqljdbc4.jar in $SQOOP_HOME/lib and also add sqoop-1.4.4.jar or whatever version you are using along with sqljdbc4.jar to $HADOOP_HOME/lib.
I'm using Hadoop-2.2.0, so i put it inside $HADOOP_HOME/share/hadoop/common/lib directory, and use the following command to do the import:
export HCAT_HOME=/home/Kuntal/BIG_DATA/hive-0.12.0/hcatalog
(sometimes HCatlog of Hive needs to be exported or set.)
./sqoop-import --connect "jdbc:sqlserver://IP\INSTANCE;port=1433;username=USERNAME;password=PASSWORD;database=DATABASE_NAME" --table TABLE_NAME --target-dir hdfs://localhost:50315/sqoop --m 1
Sometimes you have to specify the port, otherwise default works. Hope you find it useful.
According to this sqoop documentation, generic options like -libjars must come before tool-specific options:
Generic Hadoop command-line arguments:
(must preceed any tool-specific arguments)
...
-libjars <comma separated list of jars> specify comma separated jar files to include in the classpath.
Recently came across this same problem. Even though documentation says that it will pick up additional jar files. The problem is I believe propagated from Hadoop jar command line option. -libjars is not reliable option to set additional jar file path.
Instead, choose HADOOP_CLASSPATH option to setup additional jar files.
In my case, I had multiple different versions of driver JAR, but using -libjars was not correctly picking up file for me.
To resolve this, I specified
export HADOOP_CLASSPATH=/$SQOOP_HOME/<path_to_driver>.jar
This makes sure that correct JAR file gets loaded.

SQLException: No suitable driver found for jdbc:mysql://localhost:3306/dbname

I've inherited a project (and I have absolutly no experience of Java) and I'm rather stuck.
We have a server running redhat, which I needed to update one of the jar files. So I simply copied up the updated file and restarted the service for that file. However this process has worked on our other server I did that too but on this one it comes up with the below in the log file.
Exception: com.mysql.jdbc.Driver
SQLException: No suitable driver found for jdbc:mysql://localhost:3306/dbanme
The jar files are uploaded to a folder in the root of the website and within that jar folder is a lib folder where mysql-connector-java-5.1.6-bin.jar is located.
Does anyone know what I could be missing as I'm a newbie to linux aswell.
Thanks in advance
java.sql.SQLException: No suitable driver found
This exception can have 2 causes:
The JDBC driver is not loaded at all.
URL does not match any of the loaded JDBC drivers.
Since the driver seems to be loaded , it look like that the URL is not valid on that machine:
jdbc:mysql://localhost:3306/dbname
Do you have mysql running and listening on port 3306 on that machine. Also make sure you hte schema dbname there.
You need only set that:
[jdbc:mysql://localhost/dbanme]
instead of
[jdbc:mysql://localhost:3306/dbanme]
Because java compiler default understand a port 3306, so no need to fill "3306" after "localhost:"

Categories

Resources