java.sql.Driver#getMajorVersion ( )源码实例Demo

下面列出了java.sql.Driver#getMajorVersion ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: pentaho-metadata   文件: BaseHiveDialect.java
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;
}
 
源代码2 项目: dekaf   文件: Dekaf.java
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);
}
 
源代码3 项目: MtgDesktopCompanion   文件: AbstractSQLMagicDAO.java
@Override
public String getVersion() {
	try {
		Driver d = DriverManager.getDriver(getjdbcUrl());
		return d.getMajorVersion()+"."+d.getMinorVersion();
	} catch (SQLException e) {
		return "1.0";
	}
}
 
源代码4 项目: clearpool   文件: JDBCXADataSource.java
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();
  }
}
 
源代码5 项目: pentaho-hadoop-shims   文件: HiveDriver.java
@Override public int getMajorVersion() {
  Driver driverDelegate = this.delegate;
  if ( driverDelegate == null ) {
    return -1;
  }
  return driverDelegate.getMajorVersion();
}
 
源代码6 项目: gemfirexd-oss   文件: JDBCMBeanTest.java
/**
 * <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");
}
 
源代码7 项目: gemfirexd-oss   文件: JDBCMBeanTest.java
/**
 * <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");
}