This is an automated email from the ASF dual-hosted git repository.
okumin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git
The following commit(s) were added to refs/heads/master by this push:
new 7a7596f9773 HIVE-29258: Remove Class.forName() for driver loading
(#6207)
7a7596f9773 is described below
commit 7a7596f977395d9e739be247eaa65c996d38c203
Author: Raghav Aggarwal <[email protected]>
AuthorDate: Mon Dec 1 04:57:31 2025 +0530
HIVE-29258: Remove Class.forName() for driver loading (#6207)
* HIVE-29258: Remove Class.forName() for driver loading
* Addressing SonaType
* Addressing review comments
* Remove Reflection code in BeeLine.java, DatabaseConnection.java and
Commands.java to leverage ServiceLoader
* Review comments
---
.../src/java/org/apache/hive/beeline/BeeLine.java | 25 +++---------
.../src/java/org/apache/hive/beeline/Commands.java | 47 +++++++++++-----------
.../apache/hive/beeline/DatabaseConnection.java | 32 +++++----------
.../org/apache/hive/beeline/ProxyAuthTest.java | 2 -
.../org/apache/hive/beeline/TestShutdownHook.java | 6 +--
.../templeton/tool/TempletonControllerJob.java | 5 ---
.../src/main/java/org/apache/hive/hplsql/Conn.java | 5 ---
.../hive/minikdc/JdbcWithMiniKdcSQLAuthTest.java | 1 -
.../hive/minikdc/TestHS2AuthMechsWithMiniKdc.java | 1 -
.../apache/hive/minikdc/TestHS2JWTWithMiniKdc.java | 1 -
.../hive/minikdc/TestHs2HooksWithMiniKdc.java | 1 -
.../minikdc/TestJdbcNonKrbSASLWithMiniKdc.java | 2 -
.../hive/minikdc/TestJdbcWithDBTokenStore.java | 2 -
.../minikdc/TestJdbcWithDBTokenStoreNoDoAs.java | 2 -
.../apache/hive/minikdc/TestJdbcWithMiniKdc.java | 1 -
.../hive/minikdc/TestJdbcWithMiniKdcCookie.java | 6 ---
.../apache/hive/minikdc/TestSSLWithMiniKdc.java | 2 -
.../apache/hadoop/hive/ql/TestAutoPurgeTables.java | 2 -
.../ql/TestMetaStoreLimitPartitionRequest.java | 1 -
.../hive/ql/processor/TestShowProcessList.java | 1 -
.../TestReExecuteKilledTezAMQueryPlugin.java | 1 -
.../apache/hive/beeline/TestBeeLineWithArgs.java | 4 +-
.../hive/beeline/TestBeelinePasswordOption.java | 4 +-
.../BeelineWithHS2ConnectionFileTestBase.java | 1 -
.../apache/hive/jdbc/AbstractJdbcTriggersTest.java | 2 -
.../jdbc/AbstractTestJdbcGenericUDTFGetSplits.java | 2 -
.../org/apache/hive/jdbc/BaseJdbcWithMiniLlap.java | 1 -
.../org/apache/hive/jdbc/TestActivePassiveHA.java | 1 -
.../java/org/apache/hive/jdbc/TestCSRFFilter.java | 1 -
.../java/org/apache/hive/jdbc/TestJdbcDriver2.java | 2 -
.../org/apache/hive/jdbc/TestJdbcWithMiniHA.java | 1 -
.../jdbc/TestJdbcWithMiniHS2ErasureCoding.java | 1 -
.../hive/jdbc/TestJdbcWithServiceDiscovery.java | 1 -
.../TestKillQueryWithAuthorizationDisabled.java | 1 -
.../java/org/apache/hive/jdbc/TestNoSaslAuth.java | 1 -
.../org/apache/hive/jdbc/TestRestrictedList.java | 2 -
.../test/java/org/apache/hive/jdbc/TestSSL.java | 1 -
.../hive/jdbc/TestServiceDiscoveryWithMiniHS2.java | 1 -
.../hive/jdbc/TestTriggersMoveWorkloadManager.java | 2 -
.../hive/jdbc/TestTriggersWorkloadManager.java | 2 -
.../apache/hive/jdbc/TestWMMetricsWithTrigger.java | 1 -
.../java/org/apache/hive/jdbc/TestXSRFFilter.java | 1 -
.../jdbc/authorization/TestHS2AuthzContext.java | 1 -
.../authorization/TestHS2AuthzSessionContext.java | 1 -
.../authorization/TestJdbcMetadataApiAuth.java | 1 -
.../TestJdbcWithSQLAuthUDFBlacklist.java | 2 -
.../TestJdbcWithSQLAuthorization.java | 2 -
.../apache/hive/jdbc/cbo_rp_TestJdbcDriver2.java | 4 +-
.../org/apache/hive/jdbc/miniHS2/TestMiniHS2.java | 6 ---
.../apache/hive/service/TestDFSErrorHandling.java | 1 -
.../service/TestHS2ImpersonationWithRemoteMS.java | 2 -
.../service/auth/TestCustomAuthentication.java | 1 -
.../auth/TestHttpCookieAuthenticationTest.java | 3 --
.../auth/TrustDomainAuthenticationTest.java | 1 -
.../auth/jwt/TestHttpJwtAuthentication.java | 1 -
.../thrift/TestThriftCliServiceMessageSize.java | 1 -
.../hive/ql/externalDB/AbstractExternalDB.java | 3 +-
.../java/org/apache/hive/jdbc/miniHS2/MiniHS2.java | 5 ---
.../hadoop/hive/llap/LlapBaseInputFormat.java | 7 ----
.../jdbc/AbstractJDBCConnectorProvider.java | 7 ----
.../tools/schematool/HiveSchemaHelper.java | 6 ---
.../metastore/txn/jdbc/NoPoolConnectionPool.java | 32 ++-------------
.../hadoop/hive/metastore/utils/TestTxnDbUtil.java | 6 +--
.../hive/testutils/jdbc/HiveBurnInClient.java | 7 +---
64 files changed, 55 insertions(+), 224 deletions(-)
diff --git a/beeline/src/java/org/apache/hive/beeline/BeeLine.java
b/beeline/src/java/org/apache/hive/beeline/BeeLine.java
index 3cbbc826d8d..bef95340965 100644
--- a/beeline/src/java/org/apache/hive/beeline/BeeLine.java
+++ b/beeline/src/java/org/apache/hive/beeline/BeeLine.java
@@ -71,7 +71,6 @@
import java.util.ResourceBundle;
import java.util.ServiceLoader;
import java.util.Set;
-import java.util.SortedSet;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;
@@ -310,12 +309,6 @@ public class BeeLine implements Closeable {
private final Completer beeLineCommandCompleter = new
BeeLineCommandCompleter(Arrays.asList(commandHandlers));
- static final SortedSet<String> KNOWN_DRIVERS = new
TreeSet<String>(Arrays.asList(
- new String[] {
- "org.apache.hive.jdbc.HiveDriver",
- "org.apache.hadoop.hive.jdbc.HiveDriver",
- }));
-
static {
try {
Class.forName("org.jline.reader.LineReader");
@@ -2370,23 +2363,17 @@ private Driver findRegisteredDriver(String url) {
return null;
}
- public Driver findLocalDriver(String url) throws Exception {
+ public Driver findLocalDriver(String url) throws SQLException {
Objects.requireNonNull(url);
Collection<Driver> currentDrivers = drivers == null ?
Collections.emptyList() : drivers;
- for (Driver d : currentDrivers) {
- try {
- String clazzName = d.getClass().getName();
- Driver driver = (Driver) Class.forName(clazzName, true,
- Thread.currentThread().getContextClassLoader()).newInstance();
- if (driver.acceptsURL(url) && isSupportedLocalDriver(driver)) {
- return driver;
- }
- } catch (SQLException e) {
- throw e;
+ for (Driver driver : currentDrivers) {
+ // The 'driver' is already an instance from the ServiceLoader.
+ // We can use it directly without creating a new one via reflection.
+ if (driver.acceptsURL(url) && isSupportedLocalDriver(driver)) {
+ return driver;
}
}
-
return null;
}
diff --git a/beeline/src/java/org/apache/hive/beeline/Commands.java
b/beeline/src/java/org/apache/hive/beeline/Commands.java
index 7eaa2618f84..e1364d1848d 100644
--- a/beeline/src/java/org/apache/hive/beeline/Commands.java
+++ b/beeline/src/java/org/apache/hive/beeline/Commands.java
@@ -44,6 +44,7 @@
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
@@ -340,48 +341,48 @@ public boolean reconnect(String line) {
return true;
}
-
public boolean scan(String line) throws IOException {
- TreeSet<String> names = new TreeSet<String>();
-
if (beeLine.getDrivers() == null) {
beeLine.setDrivers(beeLine.scanDrivers());
}
- beeLine.info(beeLine.loc("drivers-found-count",
beeLine.getDrivers().size()));
+ // Use a TreeSet to get a unique, sorted list of drivers by class name.
+ Set<Driver> drivers =
+ new TreeSet<>(Comparator.comparing(d -> d.getClass().getName()));
+ drivers.addAll(beeLine.getDrivers());
- // unique the list
- for (Iterator<Driver> i = beeLine.getDrivers().iterator(); i.hasNext();) {
- names.add(i.next().getClass().getName());
- }
+ // Get count of the unique driver in classpath
+ beeLine.info(beeLine.loc("drivers-found-count", drivers.size()));
- beeLine.output(beeLine.getColorBuffer()
- .bold(beeLine.getColorBuffer().pad(beeLine.loc("compliant"),
10).getMono())
- .bold(beeLine.getColorBuffer().pad(beeLine.loc("jdbc-version"),
8).getMono())
- .bold(beeLine.getColorBuffer(beeLine.loc("driver-class")).getMono()));
+ beeLine.output(
+ beeLine
+ .getColorBuffer()
+ .bold(beeLine.getColorBuffer().pad(beeLine.loc("compliant"),
10).getMono())
+ .bold(beeLine.getColorBuffer().pad(beeLine.loc("jdbc-version"),
8).getMono())
+
.bold(beeLine.getColorBuffer(beeLine.loc("driver-class")).getMono()));
- for (Iterator<String> i = names.iterator(); i.hasNext();) {
- String name = i.next().toString();
+ for (Driver driver : drivers) {
+ String name = driver.getClass().getName();
try {
- Driver driver = (Driver) Class.forName(name).newInstance();
- ColorBuffer msg = beeLine.getColorBuffer()
- .pad(driver.jdbcCompliant() ? "yes" : "no", 10)
- .pad(driver.getMajorVersion() + "."
- + driver.getMinorVersion(), 8)
- .append(name);
+ // Use the driver instance that ServiceLoader already created for us.
+ ColorBuffer msg =
+ beeLine
+ .getColorBuffer()
+ .pad(driver.jdbcCompliant() ? "yes" : "no", 10)
+ .pad(driver.getMajorVersion() + "." +
driver.getMinorVersion(), 8)
+ .append(name);
if (driver.jdbcCompliant()) {
beeLine.output(msg);
} else {
beeLine.output(beeLine.getColorBuffer().red(msg.getMono()));
}
} catch (Throwable t) {
- beeLine.output(beeLine.getColorBuffer().red(name)); // error with
driver
+ beeLine.error("Error processing driver " + name);
}
}
return true;
}
-
public boolean save(String line) throws IOException {
beeLine.info(beeLine.loc("saving-options",
beeLine.getOpts().getPropertiesFile()));
beeLine.getOpts().save();
@@ -1670,7 +1671,7 @@ public boolean connect(Properties props) throws
IOException {
try {
beeLine.getDatabaseConnections().setConnection(
- new DatabaseConnection(beeLine, driver, url, props));
+ new DatabaseConnection(beeLine, url, props));
beeLine.getDatabaseConnection().getConnection();
if (!beeLine.isBeeLine()) {
diff --git a/beeline/src/java/org/apache/hive/beeline/DatabaseConnection.java
b/beeline/src/java/org/apache/hive/beeline/DatabaseConnection.java
index c3c5365631c..baaddee4def 100644
--- a/beeline/src/java/org/apache/hive/beeline/DatabaseConnection.java
+++ b/beeline/src/java/org/apache/hive/beeline/DatabaseConnection.java
@@ -49,7 +49,6 @@ class DatabaseConnection {
private final BeeLine beeLine;
private Connection connection;
private DatabaseMetaData meta;
- private final String driver;
private final String url;
private final Properties info;
private Schema schema = null;
@@ -59,10 +58,8 @@ public boolean isClosed() {
return (null == connection);
}
- public DatabaseConnection(BeeLine beeLine, String driver, String url,
- Properties info) throws SQLException {
+ DatabaseConnection(BeeLine beeLine, String url, Properties info) {
this.beeLine = beeLine;
- this.driver = driver;
this.url = url;
this.info = info;
}
@@ -85,14 +82,6 @@ void setCompletions(boolean skipmeta) throws SQLException,
IOException {
* Connection to the specified data source.
*/
boolean connect() throws SQLException {
- try {
- if (driver != null && driver.length() != 0) {
- Class.forName(driver);
- }
- } catch (ClassNotFoundException cnfe) {
- return beeLine.error(cnfe);
- }
-
boolean isDriverRegistered = false;
try {
isDriverRegistered = DriverManager.getDriver(getUrl()) != null;
@@ -163,18 +152,19 @@ boolean connect() throws SQLException {
public Connection getConnectionFromLocalDriver(String url, Properties
properties) {
Collection<Driver> drivers = beeLine.getDrivers();
- for (Driver d : drivers) {
+ for (Driver driver : drivers) {
try {
- if (d.acceptsURL(url) && beeLine.isSupportedLocalDriver(d)) {
- String clazzName = d.getClass().getName();
- beeLine.debug("Driver name is " + clazzName);
- Driver driver =
- (Driver) Class.forName(clazzName, true,
Thread.currentThread().getContextClassLoader())
- .newInstance();
+ if (driver.acceptsURL(url) && beeLine.isSupportedLocalDriver(driver)) {
+ beeLine.debug("Driver name is " + driver.getClass().getName());
+ // The 'driver' is already an instance from the ServiceLoader, so we
can use it directly.
return driver.connect(url, properties);
}
- } catch (Exception e) {
- beeLine.error("Fail to connect with a local driver due to the
exception:" + e);
+ } catch (SQLException e) {
+ beeLine.error(
+ "Failed to connect with local driver "
+ + driver.getClass().getName()
+ + " due to exception: "
+ + e);
beeLine.error(e);
}
}
diff --git a/beeline/src/test/org/apache/hive/beeline/ProxyAuthTest.java
b/beeline/src/test/org/apache/hive/beeline/ProxyAuthTest.java
index 5732e2061c2..71d9b492d9d 100644
--- a/beeline/src/test/org/apache/hive/beeline/ProxyAuthTest.java
+++ b/beeline/src/test/org/apache/hive/beeline/ProxyAuthTest.java
@@ -44,7 +44,6 @@
* <HS2host> <HS2Port> <HS2-Server-principal> <client-principal>
*/
public class ProxyAuthTest {
- private static final String driverName = "org.apache.hive.jdbc.HiveDriver";
private static final String BEELINE_EXIT = "beeline.system.exit";
private static Connection con = null;
private static boolean noClose = false;
@@ -68,7 +67,6 @@ public static void main(String[] args) throws Exception {
File currentResultFile = null;
String [] beeLineArgs = {};
- Class.forName(driverName);
String host = args[0];
String port = args[1];
String serverPrincipal = args[2];
diff --git a/beeline/src/test/org/apache/hive/beeline/TestShutdownHook.java
b/beeline/src/test/org/apache/hive/beeline/TestShutdownHook.java
index 73e6f3eb571..bdea7f486c7 100644
--- a/beeline/src/test/org/apache/hive/beeline/TestShutdownHook.java
+++ b/beeline/src/test/org/apache/hive/beeline/TestShutdownHook.java
@@ -30,11 +30,11 @@ public void testShutdownHook() throws Exception {
PrintStream ops = new PrintStream(os);
BeeLine beeline = new BeeLine();
DatabaseConnections dbConnections = beeline.getDatabaseConnections();
- dbConnections.setConnection(new DatabaseConnection(beeline,null,null,
null));
- dbConnections.setConnection(new DatabaseConnection(beeline,null,null,
null));
+ dbConnections.setConnection(new DatabaseConnection(beeline, null, null));
+ dbConnections.setConnection(new DatabaseConnection(beeline, null, null));
Assert.assertEquals(2, dbConnections.size());
beeline.setOutputStream(ops);
beeline.getShutdownHook().run();
Assert.assertEquals(0, dbConnections.size());
}
-}
\ No newline at end of file
+}
diff --git
a/hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/tool/TempletonControllerJob.java
b/hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/tool/TempletonControllerJob.java
index 17453216f28..7253e31b034 100644
---
a/hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/tool/TempletonControllerJob.java
+++
b/hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/tool/TempletonControllerJob.java
@@ -218,11 +218,6 @@ private String buildHS2DelegationToken(String user) throws
IOException, Interrup
return real.doAs(new PrivilegedExceptionAction<String>() {
@Override
public String run() throws IOException, TException, InterruptedException
{
- try {
- Class.forName("org.apache.hive.jdbc.HiveDriver");
- } catch (ClassNotFoundException e) {
- throw new IOException(e);
- }
String hs2Url = appConf.get(AppConfig.HIVE_SERVER2_URL);
final HiveConnection con;
try {
diff --git a/hplsql/src/main/java/org/apache/hive/hplsql/Conn.java
b/hplsql/src/main/java/org/apache/hive/hplsql/Conn.java
index be21fbd5fc0..87482cbb89f 100644
--- a/hplsql/src/main/java/org/apache/hive/hplsql/Conn.java
+++ b/hplsql/src/main/java/org/apache/hive/hplsql/Conn.java
@@ -146,15 +146,11 @@ synchronized Connection getConnection(String connName)
throws Exception {
* @throws Exception
*/
Connection openConnection(String connStr) throws Exception {
- String driver = "org.apache.hadoop.hive.jdbc.HiveDriver";
StringBuilder url = new StringBuilder();
String usr = "";
String pwd = "";
if (connStr != null) {
String[] c = connStr.split(";");
- if (c.length >= 1) {
- driver = c[0];
- }
if (c.length >= 2) {
url.append(c[1]);
}
@@ -174,7 +170,6 @@ else if (pwd.isEmpty()) {
}
}
}
- Class.forName(driver);
timer.start();
Connection conn = DriverManager.getConnection(url.toString().trim(), usr,
pwd);
timer.stop();
diff --git
a/itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/JdbcWithMiniKdcSQLAuthTest.java
b/itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/JdbcWithMiniKdcSQLAuthTest.java
index cd4c1c3c75c..cdf79423e6c 100644
---
a/itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/JdbcWithMiniKdcSQLAuthTest.java
+++
b/itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/JdbcWithMiniKdcSQLAuthTest.java
@@ -51,7 +51,6 @@ public static void beforeTestBase(String transportMode)
throws Exception {
hiveConf.setVar(ConfVars.HIVE_SERVER2_TRANSPORT_MODE, transportMode);
System.err.println("Testing using HS2 mode:" + transportMode);
- Class.forName(MiniHS2.getJdbcDriverName());
hiveConf.setVar(ConfVars.HIVE_AUTHORIZATION_MANAGER,
SQLStdHiveAuthorizerFactory.class.getName());
hiveConf.setVar(ConfVars.HIVE_AUTHENTICATOR_MANAGER,
diff --git
a/itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestHS2AuthMechsWithMiniKdc.java
b/itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestHS2AuthMechsWithMiniKdc.java
index 36eb4820715..d5e159cb822 100644
---
a/itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestHS2AuthMechsWithMiniKdc.java
+++
b/itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestHS2AuthMechsWithMiniKdc.java
@@ -87,7 +87,6 @@ public class TestHS2AuthMechsWithMiniKdc extends
AbstractLdapTestUnit {
@Before
public void setUpBefore() throws Exception {
if (miniHS2 == null) {
- Class.forName(MiniHS2.getJdbcDriverName());
miniHiveKdc = new MiniHiveKdc();
HiveConf hiveConf = new HiveConf();
hiveConf.setBoolVar(HiveConf.ConfVars.HIVE_SERVER2_ENABLE_DOAS, false);
diff --git
a/itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestHS2JWTWithMiniKdc.java
b/itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestHS2JWTWithMiniKdc.java
index 82a8f46350a..3d96ec7f21c 100644
---
a/itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestHS2JWTWithMiniKdc.java
+++
b/itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestHS2JWTWithMiniKdc.java
@@ -73,7 +73,6 @@ public class TestHS2JWTWithMiniKdc {
@BeforeClass
public static void setUpBeforeClass() throws Exception {
- Class.forName(MiniHS2.getJdbcDriverName());
MOCK_JWKS_SERVER.stubFor(get("/jwks")
.willReturn(ok()
.withBody(Files.readAllBytes(jwtVerificationJWKSFile.toPath()))));
diff --git
a/itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestHs2HooksWithMiniKdc.java
b/itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestHs2HooksWithMiniKdc.java
index 9adc38fdf56..f094590e018 100644
---
a/itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestHs2HooksWithMiniKdc.java
+++
b/itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestHs2HooksWithMiniKdc.java
@@ -50,7 +50,6 @@ public class TestHs2HooksWithMiniKdc {
@BeforeClass
public static void setUpBeforeClass() throws Exception {
- Class.forName(MiniHS2.getJdbcDriverName());
confOverlay.put(ConfVars.POST_EXEC_HOOKS.varname,
PostExecHook.class.getName());
confOverlay.put(ConfVars.PRE_EXEC_HOOKS.varname,
PreExecHook.class.getName());
confOverlay.put(ConfVars.SEMANTIC_ANALYZER_HOOK.varname,
diff --git
a/itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestJdbcNonKrbSASLWithMiniKdc.java
b/itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestJdbcNonKrbSASLWithMiniKdc.java
index 3e643369f5c..f0c0a893d83 100644
---
a/itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestJdbcNonKrbSASLWithMiniKdc.java
+++
b/itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestJdbcNonKrbSASLWithMiniKdc.java
@@ -30,7 +30,6 @@
import org.apache.hadoop.hive.conf.HiveConf;
import org.apache.hadoop.hive.conf.HiveConf.ConfVars;
import org.apache.hive.jdbc.HiveConnection;
-import org.apache.hive.jdbc.miniHS2.MiniHS2;
import org.apache.hive.service.auth.PasswdAuthenticationProvider;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -52,7 +51,6 @@ public void authenticate(String user, String password) throws
AuthenticationExce
@BeforeClass
public static void beforeTest() throws Exception {
- Class.forName(MiniHS2.getJdbcDriverName());
confOverlay.put(ConfVars.HIVE_SERVER2_SESSION_HOOK.varname,
SessionHookTest.class.getName());
confOverlay.put(ConfVars.HIVE_SERVER2_CUSTOM_AUTHENTICATION_CLASS.varname,
diff --git
a/itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestJdbcWithDBTokenStore.java
b/itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestJdbcWithDBTokenStore.java
index b770fa91757..4b1d988c29f 100644
---
a/itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestJdbcWithDBTokenStore.java
+++
b/itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestJdbcWithDBTokenStore.java
@@ -21,7 +21,6 @@
import org.apache.hadoop.hive.conf.HiveConf;
import org.apache.hadoop.hive.conf.HiveConf.ConfVars;
import org.apache.hadoop.hive.metastore.conf.MetastoreConf;
-import org.apache.hive.jdbc.miniHS2.MiniHS2;
import org.junit.BeforeClass;
/**
@@ -33,7 +32,6 @@ public class TestJdbcWithDBTokenStore extends
TestJdbcWithMiniKdc{
@BeforeClass
public static void beforeTest() throws Exception {
- Class.forName(MiniHS2.getJdbcDriverName());
confOverlay.put(ConfVars.HIVE_SERVER2_SESSION_HOOK.varname,
SessionHookTest.class.getName());
confOverlay.put(ConfVars.HIVE_SCHEDULED_QUERIES_EXECUTOR_ENABLED.varname,
"false");
diff --git
a/itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestJdbcWithDBTokenStoreNoDoAs.java
b/itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestJdbcWithDBTokenStoreNoDoAs.java
index b70e746a0f9..ef444e2d299 100644
---
a/itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestJdbcWithDBTokenStoreNoDoAs.java
+++
b/itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestJdbcWithDBTokenStoreNoDoAs.java
@@ -21,7 +21,6 @@
import org.apache.hadoop.hive.conf.HiveConf;
import org.apache.hadoop.hive.conf.HiveConf.ConfVars;
import org.apache.hadoop.hive.metastore.conf.MetastoreConf;
-import org.apache.hive.jdbc.miniHS2.MiniHS2;
import org.junit.BeforeClass;
/**
@@ -33,7 +32,6 @@ public class TestJdbcWithDBTokenStoreNoDoAs extends
TestJdbcWithMiniKdc{
@BeforeClass
public static void beforeTest() throws Exception {
- Class.forName(MiniHS2.getJdbcDriverName());
confOverlay.put(ConfVars.HIVE_SERVER2_SESSION_HOOK.varname,
SessionHookTest.class.getName());
confOverlay.put(ConfVars.HIVE_SCHEDULED_QUERIES_EXECUTOR_ENABLED.varname,
"false");
diff --git
a/itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestJdbcWithMiniKdc.java
b/itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestJdbcWithMiniKdc.java
index 78d819761fe..40b3e0eec9d 100644
---
a/itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestJdbcWithMiniKdc.java
+++
b/itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestJdbcWithMiniKdc.java
@@ -66,7 +66,6 @@ public void run(HiveSessionHookContext sessionHookContext)
throws HiveSQLExcepti
@BeforeClass
public static void beforeTest() throws Exception {
- Class.forName(MiniHS2.getJdbcDriverName());
confOverlay.put(ConfVars.HIVE_SERVER2_SESSION_HOOK.varname,
SessionHookTest.class.getName());
confOverlay.put(ConfVars.HIVE_SCHEDULED_QUERIES_EXECUTOR_ENABLED.varname,
"false");
diff --git
a/itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestJdbcWithMiniKdcCookie.java
b/itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestJdbcWithMiniKdcCookie.java
index c9e324d3753..55add652ece 100644
---
a/itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestJdbcWithMiniKdcCookie.java
+++
b/itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestJdbcWithMiniKdcCookie.java
@@ -37,7 +37,6 @@
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
-import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@@ -62,11 +61,6 @@ public static Collection<Object[]> transportModes() {
return Arrays.asList(new Object[][]{{MiniHS2.HS2_ALL_MODE},
{MiniHS2.HS2_HTTP_MODE}});
}
- @BeforeClass
- public static void beforeTest() throws Exception {
- Class.forName(MiniHS2.getJdbcDriverName());
- }
-
@Before
public void setUp() throws Exception {
miniHiveKdc = new MiniHiveKdc();
diff --git
a/itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestSSLWithMiniKdc.java
b/itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestSSLWithMiniKdc.java
index faaf8776169..669bb019f16 100644
---
a/itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestSSLWithMiniKdc.java
+++
b/itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestSSLWithMiniKdc.java
@@ -51,8 +51,6 @@ public class TestSSLWithMiniKdc {
@BeforeClass
public static void beforeTest() throws Exception {
- Class.forName(MiniHS2.getJdbcDriverName());
-
miniHiveKdc = new MiniHiveKdc();
HiveConf hiveConf = new HiveConf();
diff --git
a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/TestAutoPurgeTables.java
b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/TestAutoPurgeTables.java
index 09f9d68a91d..b8dac35fa2d 100644
---
a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/TestAutoPurgeTables.java
+++
b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/TestAutoPurgeTables.java
@@ -46,7 +46,6 @@
public class TestAutoPurgeTables {
- private static final String driverName = "org.apache.hive.jdbc.HiveDriver";
private static final String testDbName = "auto_purge_test_db";
//private static final String testTableName = "auto_purge_test_table";
private static final String INSERT_OVERWRITE_COMMAND_FORMAT =
@@ -118,7 +117,6 @@ public static void setUpBeforeClass() throws Exception {
// Create test database and base tables once for all the test
miniHS2 = new MiniHS2.Builder().withConf(conf).build();
miniHS2.start(new HashMap<String, String>());
- Class.forName(driverName);
con = getConnection(miniHS2.getBaseJdbcURL() + ";create=true");
try (Statement stmt = con.createStatement()) {
Assert.assertNotNull("Statement is null", stmt);
diff --git
a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/TestMetaStoreLimitPartitionRequest.java
b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/TestMetaStoreLimitPartitionRequest.java
index 9e9de7e93f8..faaf6b37782 100644
---
a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/TestMetaStoreLimitPartitionRequest.java
+++
b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/TestMetaStoreLimitPartitionRequest.java
@@ -64,7 +64,6 @@ public class TestMetaStoreLimitPartitionRequest {
@BeforeClass
public static void beforeTest() throws Exception {
- Class.forName(MiniHS2.getJdbcDriverName());
conf = new HiveConfForTest(TestMetaStoreLimitPartitionRequest.class);
DriverManager.setLoginTimeout(0);
diff --git
a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/processor/TestShowProcessList.java
b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/processor/TestShowProcessList.java
index 7c57db9b249..9c841d8b1e1 100644
---
a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/processor/TestShowProcessList.java
+++
b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/processor/TestShowProcessList.java
@@ -78,7 +78,6 @@ public static void beforeTest() throws Exception {
TestTxnDbUtil.setConfValues(conf);
TestTxnDbUtil.prepDb(conf);
MiniHS2.cleanupLocalDir();
- Class.forName(MiniHS2.getJdbcDriverName());
miniHS2 = new MiniHS2(conf, MiniHS2.MiniClusterType.LLAP);
Map<String, String> confOverlay = new HashMap<>();
miniHS2.start(confOverlay);
diff --git
a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/reexec/TestReExecuteKilledTezAMQueryPlugin.java
b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/reexec/TestReExecuteKilledTezAMQueryPlugin.java
index 6083fd01a5c..65982ec0461 100644
---
a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/reexec/TestReExecuteKilledTezAMQueryPlugin.java
+++
b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/reexec/TestReExecuteKilledTezAMQueryPlugin.java
@@ -74,7 +74,6 @@ public static void beforeTest() throws Exception {
conf.setVar(HiveConf.ConfVars.USERS_IN_ADMIN_ROLE,
System.getProperty("user.name"));
conf.set(HiveConf.ConfVars.HIVE_QUERY_REEXECUTION_STRATEGIES.varname,
"recompile_without_cbo,reexecute_lost_am");
MiniHS2.cleanupLocalDir();
- Class.forName(MiniHS2.getJdbcDriverName());
miniHS2 = new MiniHS2(conf, MiniHS2.MiniClusterType.LLAP);
dataFileDir = conf.get("test.data.files").replace('\\', '/').replace("c:",
"");
Map<String, String> confOverlay = new HashMap<String, String>();
diff --git
a/itests/hive-unit/src/test/java/org/apache/hive/beeline/TestBeeLineWithArgs.java
b/itests/hive-unit/src/test/java/org/apache/hive/beeline/TestBeeLineWithArgs.java
index 92f2d8c5657..ffb9ab1224a 100644
---
a/itests/hive-unit/src/test/java/org/apache/hive/beeline/TestBeeLineWithArgs.java
+++
b/itests/hive-unit/src/test/java/org/apache/hive/beeline/TestBeeLineWithArgs.java
@@ -107,11 +107,9 @@ public static void preTests() throws Exception {
/**
* Create table for use by tests
- * @throws ClassNotFoundException
* @throws SQLException
*/
- private static void createTable() throws ClassNotFoundException,
SQLException {
- Class.forName(BeeLine.BEELINE_DEFAULT_JDBC_DRIVER);
+ private static void createTable() throws SQLException {
Connection con = DriverManager.getConnection(miniHS2.getBaseJdbcURL(),
userName , "");
diff --git
a/itests/hive-unit/src/test/java/org/apache/hive/beeline/TestBeelinePasswordOption.java
b/itests/hive-unit/src/test/java/org/apache/hive/beeline/TestBeelinePasswordOption.java
index 0631c641177..d2279d869be 100644
---
a/itests/hive-unit/src/test/java/org/apache/hive/beeline/TestBeelinePasswordOption.java
+++
b/itests/hive-unit/src/test/java/org/apache/hive/beeline/TestBeelinePasswordOption.java
@@ -292,11 +292,9 @@ private String connectBeelineWithUserPrompt(List<String>
argList, String prompt)
/**
* Create table for use by tests
*
- * @throws ClassNotFoundException
* @throws SQLException
*/
- private static void createTable() throws ClassNotFoundException,
SQLException {
- Class.forName(BeeLine.BEELINE_DEFAULT_JDBC_DRIVER);
+ private static void createTable() throws SQLException {
Connection con = DriverManager.getConnection(miniHS2.getBaseJdbcURL(), "",
"");
assertNotNull("Connection is null", con);
diff --git
a/itests/hive-unit/src/test/java/org/apache/hive/beeline/hs2connection/BeelineWithHS2ConnectionFileTestBase.java
b/itests/hive-unit/src/test/java/org/apache/hive/beeline/hs2connection/BeelineWithHS2ConnectionFileTestBase.java
index bc20d733f95..0b5a509ab92 100644
---
a/itests/hive-unit/src/test/java/org/apache/hive/beeline/hs2connection/BeelineWithHS2ConnectionFileTestBase.java
+++
b/itests/hive-unit/src/test/java/org/apache/hive/beeline/hs2connection/BeelineWithHS2ConnectionFileTestBase.java
@@ -154,7 +154,6 @@ protected void close() throws IOException {
@BeforeClass
public static void beforeTest() throws Exception {
MiniHS2.cleanupLocalDir();
- Class.forName(MiniHS2.getJdbcDriverName());
}
@AfterClass
diff --git
a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/AbstractJdbcTriggersTest.java
b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/AbstractJdbcTriggersTest.java
index 40802951f46..929bd94f03d 100644
---
a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/AbstractJdbcTriggersTest.java
+++
b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/AbstractJdbcTriggersTest.java
@@ -63,8 +63,6 @@ public abstract class AbstractJdbcTriggersTest {
@BeforeClass
public static void beforeTest() throws Exception {
- Class.forName(MiniHS2.getJdbcDriverName());
-
String confDir = "../../data/conf/llap/";
HiveConf.setHiveSiteLocation(new URL("file://" + new
File(confDir).toURI().getPath() + "/hive-site.xml"));
System.out.println("Setting hive-site: " + HiveConf.getHiveSiteLocation());
diff --git
a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/AbstractTestJdbcGenericUDTFGetSplits.java
b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/AbstractTestJdbcGenericUDTFGetSplits.java
index bb73b8bbca6..519f975fb7e 100644
---
a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/AbstractTestJdbcGenericUDTFGetSplits.java
+++
b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/AbstractTestJdbcGenericUDTFGetSplits.java
@@ -58,8 +58,6 @@ public abstract class AbstractTestJdbcGenericUDTFGetSplits {
@BeforeClass
public static void beforeTest() throws Exception {
- Class.forName(MiniHS2.getJdbcDriverName());
-
String confDir = "../../data/conf/llap/";
HiveConf.setHiveSiteLocation(new URL("file://" + new
File(confDir).toURI().getPath() + "/hive-site.xml"));
System.out.println("Setting hive-site: " + HiveConf.getHiveSiteLocation());
diff --git
a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/BaseJdbcWithMiniLlap.java
b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/BaseJdbcWithMiniLlap.java
index 12b1e6b1431..b9002c5113f 100644
---
a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/BaseJdbcWithMiniLlap.java
+++
b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/BaseJdbcWithMiniLlap.java
@@ -83,7 +83,6 @@ public abstract class BaseJdbcWithMiniLlap {
// This method should be called by sub-classes in a @BeforeClass initializer
public static MiniHS2 beforeTest(HiveConf inputConf) throws Exception {
conf = inputConf;
- Class.forName(MiniHS2.getJdbcDriverName());
miniHS2 = new MiniHS2(conf, MiniClusterType.LLAP);
dataFileDir = conf.get("test.data.files").replace('\\', '/').replace("c:",
"");
kvDataFilePath = new Path(dataFileDir, "kv1.txt");
diff --git
a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestActivePassiveHA.java
b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestActivePassiveHA.java
index 6879c76be3b..f1c59ba0cbd 100644
---
a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestActivePassiveHA.java
+++
b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestActivePassiveHA.java
@@ -88,7 +88,6 @@ public class TestActivePassiveHA {
public static void beforeTest() throws Exception {
MiniHS2.cleanupLocalDir();
zkServer = new TestingServer();
- Class.forName(MiniHS2.getJdbcDriverName());
}
@AfterClass
diff --git
a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestCSRFFilter.java
b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestCSRFFilter.java
index eff2803eb01..25e77d24903 100644
--- a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestCSRFFilter.java
+++ b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestCSRFFilter.java
@@ -74,7 +74,6 @@ public static void afterClass() throws IOException {
// This is not modeled as a @Before, because it needs to be parameterized
per-test.
// If there is a better way to do this, we should do it.
private void initHS2(boolean enableCSRFFilter) throws Exception {
- Class.forName(MiniHS2.getJdbcDriverName());
HiveConf conf = new HiveConf();
conf.setBoolVar(ConfVars.HIVE_SUPPORT_CONCURRENCY, false);
miniHS2 = new
MiniHS2.Builder().withConf(conf).cleanupLocalDirOnStartup(false).build();
diff --git
a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java
b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java
index a752c673183..6947b0b4b88 100644
--- a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java
+++ b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java
@@ -104,7 +104,6 @@
public class TestJdbcDriver2 {
private static final Logger LOG =
LoggerFactory.getLogger(TestJdbcDriver2.class);
- private static final String driverName = "org.apache.hive.jdbc.HiveDriver";
private static final String testDbName = "testjdbcdriver";
private static final String defaultDbName = "default";
private static final String tableName = "testjdbcdrivertbl";
@@ -208,7 +207,6 @@ public static void setUpBeforeClass() throws Exception {
dataFileRowCount = 500;
dataTypeDataFilePath = new Path(dataFileDir, "datatypes.txt");
// Create test database and base tables once for all the test
- Class.forName(driverName);
System.setProperty(ConfVars.HIVE_SERVER2_LOGGING_OPERATION_LEVEL.varname,
"verbose");
System.setProperty(ConfVars.HIVE_MAPRED_MODE.varname, "nonstrict");
System.setProperty(ConfVars.HIVE_AUTHORIZATION_MANAGER.varname,
diff --git
a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcWithMiniHA.java
b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcWithMiniHA.java
index aafa101a354..b304d2a579a 100644
---
a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcWithMiniHA.java
+++
b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcWithMiniHA.java
@@ -67,7 +67,6 @@ public void run(HiveSessionHookContext sessionHookContext)
throws HiveSQLExcepti
@BeforeClass
public static void beforeTest() throws Exception {
- Class.forName(MiniHS2.getJdbcDriverName());
conf = new HiveConfForTest(TestJdbcWithMiniHA.class);
conf.setBoolVar(ConfVars.HIVE_SUPPORT_CONCURRENCY, false);
String dataFileDir = conf.get("test.data.files").replace('\\', '/')
diff --git
a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcWithMiniHS2ErasureCoding.java
b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcWithMiniHS2ErasureCoding.java
index 3d5ddaa08c1..7423d017fb3 100644
---
a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcWithMiniHS2ErasureCoding.java
+++
b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcWithMiniHS2ErasureCoding.java
@@ -67,7 +67,6 @@ public class TestJdbcWithMiniHS2ErasureCoding {
*/
@BeforeClass
public static void beforeTest() throws Exception {
- Class.forName(MiniHS2.getJdbcDriverName());
conf = new HiveConfForTest(TestJdbcWithMiniHS2ErasureCoding.class);
//TODO: HIVE-28284: TestJdbcWithMiniHS2/TestJdbcWithMiniHS2ErasureCoding
to run on Tez
conf.setVar(HiveConf.ConfVars.HIVE_EXECUTION_ENGINE, "mr");
diff --git
a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcWithServiceDiscovery.java
b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcWithServiceDiscovery.java
index 9f2fb323589..0f010709a40 100644
---
a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcWithServiceDiscovery.java
+++
b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcWithServiceDiscovery.java
@@ -80,7 +80,6 @@ public static void setup() throws Exception {
miniHS2server1 = new
MiniHS2.Builder().withConf(hiveConf1).withMiniMR().build();
miniHS2server2 = new
MiniHS2.Builder().withConf(hiveConf2).cleanupLocalDirOnStartup(false).build();
- Class.forName(MiniHS2.getJdbcDriverName());
String instanceId1 = UUID.randomUUID().toString();
miniHS2server1.start(getConfOverlay(instanceId1));
miniHS2directUrl1 =
diff --git
a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestKillQueryWithAuthorizationDisabled.java
b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestKillQueryWithAuthorizationDisabled.java
index a08695678bc..b2f94b00c81 100644
---
a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestKillQueryWithAuthorizationDisabled.java
+++
b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestKillQueryWithAuthorizationDisabled.java
@@ -108,7 +108,6 @@ static HiveConf defaultConf() throws Exception {
// Disable Hive Authorization
conf.setBoolVar(HiveConf.ConfVars.HIVE_AUTHORIZATION_ENABLED, false);
MiniHS2.cleanupLocalDir();
- Class.forName(MiniHS2.getJdbcDriverName());
miniHS2 = new MiniHS2(conf, MiniHS2.MiniClusterType.LLAP);
Map<String, String> confOverlay = new HashMap<String, String>();
miniHS2.start(confOverlay);
diff --git
a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestNoSaslAuth.java
b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestNoSaslAuth.java
index 4ec86c0c133..ed4890b6bb0 100644
--- a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestNoSaslAuth.java
+++ b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestNoSaslAuth.java
@@ -57,7 +57,6 @@ public void run(HiveSessionHookContext sessionHookContext)
@BeforeClass
public static void beforeTest() throws Exception {
- Class.forName(MiniHS2.getJdbcDriverName());
HiveConf conf = new HiveConf();
conf.setBoolVar(HiveConf.ConfVars.HIVE_SUPPORT_CONCURRENCY, false);
conf.setBoolVar(ConfVars.HIVE_SERVER2_ENABLE_DOAS, false);
diff --git
a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestRestrictedList.java
b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestRestrictedList.java
index ce068340395..7443ae64ae4 100644
---
a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestRestrictedList.java
+++
b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestRestrictedList.java
@@ -46,8 +46,6 @@ public class TestRestrictedList {
@BeforeClass
public static void startServices() throws Exception {
- Class.forName(MiniHS2.getJdbcDriverName());
-
oldHiveSiteURL = HiveConf.getHiveSiteLocation();
oldHiveMetastoreSiteURL = HiveConf.getMetastoreSiteLocation();
String confDir = "../../data/conf/rlist/";
diff --git a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestSSL.java
b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestSSL.java
index ec6c65f75a2..bc37fbef866 100644
--- a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestSSL.java
+++ b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestSSL.java
@@ -75,7 +75,6 @@ public class TestSSL {
@BeforeClass
public static void beforeTest() throws Exception {
MiniHS2.cleanupLocalDir();
- Class.forName(MiniHS2.getJdbcDriverName());
}
@AfterClass
diff --git
a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestServiceDiscoveryWithMiniHS2.java
b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestServiceDiscoveryWithMiniHS2.java
index 8512ff4ad6c..304f1bbe949 100644
---
a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestServiceDiscoveryWithMiniHS2.java
+++
b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestServiceDiscoveryWithMiniHS2.java
@@ -54,7 +54,6 @@ public class TestServiceDiscoveryWithMiniHS2 {
public static void beforeTest() throws Exception {
MiniHS2.cleanupLocalDir();
zkServer = new TestingServer();
- Class.forName(MiniHS2.getJdbcDriverName());
hiveConf = new HiveConf();
hiveConf.setBoolVar(ConfVars.HIVE_SUPPORT_CONCURRENCY, false);
// Set up zookeeper dynamic service discovery configs
diff --git
a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestTriggersMoveWorkloadManager.java
b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestTriggersMoveWorkloadManager.java
index a50931c2bc2..506d1b40150 100644
---
a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestTriggersMoveWorkloadManager.java
+++
b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestTriggersMoveWorkloadManager.java
@@ -64,8 +64,6 @@ public String getTestName() {
@BeforeClass
public static void beforeTest() throws Exception {
- Class.forName(MiniHS2.getJdbcDriverName());
-
String confDir = "../../data/conf/llap/";
HiveConf.setHiveSiteLocation(new URL("file://" + new
File(confDir).toURI().getPath() + "/hive-site.xml"));
System.out.println("Setting hive-site: " + HiveConf.getHiveSiteLocation());
diff --git
a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestTriggersWorkloadManager.java
b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestTriggersWorkloadManager.java
index 9ae60634c60..405f4c1b857 100644
---
a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestTriggersWorkloadManager.java
+++
b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestTriggersWorkloadManager.java
@@ -54,8 +54,6 @@ public String getTestName() {
@BeforeClass
public static void beforeTest() throws Exception {
- Class.forName(MiniHS2.getJdbcDriverName());
-
String confDir = "../../data/conf/llap/";
HiveConf.setHiveSiteLocation(new URL("file://" + new
File(confDir).toURI().getPath() + "/hive-site.xml"));
conf = new HiveConf();
diff --git
a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestWMMetricsWithTrigger.java
b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestWMMetricsWithTrigger.java
index d056ab3341c..ca0ae94ef24 100644
---
a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestWMMetricsWithTrigger.java
+++
b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestWMMetricsWithTrigger.java
@@ -102,7 +102,6 @@ static HiveConf defaultConf() throws Exception {
public static void beforeTest() throws Exception {
HiveConf conf = defaultConf();
- Class.forName(MiniHS2.getJdbcDriverName());
miniHS2 = new MiniHS2(conf, MiniHS2.MiniClusterType.LLAP);
Map<String, String> confOverlay = new HashMap<>();
miniHS2.start(confOverlay);
diff --git
a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestXSRFFilter.java
b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestXSRFFilter.java
index b5a3568ab2c..9452cb9e2be 100644
--- a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestXSRFFilter.java
+++ b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestXSRFFilter.java
@@ -82,7 +82,6 @@ public static void afterClass() throws IOException {
// This is not modeled as a @Before, because it needs to be parameterized
per-test.
// If there is a better way to do this, we should do it.
private void initHS2(boolean enableXSRFFilter) throws Exception {
- Class.forName(MiniHS2.getJdbcDriverName());
HiveConf conf = new HiveConf();
conf.setBoolVar(ConfVars.HIVE_SUPPORT_CONCURRENCY, false);
miniHS2 = new
MiniHS2.Builder().withConf(conf).cleanupLocalDirOnStartup(false).build();
diff --git
a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/authorization/TestHS2AuthzContext.java
b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/authorization/TestHS2AuthzContext.java
index 977fe433205..036241752af 100644
---
a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/authorization/TestHS2AuthzContext.java
+++
b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/authorization/TestHS2AuthzContext.java
@@ -69,7 +69,6 @@ public HiveAuthorizer
createHiveAuthorizer(HiveMetastoreClientFactory metastoreC
@BeforeClass
public static void beforeTest() throws Exception {
- Class.forName(MiniHS2.getJdbcDriverName());
HiveConf conf = new HiveConf();
conf.setVar(ConfVars.HIVE_AUTHORIZATION_MANAGER,
MockedHiveAuthorizerFactory.class.getName());
conf.setVar(ConfVars.HIVE_AUTHENTICATOR_MANAGER,
SessionStateUserAuthenticator.class.getName());
diff --git
a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/authorization/TestHS2AuthzSessionContext.java
b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/authorization/TestHS2AuthzSessionContext.java
index 60d939e83ba..def11cb98f7 100644
---
a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/authorization/TestHS2AuthzSessionContext.java
+++
b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/authorization/TestHS2AuthzSessionContext.java
@@ -59,7 +59,6 @@ public HiveAuthorizer
createHiveAuthorizer(HiveMetastoreClientFactory metastoreC
@BeforeClass
public static void beforeTest() throws Exception {
- Class.forName(MiniHS2.getJdbcDriverName());
HiveConf conf = new HiveConf();
conf.setVar(ConfVars.HIVE_AUTHORIZATION_MANAGER,
MockedHiveAuthorizerFactory.class.getName());
conf.setVar(ConfVars.HIVE_AUTHENTICATOR_MANAGER,
SessionStateUserAuthenticator.class.getName());
diff --git
a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/authorization/TestJdbcMetadataApiAuth.java
b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/authorization/TestJdbcMetadataApiAuth.java
index aae43c9ea5a..fd781708869 100644
---
a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/authorization/TestJdbcMetadataApiAuth.java
+++
b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/authorization/TestJdbcMetadataApiAuth.java
@@ -101,7 +101,6 @@ public HiveAuthorizer
createHiveAuthorizer(HiveMetastoreClientFactory metastoreC
@BeforeClass
public static void beforeTest() throws Exception {
- Class.forName(MiniHS2.getJdbcDriverName());
HiveConf conf = new HiveConf();
conf.setVar(ConfVars.HIVE_AUTHORIZATION_MANAGER,
TestAuthorizerFactory.class.getName());
conf.setVar(ConfVars.HIVE_AUTHENTICATOR_MANAGER,
SessionStateUserAuthenticator.class.getName());
diff --git
a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/authorization/TestJdbcWithSQLAuthUDFBlacklist.java
b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/authorization/TestJdbcWithSQLAuthUDFBlacklist.java
index 99df3efc453..71736ce7506 100644
---
a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/authorization/TestJdbcWithSQLAuthUDFBlacklist.java
+++
b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/authorization/TestJdbcWithSQLAuthUDFBlacklist.java
@@ -44,8 +44,6 @@ public class TestJdbcWithSQLAuthUDFBlacklist {
private MiniHS2 miniHS2 = null;
public void startHS2(HiveConf conf) throws Exception {
- Class.forName(MiniHS2.getJdbcDriverName());
-
conf.setVar(ConfVars.HIVE_AUTHORIZATION_MANAGER,
SQLStdHiveAuthorizerFactory.class.getName());
conf.setVar(ConfVars.HIVE_AUTHENTICATOR_MANAGER,
SessionStateUserAuthenticator.class.getName());
conf.setBoolVar(ConfVars.HIVE_AUTHORIZATION_ENABLED, true);
diff --git
a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/authorization/TestJdbcWithSQLAuthorization.java
b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/authorization/TestJdbcWithSQLAuthorization.java
index 206eae5a54d..52703b4691d 100644
---
a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/authorization/TestJdbcWithSQLAuthorization.java
+++
b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/authorization/TestJdbcWithSQLAuthorization.java
@@ -18,7 +18,6 @@
package org.apache.hive.jdbc.authorization;
-import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -45,7 +44,6 @@ public class TestJdbcWithSQLAuthorization {
@BeforeClass
public static void beforeTest() throws Exception {
- Class.forName(MiniHS2.getJdbcDriverName());
HiveConf conf = new HiveConf();
conf.setVar(ConfVars.HIVE_AUTHORIZATION_MANAGER,
SQLStdHiveAuthorizerFactory.class.getName());
conf.setVar(ConfVars.HIVE_AUTHENTICATOR_MANAGER,
SessionStateUserAuthenticator.class.getName());
diff --git
a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/cbo_rp_TestJdbcDriver2.java
b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/cbo_rp_TestJdbcDriver2.java
index 1942dc194f1..2cfeabeb1b7 100644
---
a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/cbo_rp_TestJdbcDriver2.java
+++
b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/cbo_rp_TestJdbcDriver2.java
@@ -77,7 +77,6 @@
*/
public class cbo_rp_TestJdbcDriver2 {
private static final Logger LOG =
LoggerFactory.getLogger(cbo_rp_TestJdbcDriver2.class);
- private static final String driverName = "org.apache.hive.jdbc.HiveDriver";
private static final String tableName = "testHiveJdbcDriver_Table";
private static final String tableComment = "Simple table";
private static final String viewName = "testHiveJdbcDriverView";
@@ -107,8 +106,7 @@ public cbo_rp_TestJdbcDriver2() {
}
@BeforeClass
- public static void setUpBeforeClass() throws SQLException,
ClassNotFoundException{
- Class.forName(driverName);
+ public static void setUpBeforeClass() throws SQLException {
Connection con1 = getConnection("default");
System.setProperty(ConfVars.HIVE_SERVER2_LOGGING_OPERATION_LEVEL.varname,
"verbose");
diff --git
a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/miniHS2/TestMiniHS2.java
b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/miniHS2/TestMiniHS2.java
index abc6977fea9..f1c661befd1 100644
---
a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/miniHS2/TestMiniHS2.java
+++
b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/miniHS2/TestMiniHS2.java
@@ -31,18 +31,12 @@
import org.apache.hadoop.hive.conf.HiveConf;
import org.apache.hadoop.hive.conf.HiveConf.ConfVars;
import org.junit.After;
-import org.junit.BeforeClass;
import org.junit.Test;
public class TestMiniHS2 {
private MiniHS2 miniHS2;
- @BeforeClass
- public static void beforeTest() throws Exception {
- Class.forName(MiniHS2.getJdbcDriverName());
- }
-
@After
public void tearDown() throws Exception {
miniHS2.stop();
diff --git
a/itests/hive-unit/src/test/java/org/apache/hive/service/TestDFSErrorHandling.java
b/itests/hive-unit/src/test/java/org/apache/hive/service/TestDFSErrorHandling.java
index 6321e049f5c..dc3a2d83832 100644
---
a/itests/hive-unit/src/test/java/org/apache/hive/service/TestDFSErrorHandling.java
+++
b/itests/hive-unit/src/test/java/org/apache/hive/service/TestDFSErrorHandling.java
@@ -95,7 +95,6 @@ public void testAccessDenied() throws Exception {
assertTrue("Test setup failed. MiniHS2 is not initialized",
miniHS2 != null && miniHS2.isStarted());
- Class.forName(MiniHS2.getJdbcDriverName());
Path scratchDir = new Path(HiveConf.getVar(hiveConf,
HiveConf.ConfVars.SCRATCH_DIR));
MiniDFSShim dfs = miniHS2.getDfs();
diff --git
a/itests/hive-unit/src/test/java/org/apache/hive/service/TestHS2ImpersonationWithRemoteMS.java
b/itests/hive-unit/src/test/java/org/apache/hive/service/TestHS2ImpersonationWithRemoteMS.java
index 58bd57eedf9..bfc6697aa85 100644
---
a/itests/hive-unit/src/test/java/org/apache/hive/service/TestHS2ImpersonationWithRemoteMS.java
+++
b/itests/hive-unit/src/test/java/org/apache/hive/service/TestHS2ImpersonationWithRemoteMS.java
@@ -74,8 +74,6 @@ public void testImpersonation() throws Exception {
assertTrue("Test setup failed. MiniHS2 is not initialized",
miniHS2 != null && miniHS2.isStarted());
- Class.forName(MiniHS2.getJdbcDriverName());
-
// Create two tables one as user "foo" and other as user "bar"
Connection hs2Conn =
DriverManager.getConnection(miniHS2.getJdbcURL()+";retries=3", "foo", null);
Statement stmt = hs2Conn.createStatement();
diff --git
a/itests/hive-unit/src/test/java/org/apache/hive/service/auth/TestCustomAuthentication.java
b/itests/hive-unit/src/test/java/org/apache/hive/service/auth/TestCustomAuthentication.java
index 16b5dfc1492..dae1dc9b2a3 100644
---
a/itests/hive-unit/src/test/java/org/apache/hive/service/auth/TestCustomAuthentication.java
+++
b/itests/hive-unit/src/test/java/org/apache/hive/service/auth/TestCustomAuthentication.java
@@ -82,7 +82,6 @@ public static void tearDown() throws Exception {
public void testCustomAuthentication() throws Exception {
String url = "jdbc:hive2://localhost:10000/default";
- Class.forName("org.apache.hive.jdbc.HiveDriver");
try {
DriverManager.getConnection(url, "wronguser", "pwd");
diff --git
a/itests/hive-unit/src/test/java/org/apache/hive/service/auth/TestHttpCookieAuthenticationTest.java
b/itests/hive-unit/src/test/java/org/apache/hive/service/auth/TestHttpCookieAuthenticationTest.java
index 827cc689a25..636c930835d 100644
---
a/itests/hive-unit/src/test/java/org/apache/hive/service/auth/TestHttpCookieAuthenticationTest.java
+++
b/itests/hive-unit/src/test/java/org/apache/hive/service/auth/TestHttpCookieAuthenticationTest.java
@@ -34,7 +34,6 @@
import org.apache.hadoop.hive.conf.HiveConf;
import org.apache.hive.jdbc.HiveConnection;
-import org.apache.hive.jdbc.HiveDriver;
import org.apache.hive.jdbc.miniHS2.MiniHS2;
import org.apache.http.client.CookieStore;
import org.apache.http.client.HttpClient;
@@ -76,8 +75,6 @@ public static void stopServices() throws Exception {
public void testHttpJdbcCookies() throws Exception {
String sqlQuery = "show tables";
- Class.forName(HiveDriver.class.getCanonicalName());
-
String username = System.getProperty("user.name");
try(Connection connection =
DriverManager.getConnection(miniHS2.getJdbcURL(), username, "bar")) {
assertNotNull(connection);
diff --git
a/itests/hive-unit/src/test/java/org/apache/hive/service/auth/TrustDomainAuthenticationTest.java
b/itests/hive-unit/src/test/java/org/apache/hive/service/auth/TrustDomainAuthenticationTest.java
index dbadac36a16..6b40895ea7e 100644
---
a/itests/hive-unit/src/test/java/org/apache/hive/service/auth/TrustDomainAuthenticationTest.java
+++
b/itests/hive-unit/src/test/java/org/apache/hive/service/auth/TrustDomainAuthenticationTest.java
@@ -116,7 +116,6 @@ public void testTrustedDomainAuthentication() throws
Exception {
}
String url = "jdbc:hive2://localhost:" + port + "/default" + urlExtra;
- Class.forName("org.apache.hive.jdbc.HiveDriver");
if (properTrustedDomain) {
testProperTrustedDomainAuthentication(url);
diff --git
a/itests/hive-unit/src/test/java/org/apache/hive/service/auth/jwt/TestHttpJwtAuthentication.java
b/itests/hive-unit/src/test/java/org/apache/hive/service/auth/jwt/TestHttpJwtAuthentication.java
index c6973ac4346..9990430bb2e 100644
---
a/itests/hive-unit/src/test/java/org/apache/hive/service/auth/jwt/TestHttpJwtAuthentication.java
+++
b/itests/hive-unit/src/test/java/org/apache/hive/service/auth/jwt/TestHttpJwtAuthentication.java
@@ -133,7 +133,6 @@ private HiveConnection getConnection(String jwt) throws
Exception {
if (jwt != null) {
url += "jwt=" + jwt;
}
- Class.forName("org.apache.hive.jdbc.HiveDriver");
Connection connection = DriverManager.getConnection(url, null, null);
return (HiveConnection) connection;
}
diff --git
a/itests/hive-unit/src/test/java/org/apache/hive/service/cli/thrift/TestThriftCliServiceMessageSize.java
b/itests/hive-unit/src/test/java/org/apache/hive/service/cli/thrift/TestThriftCliServiceMessageSize.java
index a08e2ddf1f7..032ac3c9819 100644
---
a/itests/hive-unit/src/test/java/org/apache/hive/service/cli/thrift/TestThriftCliServiceMessageSize.java
+++
b/itests/hive-unit/src/test/java/org/apache/hive/service/cli/thrift/TestThriftCliServiceMessageSize.java
@@ -81,7 +81,6 @@ public void testMessageSize() throws Exception {
hiveServer2 = new HiveServer2();
String url = "jdbc:hive2://localhost:" + port + "/default";
- Class.forName("org.apache.hive.jdbc.HiveDriver");
try {
// First start HS2 with high message size limit. This should allow
connections
diff --git
a/itests/util/src/main/java/org/apache/hadoop/hive/ql/externalDB/AbstractExternalDB.java
b/itests/util/src/main/java/org/apache/hadoop/hive/ql/externalDB/AbstractExternalDB.java
index 2bac0b0f930..f3e5a62265e 100644
---
a/itests/util/src/main/java/org/apache/hadoop/hive/ql/externalDB/AbstractExternalDB.java
+++
b/itests/util/src/main/java/org/apache/hadoop/hive/ql/externalDB/AbstractExternalDB.java
@@ -165,9 +165,8 @@ public void stop() throws IOException, InterruptedException
{
Arrays.stream(ConnectionProperty.values()).forEach(p -> p.clear(this));
}
- public void execute(String script) throws IOException, SQLException,
ClassNotFoundException {
+ public void execute(String script) throws IOException, SQLException {
// Test we can connect to database
- Class.forName(getJdbcDriver());
try (Connection ignored = DriverManager.getConnection(getJdbcUrl(),
getRootUser(), getRootPassword())) {
LOG.info("Successfully connected to {} with user {} and password
{}", getJdbcUrl(), getRootUser(), getRootPassword());
}
diff --git
a/itests/util/src/main/java/org/apache/hive/jdbc/miniHS2/MiniHS2.java
b/itests/util/src/main/java/org/apache/hive/jdbc/miniHS2/MiniHS2.java
index 2c27daf29a0..ee4dc3e9656 100644
--- a/itests/util/src/main/java/org/apache/hive/jdbc/miniHS2/MiniHS2.java
+++ b/itests/util/src/main/java/org/apache/hive/jdbc/miniHS2/MiniHS2.java
@@ -66,7 +66,6 @@ public class MiniHS2 extends AbstractHiveService {
public static final String HS2_BINARY_MODE = "binary";
public static final String HS2_HTTP_MODE = "http";
public static final String HS2_ALL_MODE = "all";
- private static final String driverName = "org.apache.hive.jdbc.HiveDriver";
private static final FsPermission FULL_PERM = new FsPermission((short)00777);
private static final FsPermission WRITE_ALL_PERM = new
FsPermission((short)00733);
private static final String tmpDir = System.getProperty("test.tmp.dir");
@@ -718,10 +717,6 @@ private boolean isDynamicServiceDiscovery() throws
Exception {
return false;
}
- public static String getJdbcDriverName() {
- return driverName;
- }
-
public MiniMrShim getMR() {
return mr;
}
diff --git
a/llap-ext-client/src/java/org/apache/hadoop/hive/llap/LlapBaseInputFormat.java
b/llap-ext-client/src/java/org/apache/hadoop/hive/llap/LlapBaseInputFormat.java
index 1e204b0df73..3309901e849 100644
---
a/llap-ext-client/src/java/org/apache/hadoop/hive/llap/LlapBaseInputFormat.java
+++
b/llap-ext-client/src/java/org/apache/hadoop/hive/llap/LlapBaseInputFormat.java
@@ -92,7 +92,6 @@ public class LlapBaseInputFormat<V extends
WritableComparable<?>>
private static final Logger LOG =
LoggerFactory.getLogger(LlapBaseInputFormat.class);
- private static String driverName = "org.apache.hive.jdbc.HiveDriver";
private static final Object lock = new Object();
private static final Map<String, List<Connection>> connectionMap = new
HashMap<String, List<Connection>>();
@@ -222,12 +221,6 @@ public InputSplit[] getSplits(JobConf job, int numSplits)
throws IOException {
LOG.info("Handle ID not specified - generated handle ID {}", handleId);
}
- try {
- Class.forName(driverName);
- } catch (ClassNotFoundException e) {
- throw new IOException(e);
- }
-
LOG.info("Handle ID {}: query={}", handleId, query);
String escapedQuery = StringUtils.escapeString(query, ESCAPE_CHAR,
escapedChars);
String sql = String.format(SPLIT_QUERY, escapedQuery, numSplits);
diff --git
a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/AbstractJDBCConnectorProvider.java
b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/AbstractJDBCConnectorProvider.java
index c30d1eddad1..f50035d7cac 100644
---
a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/AbstractJDBCConnectorProvider.java
+++
b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/AbstractJDBCConnectorProvider.java
@@ -107,13 +107,6 @@ public AbstractJDBCConnectorProvider(String dbName,
DataConnector dataConn, Stri
try {
warehouse = new Warehouse(MetastoreConf.newMetastoreConf());
} catch (MetaException e) { /* ignore */ }
-
- try {
- Class.forName(driverClassName);
- } catch (ClassNotFoundException cnfe) {
- LOG.warn("Driver class not found in classpath: {}" + driverClassName);
- throw new RuntimeException("Driver class not found:" +
driverClass.getClass().getName(), cnfe);
- }
}
@Override public void open() throws ConnectException {
diff --git
a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/tools/schematool/HiveSchemaHelper.java
b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/tools/schematool/HiveSchemaHelper.java
index fe9dbb8ccb3..47000cc41b2 100644
---
a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/tools/schematool/HiveSchemaHelper.java
+++
b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/tools/schematool/HiveSchemaHelper.java
@@ -81,9 +81,6 @@ public static Connection getConnectionToMetastore(String
userName, String passwo
throw new HiveMetaException("UserName empty ");
}
- // load required JDBC driver
- Class.forName(driver);
-
// Connect using the JDBC URL and user/pass from conf
Connection conn = DriverManager.getConnection(url, userName, password);
if (schema != null) {
@@ -92,9 +89,6 @@ public static Connection getConnectionToMetastore(String
userName, String passwo
return conn;
} catch (IOException | SQLException e) {
throw new HiveMetaException("Failed to get schema version.", e);
- } catch (ClassNotFoundException e) {
- LOG.error("Unable to find driver class", e);
- throw new HiveMetaException("Failed to load driver", e);
}
}
diff --git
a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/jdbc/NoPoolConnectionPool.java
b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/jdbc/NoPoolConnectionPool.java
index 9b869be0f44..6f7ca8bb970 100644
---
a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/jdbc/NoPoolConnectionPool.java
+++
b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/jdbc/NoPoolConnectionPool.java
@@ -27,7 +27,7 @@
import javax.sql.DataSource;
import java.io.PrintWriter;
import java.sql.Connection;
-import java.sql.Driver;
+import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;
@@ -41,8 +41,6 @@ public class NoPoolConnectionPool implements DataSource {
// implement them.
private final Configuration conf;
private final DatabaseProduct dbProduct;
- private Driver driver;
- private String connString;
private String user;
private String passwd;
@@ -62,38 +60,14 @@ public Connection getConnection() throws SQLException {
@Override
public Connection getConnection(String username, String password) throws
SQLException {
- // Find the JDBC driver
- if (driver == null) {
- String driverName = MetastoreConf.getVar(conf,
MetastoreConf.ConfVars.CONNECTION_DRIVER);
- if (driverName == null || driverName.equals("")) {
- String msg = "JDBC driver for transaction db not set in configuration
" +
- "file, need to set " +
MetastoreConf.ConfVars.CONNECTION_DRIVER.getVarname();
- LOG.error(msg);
- throw new RuntimeException(msg);
- }
- try {
- LOG.info("Going to load JDBC driver {}", driverName);
- driver = (Driver) Class.forName(driverName).newInstance();
- } catch (InstantiationException e) {
- throw new RuntimeException("Unable to instantiate driver " +
driverName + ", " +
- e.getMessage(), e);
- } catch (IllegalAccessException e) {
- throw new RuntimeException(
- "Unable to access driver " + driverName + ", " + e.getMessage(),
- e);
- } catch (ClassNotFoundException e) {
- throw new RuntimeException("Unable to find driver " + driverName + ",
" + e.getMessage(),
- e);
- }
- connString = MetastoreConf.getVar(conf,
MetastoreConf.ConfVars.CONNECT_URL_KEY);
- }
+ String connString = MetastoreConf.getVar(conf,
MetastoreConf.ConfVars.CONNECT_URL_KEY);
try {
LOG.info("Connecting to transaction db with connection string {}",
connString);
Properties connectionProps = new Properties();
connectionProps.setProperty("user", username);
connectionProps.setProperty("password", password);
- Connection conn = driver.connect(connString, connectionProps);
+ Connection conn = DriverManager.getConnection(connString,
connectionProps);
String prepareStmt = dbProduct != null ? dbProduct.getPrepareTxnStmt() :
null;
if (prepareStmt != null) {
try (Statement stmt = conn.createStatement()) {
diff --git
a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/utils/TestTxnDbUtil.java
b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/utils/TestTxnDbUtil.java
index bd50c0088e1..96a1b8a1589 100644
---
a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/utils/TestTxnDbUtil.java
+++
b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/utils/TestTxnDbUtil.java
@@ -21,7 +21,7 @@
import java.io.FileInputStream;
import java.io.InputStream;
import java.sql.Connection;
-import java.sql.Driver;
+import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
@@ -408,15 +408,13 @@ public static void executeUpdate(Configuration conf,
String query)
}
public static Connection getConnection(Configuration conf) throws Exception {
- String jdbcDriver = MetastoreConf.getVar(conf, ConfVars.CONNECTION_DRIVER);
- Driver driver = (Driver) Class.forName(jdbcDriver).newInstance();
Properties prop = new Properties();
String driverUrl = MetastoreConf.getVar(conf, ConfVars.CONNECT_URL_KEY);
String user = MetastoreConf.getVar(conf, ConfVars.CONNECTION_USER_NAME);
String passwd = MetastoreConf.getPassword(conf,
MetastoreConf.ConfVars.PWD);
prop.setProperty("user", user);
prop.setProperty("password", passwd);
- Connection conn = driver.connect(driverUrl, prop);
+ Connection conn = DriverManager.getConnection(driverUrl, prop);
conn.setAutoCommit(true);
DatabaseProduct dbProduct =
determineDatabaseProduct(conn.getMetaData().getDatabaseProductName(), conf);
diff --git
a/testutils/src/java/org/apache/hive/testutils/jdbc/HiveBurnInClient.java
b/testutils/src/java/org/apache/hive/testutils/jdbc/HiveBurnInClient.java
index 005119ae2f2..ad6f6c1adbc 100644
--- a/testutils/src/java/org/apache/hive/testutils/jdbc/HiveBurnInClient.java
+++ b/testutils/src/java/org/apache/hive/testutils/jdbc/HiveBurnInClient.java
@@ -26,8 +26,6 @@
public class HiveBurnInClient {
- private static final String driverName = "org.apache.hive.jdbc.HiveDriver";
-
//default 80k (runs slightly over 1 day long)
private static final int NUM_QUERY_ITERATIONS = 80000;
@@ -115,10 +113,9 @@ public static void runQueries(Connection con, int
numberOfQueryIterations) throw
/**
* @param args
* @throws SQLException
- * @throws ClassNotFoundException
*/
- public static void main(String[] args) throws SQLException,
ClassNotFoundException {
- Class.forName(driverName);
+ public static void main(String[] args) throws SQLException {
+ // Ensure hive-jdbc jar is in the classpath
int numberOfQueryIterations = NUM_QUERY_ITERATIONS;
if (args.length > 0) {