當前位置: 首頁>>代碼示例>>Java>>正文


Java Connection.getSchema方法代碼示例

本文整理匯總了Java中java.sql.Connection.getSchema方法的典型用法代碼示例。如果您正苦於以下問題:Java Connection.getSchema方法的具體用法?Java Connection.getSchema怎麽用?Java Connection.getSchema使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.sql.Connection的用法示例。


在下文中一共展示了Connection.getSchema方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testRemoteConnectionProperties

import java.sql.Connection; //導入方法依賴的package包/類
@Test public void testRemoteConnectionProperties() throws Exception {
  ConnectionSpec.getDatabaseLock().lock();
  try (AvaticaConnection conn = (AvaticaConnection) DriverManager.getConnection(url)) {
    String id = conn.id;
    final Map<String, ConnectionPropertiesImpl> m = ((RemoteMeta) getMeta(conn)).propsMap;
    assertFalse("remote connection map should start ignorant", m.containsKey(id));
    // force creating a connection object on the remote side.
    try (final Statement stmt = conn.createStatement()) {
      assertTrue("creating a statement starts a local object.", m.containsKey(id));
      assertTrue(stmt.execute("select count(1) from EMP"));
    }
    Connection remoteConn = getConnection(FullyRemoteJdbcMetaFactory.getInstance(), id);
    final boolean defaultRO = remoteConn.isReadOnly();
    final boolean defaultAutoCommit = remoteConn.getAutoCommit();
    final String defaultCatalog = remoteConn.getCatalog();
    final String defaultSchema = remoteConn.getSchema();
    conn.setReadOnly(!defaultRO);
    assertTrue("local changes dirty local state", m.get(id).isDirty());
    assertEquals("remote connection has not been touched", defaultRO, remoteConn.isReadOnly());
    conn.setAutoCommit(!defaultAutoCommit);
    assertEquals("remote connection has not been touched",
        defaultAutoCommit, remoteConn.getAutoCommit());

    // further interaction with the connection will force a sync
    try (final Statement stmt = conn.createStatement()) {
      assertEquals(!defaultAutoCommit, remoteConn.getAutoCommit());
      assertFalse("local values should be clean", m.get(id).isDirty());
    }
  } finally {
    ConnectionSpec.getDatabaseLock().unlock();
  }
}
 
開發者ID:apache,項目名稱:calcite-avatica,代碼行數:33,代碼來源:RemoteMetaTest.java

示例2: ConnectionPropertiesImpl

import java.sql.Connection; //導入方法依賴的package包/類
public ConnectionPropertiesImpl(Connection conn) throws SQLException {
  this(conn.getAutoCommit(), conn.isReadOnly(), conn.getTransactionIsolation(),
      conn.getCatalog(), conn.getSchema());
}
 
開發者ID:apache,項目名稱:calcite-avatica,代碼行數:5,代碼來源:ConnectionPropertiesImpl.java

示例3: extractName

import java.sql.Connection; //導入方法依賴的package包/類
/**
 * Extract a DataSource name, using a default one if necessary.
 * 
 * @param connection
 *            JDBC DataSource Connection.
 * @return a non-null DataSource name.
 * @throws SQLException
 *             if something goes wrong while extracting component info.
 */
protected String extractName(Connection connection) throws SQLException {
    String name = connection.getSchema();
    if (name == null) {
        name = connection.getCatalog();
    }
    return Optional.ofNullable(name).orElse(defaultName);
}
 
開發者ID:cereebro,項目名稱:cereebro,代碼行數:17,代碼來源:DataSourceRelationshipDetector.java


注:本文中的java.sql.Connection.getSchema方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。