Java Code Examples for java.sql.Driver#getMajorVersion()
The following examples show how to use
java.sql.Driver#getMajorVersion() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseHiveDialect.java From pentaho-metadata with GNU Lesser General Public License v2.1 | 6 votes |
protected synchronized void initDriverInfo() { Integer majorVersion = 0; Integer minorVersion = 0; try { // Load the driver version number Class<?> driverClass = Class.forName( getDriverClassName() ); //$NON-NLS-1$ if ( driverClass != null ) { Driver driver = (Driver) driverClass.getConstructor().newInstance(); majorVersion = driver.getMajorVersion(); minorVersion = driver.getMinorVersion(); } } catch ( Exception e ) { // Failed to load the driver version, leave at the defaults } driverMajorVersion = majorVersion; driverMinorVersion = minorVersion; }
Example 2
Source File: Dekaf.java From dekaf with Apache License 2.0 | 6 votes |
private void loadDrivers() { if (myJarNamesToLoad.isEmpty()) return; final Collection<Driver> loadedDrivers = Providers.loadAllProviders(Driver.class, myDriversClassLoader); ArrayList<Driver> drivers = new ArrayList<Driver>(loadedDrivers.size()); for (Driver driver : loadedDrivers) { if (driver.getClass().getName().equals("sun.jdbc.odbc.JdbcOdbcDriver")) continue; driver.getMajorVersion(); // to initialize the class //say("Registering driver: %s", driver.getClass().getName()); try { DriverManager.registerDriver(driver); drivers.add(driver); } catch (SQLException e) { error("Failed to register driver %s\n exception %s with message %s", driver.getClass().getName(), e.getClass().getName(), e.getMessage()); } } JdbcDrivers.setPreferredDrivers(myDriversClassLoader, drivers); }
Example 3
Source File: AbstractSQLMagicDAO.java From MtgDesktopCompanion with GNU General Public License v3.0 | 5 votes |
@Override public String getVersion() { try { Driver d = DriverManager.getDriver(getjdbcUrl()); return d.getMajorVersion()+"."+d.getMinorVersion(); } catch (SQLException e) { return "1.0"; } }
Example 4
Source File: JDBCXADataSource.java From clearpool with GNU General Public License v3.0 | 5 votes |
private void initCheck() { String url = this.jdbcDs.getUrl(); if (url.startsWith(JdbcUtils.ORACLE_ONE_PREFIX) || url.startsWith(JdbcUtils.ORACLE_ANO_PREFIX)) { Driver driver = this.jdbcDs.getDriver(); if (driver.getMajorVersion() < 10) { throw new ConnectionPoolException("not support oracle driver " + driver.getMajorVersion() + "." + driver.getMinorVersion()); } } if (url.startsWith("jdbc:h2:")) { this.h2Factory = H2Utils.createJdbcDataSourceFactory(); } }
Example 5
Source File: HiveDriver.java From pentaho-hadoop-shims with Apache License 2.0 | 5 votes |
@Override public int getMajorVersion() { Driver driverDelegate = this.delegate; if ( driverDelegate == null ) { return -1; } return driverDelegate.getMajorVersion(); }
Example 6
Source File: JDBCMBeanTest.java From gemfirexd-oss with Apache License 2.0 | 3 votes |
/** * <p> * Tests the MajorVersion attribute of the JDBCMBean. Will test that there * exists an attribute with that name that we are able to read, that it * returns the correct type, and that the return value is as expected.</p> * <p> * The expected value is retreived from the embedded driver that is directly * accessible to this JVM, making the assumption that this driver's version * information is the same as the version information of the embedded driver * used in the JVM being instrumented using JMX (this may or may not be the * same JVM).</p> * * @throws java.lang.Exception if an error occurs, or if the test fails. */ public void testAttributeMajorVersion() throws Exception { /* since the JDBCMBean instruments the embedded driver (InternalDriver), * we need to get expected values from the embedded driver even if * this test configuration is client/server. * Assuming that the embedded driver is available in the classpath. */ Driver d = new com.pivotal.gemfirexd.jdbc.EmbeddedDriver(); int expected = d.getMajorVersion(); assertIntAttribute(expected, getJdbcMBeanObjectName(), "MajorVersion"); }
Example 7
Source File: JDBCMBeanTest.java From gemfirexd-oss with Apache License 2.0 | 3 votes |
/** * <p> * Tests the MajorVersion attribute of the JDBCMBean. Will test that there * exists an attribute with that name that we are able to read, that it * returns the correct type, and that the return value is as expected.</p> * <p> * The expected value is retreived from the embedded driver that is directly * accessible to this JVM, making the assumption that this driver's version * information is the same as the version information of the embedded driver * used in the JVM being instrumented using JMX (this may or may not be the * same JVM).</p> * * @throws java.lang.Exception if an error occurs, or if the test fails. */ public void testAttributeMajorVersion() throws Exception { /* since the JDBCMBean instruments the embedded driver (InternalDriver), * we need to get expected values from the embedded driver even if * this test configuration is client/server. * Assuming that the embedded driver is available in the classpath. */ Driver d = new com.pivotal.gemfirexd.jdbc.EmbeddedDriver(); int expected = d.getMajorVersion(); assertIntAttribute(expected, getJdbcMBeanObjectName(), "MajorVersion"); }