Specifiy "use database" in Hadoop Hive HQL query


We have multiple databases defined in Hive. In Hive command line mode or a script I can issue "use database" followed by a query (example below). When I try to specify the use database in the report query dialog I get an errror. Also I replaced /defualt at the end of JDBC connection string with my database name and it did not like that. Is there a method to specify a database name?


use test;

select * from test_table;

bradley.harris's picture
Joined: Nov 30 2012 - 5:55am
Last seen: 7 years 7 months ago
we are specifying Database name at the time of connection.
anvy.varghese - 7 years 7 months ago
If I use the connection string below I connect to the default database. jdbc:hive://hdpencwy0001:10000/default If I point to the "test" database (jdbc:hive://hdpencwy0001:10000/test)I receive the following error: Error: net.sf.jasperreports.engine.JRException: Invalid Hive JDBC url:jdbc:hive://hdpencwy0001:10000/test Verified database and table with data exists. Using vesrion 5.
bradley.harris - 7 years 7 months ago
I am also facing same issue. I am just configuring hive with mysql instead of derby as mentioned in http://www.javacodegeeks.com/2012/02/big-data-analytics-with-hive-and.html. Will try and let you know.
anilguptakgp - 7 years 6 months ago
show 1 more...

Which version of iReport are you using?

marianol - 6 years 9 months ago

1 Answer:

Unfortuately the JDBC Hive driver only allows connecting to the "default" database (this is not a Jaspersoft limitation but a JDBC Hive driver one) - so to get around this just use the table aliasing in dot notation, like this: select * from store.sales Connects to database store, table sales! This is the page that points out the limitation in Hadoop Hive JDBC driver: https://cwiki.apache.org/confluence/display/Hive/HiveClient#HiveClient-JDBC
ernestoo's picture
Joined: Nov 29 2010 - 11:59am
Last seen: 2 years 9 months ago