diff --git a/beeline/src/java/org/apache/hive/beeline/BeeLine.java b/beeline/src/java/org/apache/hive/beeline/BeeLine.java index 3cbbc826d8d6..bef953409657 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 KNOWN_DRIVERS = new TreeSet(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 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 7eaa2618f840..e1364d1848de 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 names = new TreeSet(); - 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 drivers = + new TreeSet<>(Comparator.comparing(d -> d.getClass().getName())); + drivers.addAll(beeLine.getDrivers()); - // unique the list - for (Iterator 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 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 c3c5365631c6..baaddee4def6 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 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 5732e2061c29..71d9b492d9da 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 @@ * */ 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 73e6f3eb571c..bdea7f486c7e 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 17453216f28d..7253e31b0347 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() { @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 be21fbd5fc02..87482cbb89fa 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 cd4c1c3c75cc..cdf79423e6c3 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 36eb4820715a..d5e159cb8223 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 82a8f46350a8..3d96ec7f21ca 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 9adc38fdf566..f094590e018b 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 3e643369f5c9..f0c0a893d838 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 b770fa917570..4b1d988c29fa 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 b70e746a0f92..ef444e2d2994 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 78d819761fe8..40b3e0eec9d1 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 c9e324d3753a..55add652ece6 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 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 faaf87761697..669bb019f162 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 09f9d68a91d8..b8dac35fa2d4 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()); - 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 9e9de7e93f8d..faaf6b37782f 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 7c57db9b2498..9c841d8b1e1c 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 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 6083fd01a5c1..65982ec0461a 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 confOverlay = new HashMap(); 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 92f2d8c56572..ffb9ab1224af 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 0631c641177c..d2279d869bef 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 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 bc20d733f952..0b5a509ab92b 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 40802951f46b..929bd94f03d0 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 bb73b8bbca62..519f975fb7e4 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 12b1e6b14313..b9002c5113fc 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 6879c76be3b1..f1c59ba0cbda 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 eff2803eb019..25e77d24903f 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 a752c6731837..6947b0b4b88b 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 aafa101a3541..b304d2a579ae 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 3d5ddaa08c11..7423d017fb34 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 9f2fb3235891..0f010709a403 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 a08695678bc2..b2f94b00c81e 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 confOverlay = new HashMap(); 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 4ec86c0c1338..ed4890b6bb0f 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 ce0683403952..7443ae64ae43 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 ec6c65f75a25..bc37fbef8668 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 8512ff4ad6c9..304f1bbe9497 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 a50931c2bc2f..506d1b401502 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 9ae60634c60e..405f4c1b8574 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 d056ab3341c5..ca0ae94ef24e 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 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 b5a3568ab2cb..9452cb9e2be0 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 977fe4332057..036241752af3 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 60d939e83ba3..def11cb98f71 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 aae43c9ea5a6..fd7817088698 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 99df3efc453c..71736ce7506d 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 206eae5a54d0..52703b4691d0 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 1942dc194f13..2cfeabeb1b74 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 abc6977fea92..f1c661befd11 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 6321e049f5cb..dc3a2d838322 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 58bd57eedf9d..bfc6697aa854 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 16b5dfc1492d..dae1dc9b2a3d 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 827cc689a258..636c930835d0 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 dbadac36a163..6b40895ea7e2 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 c6973ac4346b..9990430bb2e7 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 a08e2ddf1f7f..032ac3c9819f 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 2bac0b0f9309..f3e5a62265e6 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 2c27daf29a03..ee4dc3e9656e 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 1e204b0df736..3309901e849a 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> 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> connectionMap = new HashMap>(); @@ -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 c30d1eddad1f..f50035d7cac2 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 fe9dbb8ccb3d..47000cc41b20 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 9b869be0f442..6f7ca8bb9709 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 bd50c0088e1a..96a1b8a15898 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 005119ae2f2a..ad6f6c1adbc9 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) {