Hi Anil, If you use derby as metastore where ever you try to start hive cli it will create a metastore in that directory.
First option-Use other rdbms such as postgresql, mysql, oracle ... Second option- conf.set("javax.jdo.option.ConnectionURL", "jdbc:derby:;databaseName=/tmp/metastore_db;create=*false*"); so that only one metastore will be there and only one user can connect at any time. If another user want to connect your all sessions should be closed. Note ( I dont know java but I could see you are using derby and we can check these options) Thanks, Abirami On Fri, Jul 11, 2014 at 9:25 AM, AnilKumar B <akumarb2...@gmail.com> wrote: > Hi, > > I am trying to generate hive plan as below. But even after creating the > "src" table, I am facing, Table not found Exception due to MetaStore issue. > Can any one help me in resolving this? > > > private Driver createDriver() { > HiveConf conf = new HiveConf(Driver.class); > conf.set("hive.metastore.warehouse.dir", "file:///tmp/warehouse"); > conf.set("javax.jdo.option.ConnectionURL", > "jdbc:derby:;databaseName=/tmp/metastore_db;create=true"); > SessionState.start(conf); > Driver driver = new Driver(conf); > driver.init(); > return driver; > } > > Driver driver = createDriver(); > driver.compile("create table src (c1 string, c2 string)"); > int rc = driver.compile("EXPLAIN LOGICAL SELECT key, count(1) FROM > (SELECT key, value FROM src) subq1 GROUP BY key"); > > if (rc != 0) { > return; > } > > QueryPlan plan = driver.getPlan(); > org.apache.hadoop.hive.ql.exec.Task<? extends Serializable> task = plan > .getRootTasks().get(0); > ExplainWork work = (ExplainWork) task.getWork(); > > > > Thanks & Regards, > B Anil Kumar. >