If I execute these commands in spark-shell it correctly returns the data in the “people” table: The problem is if I close spark-shell and return it open, the connection to the database is not maintained. Answer As per Spark’s documentation, SparkContext and HiveContext get created inside the spark shell (when spark-shell command is executed) with HiveContext defined as SQLContext. As