Exception in thread "main" org.apache.spark.sql.catalyst.analysis.NoSuchDatabaseException: Database 'retail_db' not found;

Not able show hive databases on spark-submit, but able to show in spark-shell.
Please find the code below,

val warehouseLocation = new File("/apps/hive/warehouse/").getAbsolutePath
val spark = SparkSession
.builder()
.appName(PropertyUtils.getString(“app.name”)).master(executionMode)
.config(“spark.sql.shuffle.partitions”, 10)
.config(“spark.sql.warehouse.dir”, warehouseLocation)
.enableHiveSupport()
.getOrCreate()

spark.sql(“show databases”).show()

Above line is throwing below exception,
Exception in thread “main” org.apache.spark.sql.catalyst.analysis.NoSuchDatabaseException: Database ‘retail_db’ not found;

Step -1:

Modify hive-site.xml with below.

hive.metastore.warehouse.dir /user/hive/warehouse/ hive.metastore.uris thrift://localhost:9083

Step -2

stop and start all hadoop services

./stop-all.sh
./start-all.sh

Step 3:

start hive metastore

hive --service metastore

Step -4

val spark = SparkSession.builder().appName(“Invoke Hive Table”).master(“local”)
.config(“spark.sql.warehouse.dir”,"/user/hive/warehouse")
.config(“hive.metastore.uris”,“thrift://localhost:9083”)
.enableHiveSupport().getOrCreate()

import spark.sql
import spark.implicits._

val dblist = sql("show databases")

dblist.show