Follow up of PR #1071 for Java API

JIRA issue: [SPARK-2094](https://issues.apache.org/jira/browse/SPARK-2094)

Updated `JavaSQLContext` and `JavaHiveContext` similar to what we've done to `SQLContext` and `HiveContext` in PR #1071. Added corresponding test case for Spark SQL Java API.