Java Code Examples for java.sql.DatabaseMetaData#getURL()
The following examples show how to use
java.sql.DatabaseMetaData#getURL() .
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: DatabaseMetaDataTest.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
/** * getURL() method. Note that this method * is the only JDBC 3 DatabaseMetaData method * that is dropped in JSR169. */ public void testGetURL() throws SQLException { DatabaseMetaData dmd = getDMD(); String url; try { url = dmd.getURL(); } catch (NoSuchMethodError e) { // JSR 169 - method must not be there! assertTrue("getURL not supported", JDBC.vmSupportsJSR169()); assertFalse("getURL not supported", JDBC.vmSupportsJDBC2()); return; } assertFalse("getURL is supported!", JDBC.vmSupportsJSR169()); assertTrue("getURL is supported!", JDBC.vmSupportsJDBC2()); assertEquals("getURL match", getTestConfiguration().getJDBCUrl(), url); }
Example 2
Source File: DatabaseInformations.java From javamelody with Apache License 2.0 | 6 votes |
static Database getDatabaseForConnection(Connection connection) throws SQLException { final DatabaseMetaData metaData = connection.getMetaData(); final String databaseName = metaData.getDatabaseProductName(); final String url = metaData.getURL(); for (final Database database : Database.values()) { if (database.isRecognized(databaseName, url)) { if (database == MYSQL && metaData.getDatabaseMajorVersion() <= 4) { // si mysql et version 4 alors c'est MYSQL4 et non MYSQL return MYSQL4; } return database; } } throw new IllegalArgumentException( I18N.getFormattedString("type_base_de_donnees_inconnu", databaseName)); }
Example 3
Source File: DatabaseMetaDataTest.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
/** * getURL() method. Note that this method * is the only JDBC 3 DatabaseMetaData method * that is dropped in JSR169. */ public void testGetURL() throws SQLException { DatabaseMetaData dmd = getDMD(); String url; try { url = dmd.getURL(); } catch (NoSuchMethodError e) { // JSR 169 - method must not be there! assertTrue("getURL not supported", JDBC.vmSupportsJSR169()); assertFalse("getURL not supported", JDBC.vmSupportsJDBC2()); return; } assertFalse("getURL is supported!", JDBC.vmSupportsJSR169()); assertTrue("getURL is supported!", JDBC.vmSupportsJDBC2()); assertEquals("getURL match", getTestConfiguration().getJDBCUrl(), url); }
Example 4
Source File: Kingbase8DictionaryBack.java From o2oa with GNU Affero General Public License v3.0 | 6 votes |
public void connectedConfiguration(Connection conn) throws SQLException { super.connectedConfiguration(conn); boolean requiresWarnings = true; DatabaseMetaData meta = conn.getMetaData(); String driverName = meta.getDriverName(); String url = meta.getURL(); if (this.driverVendor == null) { if ((driverName != null) && (driverName.equalsIgnoreCase("com.kingbase8.Driver"))) { this.driverVendor = "Kingbase8JdbcDriver"; if ((url != null) && (url.startsWith("jdbc:kingbase8://"))) { requiresWarnings = false; } } else { this.driverVendor = "other"; } } if (("Kingbase8JdbcDriver".equalsIgnoreCase(this.driverVendor)) && (requiresWarnings)) { this.log.warn(_loc.get("kingbase8 Jdbc connection", url)); } }
Example 5
Source File: JdbcFacade.java From iaf with Apache License 2.0 | 6 votes |
/** * Returns the name and location of the database that this objects operates on. * * @see nl.nn.adapterframework.core.HasPhysicalDestination#getPhysicalDestinationName() */ @Override public String getPhysicalDestinationName() { String result="unknown"; try (Connection connection = getConnection()) { DatabaseMetaData metadata = connection.getMetaData(); result = metadata.getURL(); String catalog=null; catalog=connection.getCatalog(); result += catalog!=null ? ("/"+catalog):""; } catch (Exception e) { log.warn(getLogPrefix()+"exception retrieving PhysicalDestinationName", e); } return result; }
Example 6
Source File: KingbaseDictionary.java From o2oa with GNU Affero General Public License v3.0 | 6 votes |
public void connectedConfiguration(Connection conn) throws SQLException { super.connectedConfiguration(conn); boolean requiresWarnings = true; DatabaseMetaData meta = conn.getMetaData(); String driverName = meta.getDriverName(); String url = meta.getURL(); if (this.driverVendor == null) { if ((driverName != null) && (driverName.equalsIgnoreCase("com.kingbase.Driver"))) { this.driverVendor = "KingbaseJdbcDriver"; if ((url != null) && (url.startsWith("jdbc:kingbase://"))) { requiresWarnings = false; } } else { this.driverVendor = "other"; } } if (("KingbaseJdbcDriver".equalsIgnoreCase(this.driverVendor)) && (requiresWarnings)) { this.log.warn(_loc.get("kingbase Jdbc connection", url)); } }
Example 7
Source File: DbMeta.java From das with Apache License 2.0 | 6 votes |
private DbMeta(Connection conn, String realDbName, DatabaseCategory dbCategory) throws SQLException { dataBaseKeyName = realDbName; this.dbCategory = dbCategory; try { DatabaseMetaData meta = conn.getMetaData(); databaseName = conn.getCatalog(); url = meta.getURL(); host = parseHostFromDBURL(url); userName = null; if(configureLocator == null) { userName = DataSourceLocator.getDataSourceConfigure(realDbName).getUserName(); }else { userName = configureLocator.getDataSourceConfigure(realDbName).getUserName(); } } catch (Throwable e) { } }
Example 8
Source File: DbUtilities.java From openemm with GNU Affero General Public License v3.0 | 5 votes |
public static String getDbUrl(Connection connection) { try { DatabaseMetaData databaseMetaData = connection.getMetaData(); if (databaseMetaData != null) { return databaseMetaData.getURL(); } else { return null; } } catch (SQLException e) { return null; } }
Example 9
Source File: DatabaseStatusChecker.java From dubbox with Apache License 2.0 | 5 votes |
public Status check() { boolean ok; try { Connection connection = dataSource.getConnection(); try { DatabaseMetaData metaData = connection.getMetaData(); ResultSet resultSet = metaData.getTypeInfo(); try { ok = resultSet.next(); } finally { resultSet.close(); } if (message == null) { message = metaData.getURL() + " (" + metaData.getDatabaseProductName() + " " + metaData.getDatabaseProductVersion() + ", " + getIsolation(metaData.getDefaultTransactionIsolation()) + ")"; } if (version == 0) { version = metaData.getDatabaseMajorVersion(); } } finally { connection.close(); } } catch (Throwable e) { logger.error(e.getMessage(), e); ok = false; } return new Status(! ok ? Status.Level.ERROR : (version < 5 ? Status.Level.WARN : Status.Level.OK), message); }
Example 10
Source File: DBInformation.java From cloud-spring-boot-sample with Apache License 2.0 | 5 votes |
public DBInformation(DatabaseMetaData metaData) throws SQLException { url = metaData.getURL(); dbName = metaData.getDatabaseProductName(); dbMajorVersion = metaData.getDatabaseMajorVersion(); dbMinorVersion = metaData.getDatabaseMinorVersion(); driverName = metaData.getDriverName(); driverVersion = metaData.getDriverVersion(); userName = metaData.getUserName(); }
Example 11
Source File: DatabaseStatusChecker.java From dubbox-hystrix with Apache License 2.0 | 5 votes |
public Status check() { boolean ok; try { Connection connection = dataSource.getConnection(); try { DatabaseMetaData metaData = connection.getMetaData(); ResultSet resultSet = metaData.getTypeInfo(); try { ok = resultSet.next(); } finally { resultSet.close(); } if (message == null) { message = metaData.getURL() + " (" + metaData.getDatabaseProductName() + " " + metaData.getDatabaseProductVersion() + ", " + getIsolation(metaData.getDefaultTransactionIsolation()) + ")"; } if (version == 0) { version = metaData.getDatabaseMajorVersion(); } } finally { connection.close(); } } catch (Throwable e) { logger.error(e.getMessage(), e); ok = false; } return new Status(! ok ? Status.Level.ERROR : (version < 5 ? Status.Level.WARN : Status.Level.OK), message); }
Example 12
Source File: ClientServerDUnit.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
private void checkDBMetadata(Connection conn, String url) throws Exception { DatabaseMetaData dbmd = conn.getMetaData(); String actualUrl = dbmd.getURL(); // remove any trailing slash getLogWriter().info("Got DB " + dbmd.getDatabaseProductName() + ' ' + dbmd.getDatabaseProductVersion() + " using URL " + actualUrl); assertEquals("Expected the provided URL to match", url.replaceFirst("/$", ""), actualUrl.replaceFirst("/$", "")); ResultSet rs = dbmd.getCatalogs(); while (rs.next()) { getLogWriter().info("Got DB catalog: " + rs.getString(1)); } rs.close(); rs = dbmd.getSchemas(); while (rs.next()) { getLogWriter().info("Got DB schema: " + rs.getString(1) + " in catalog=" + rs.getString(2)); } rs.close(); rs = dbmd.getProcedures(null, null, null); while (rs.next()) { getLogWriter().info("Got Procedure " + rs.getString(3) + " in catalog=" + rs.getString(1) + ", schema=" + rs.getString(2)); } rs.close(); // also check for a few flags that are failing over network connection assertTrue(dbmd.othersInsertsAreVisible(ResultSet.TYPE_FORWARD_ONLY)); assertTrue(dbmd.othersDeletesAreVisible(ResultSet.TYPE_FORWARD_ONLY)); }
Example 13
Source File: HerokuDatabasePropertiesProviderResourceTest.java From tomee with Apache License 2.0 | 5 votes |
@Test public void herokuToJava() throws Exception { assertNotNull(db); final Connection connection = db.getConnection(); final DatabaseMetaData metaData = connection.getMetaData(); final String url = metaData.getURL(); assertTrue(url.startsWith("jdbc:hsqldb:hsql://localhost:")); assertTrue(url.endsWith("/adb")); assertEquals("SA", metaData.getUserName()); connection.close(); }
Example 14
Source File: DatabaseStatusChecker.java From dubbox with Apache License 2.0 | 5 votes |
public Status check() { boolean ok; try { Connection connection = dataSource.getConnection(); try { DatabaseMetaData metaData = connection.getMetaData(); ResultSet resultSet = metaData.getTypeInfo(); try { ok = resultSet.next(); } finally { resultSet.close(); } if (message == null) { message = metaData.getURL() + " (" + metaData.getDatabaseProductName() + " " + metaData.getDatabaseProductVersion() + ", " + getIsolation(metaData.getDefaultTransactionIsolation()) + ")"; } if (version == 0) { version = metaData.getDatabaseMajorVersion(); } } finally { connection.close(); } } catch (Throwable e) { logger.error(e.getMessage(), e); ok = false; } return new Status(! ok ? Status.Level.ERROR : (version < 5 ? Status.Level.WARN : Status.Level.OK), message); }
Example 15
Source File: ClientServerDUnit.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
private void checkDBMetadata(Connection conn, String url) throws Exception { DatabaseMetaData dbmd = conn.getMetaData(); String actualUrl = dbmd.getURL(); // remove any trailing slash getLogWriter().info("Got DB " + dbmd.getDatabaseProductName() + ' ' + dbmd.getDatabaseProductVersion() + " using URL " + actualUrl); assertEquals("Expected the provided URL to match", url.replaceFirst("/$", ""), actualUrl.replaceFirst("/$", "")); ResultSet rs = dbmd.getCatalogs(); while (rs.next()) { getLogWriter().info("Got DB catalog: " + rs.getString(1)); } rs.close(); rs = dbmd.getSchemas(); while (rs.next()) { getLogWriter().info("Got DB schema: " + rs.getString(1) + " in catalog=" + rs.getString(2)); } rs.close(); rs = dbmd.getProcedures(null, null, null); while (rs.next()) { getLogWriter().info("Got Procedure " + rs.getString(3) + " in catalog=" + rs.getString(1) + ", schema=" + rs.getString(2)); } rs.close(); // also check for a few flags that are failing over network connection assertTrue(dbmd.othersInsertsAreVisible(ResultSet.TYPE_FORWARD_ONLY)); assertTrue(dbmd.othersDeletesAreVisible(ResultSet.TYPE_FORWARD_ONLY)); }
Example 16
Source File: DatabaseStatusChecker.java From open-capacity-platform with Apache License 2.0 | 5 votes |
public Status check() { boolean ok; try { Connection connection = dataSource.getConnection(); try { DatabaseMetaData metaData = connection.getMetaData(); ResultSet resultSet = metaData.getTypeInfo(); try { ok = resultSet.next(); } finally { resultSet.close(); } if (message == null) { message = metaData.getURL() + " (" + metaData.getDatabaseProductName() + " " + metaData.getDatabaseProductVersion() + ", " + getIsolation(metaData.getDefaultTransactionIsolation()) + ")"; } if (version == 0) { version = metaData.getDatabaseMajorVersion(); } } finally { connection.close(); } } catch (Throwable e) { logger.error(e.getMessage(), e); ok = false; } return new Status(!ok ? Status.Level.ERROR : (version < 5 ? Status.Level.WARN : Status.Level.OK), message); }
Example 17
Source File: DatabaseStatusChecker.java From dubbo3 with Apache License 2.0 | 5 votes |
public Status check() { boolean ok; try { Connection connection = dataSource.getConnection(); try { DatabaseMetaData metaData = connection.getMetaData(); ResultSet resultSet = metaData.getTypeInfo(); try { ok = resultSet.next(); } finally { resultSet.close(); } if (message == null) { message = metaData.getURL() + " (" + metaData.getDatabaseProductName() + " " + metaData.getDatabaseProductVersion() + ", " + getIsolation(metaData.getDefaultTransactionIsolation()) + ")"; } if (version == 0) { version = metaData.getDatabaseMajorVersion(); } } finally { connection.close(); } } catch (Throwable e) { logger.error(e.getMessage(), e); ok = false; } return new Status(! ok ? Status.Level.ERROR : (version < 5 ? Status.Level.WARN : Status.Level.OK), message); }
Example 18
Source File: DatabaseStatusChecker.java From dubbo3 with Apache License 2.0 | 5 votes |
public Status check() { boolean ok; try { Connection connection = dataSource.getConnection(); try { DatabaseMetaData metaData = connection.getMetaData(); ResultSet resultSet = metaData.getTypeInfo(); try { ok = resultSet.next(); } finally { resultSet.close(); } if (message == null) { message = metaData.getURL() + " (" + metaData.getDatabaseProductName() + " " + metaData.getDatabaseProductVersion() + ", " + getIsolation(metaData.getDefaultTransactionIsolation()) + ")"; } if (version == 0) { version = metaData.getDatabaseMajorVersion(); } } finally { connection.close(); } } catch (Throwable e) { logger.error(e.getMessage(), e); ok = false; } return new Status(! ok ? Status.Level.ERROR : (version < 5 ? Status.Level.WARN : Status.Level.OK), message); }
Example 19
Source File: DatabaseStatusChecker.java From dubbox with Apache License 2.0 | 5 votes |
public Status check() { boolean ok; try { Connection connection = dataSource.getConnection(); try { DatabaseMetaData metaData = connection.getMetaData(); ResultSet resultSet = metaData.getTypeInfo(); try { ok = resultSet.next(); } finally { resultSet.close(); } if (message == null) { message = metaData.getURL() + " (" + metaData.getDatabaseProductName() + " " + metaData.getDatabaseProductVersion() + ", " + getIsolation(metaData.getDefaultTransactionIsolation()) + ")"; } if (version == 0) { version = metaData.getDatabaseMajorVersion(); } } finally { connection.close(); } } catch (Throwable e) { logger.error(e.getMessage(), e); ok = false; } return new Status(! ok ? Status.Level.ERROR : (version < 5 ? Status.Level.WARN : Status.Level.OK), message); }
Example 20
Source File: DatabaseStatusChecker.java From dubbox with Apache License 2.0 | 5 votes |
public Status check() { boolean ok; try { Connection connection = dataSource.getConnection(); try { DatabaseMetaData metaData = connection.getMetaData(); ResultSet resultSet = metaData.getTypeInfo(); try { ok = resultSet.next(); } finally { resultSet.close(); } if (message == null) { message = metaData.getURL() + " (" + metaData.getDatabaseProductName() + " " + metaData.getDatabaseProductVersion() + ", " + getIsolation(metaData.getDefaultTransactionIsolation()) + ")"; } if (version == 0) { version = metaData.getDatabaseMajorVersion(); } } finally { connection.close(); } } catch (Throwable e) { logger.error(e.getMessage(), e); ok = false; } return new Status(! ok ? Status.Level.ERROR : (version < 5 ? Status.Level.WARN : Status.Level.OK), message); }