Java Code Examples for java.sql.DriverManager#getLoginTimeout()

The following examples show how to use java.sql.DriverManager#getLoginTimeout() . 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: OpenConnectionCommand.java    From bigtable-sql with Apache License 2.0 5 votes vote down vote up
private void awaitConnection(Future future, final OpenConnectionCommandListener openConnectionCommandListener)
{
   try
   {
      if (0 < DriverManager.getLoginTimeout())
      {
         future.get(DriverManager.getLoginTimeout(), TimeUnit.SECONDS);
      }
      else
      {
         future.get();
      }

      SwingUtilities.invokeLater(new Runnable()
      {
         public void run()
         {
            openConnectionCommandListener.openConnectionFinished(null);
         }
      });
   }
   catch (final Throwable t)
   {
      SwingUtilities.invokeLater(new Runnable()
      {
         public void run()
         {
            openConnectionCommandListener.openConnectionFinished(t);
         }
      });
   }
}
 
Example 2
Source File: SquirrelPreferences.java    From bigtable-sql with Apache License 2.0 5 votes vote down vote up
private void loadDefaults()
{
	if (_loginTimeout == -1)
	{
		_loginTimeout = DriverManager.getLoginTimeout();
	}
}
 
Example 3
Source File: SimpleDataSource.java    From oxygen with Apache License 2.0 4 votes vote down vote up
@Override
public int getLoginTimeout() {
  return DriverManager.getLoginTimeout();
}
 
Example 4
Source File: UnpooledDataSource.java    From ZhihuSpider with MIT License 4 votes vote down vote up
public int getLoginTimeout() throws SQLException {
	return DriverManager.getLoginTimeout();
}
 
Example 5
Source File: ClientService.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
public ClientService(String host, int port, OpenConnectionArgs connArgs)
    throws GFXDException {
  this.isOpen = false;

  Thread currentThread = Thread.currentThread();
  connArgs.setClientHostName(hostName).setClientID(
      hostId + '|' + currentThread.getName() + "<0x"
          + Long.toHexString(currentThread.getId()) + '>');

  HostAddress hostAddr = ThriftUtils.getHostAddress(host, port);
  this.currentHostConnection = null;
  this.connArgs = connArgs;

  Map<String, String> props = connArgs.getProperties();
  String propValue;
  // default for load-balance is true
  this.loadBalance = (props == null || !"false".equalsIgnoreCase(props
      .remove(ClientAttribute.LOAD_BALANCE)));

  // setup the original host list
  if (props != null && (propValue = props.remove(
      ClientAttribute.SECONDARY_LOCATORS)) != null) {
    this.connHosts = new ArrayList<HostAddress>(4);
    this.connHosts.add(hostAddr);
    final int[] portHolder = new int[1];
    SharedUtils.splitCSV(propValue, addHostAddresses, this.connHosts,
        portHolder);
  }
  else {
    this.connHosts = Collections.singletonList(hostAddr);
  }

  // read the server groups to use for connection
  if (props != null
      && (propValue = props.remove(ClientAttribute.SERVER_GROUPS)) != null) {
    @SuppressWarnings("unchecked")
    Set<String> groupsSet = new THashSet(4);
    SharedUtils.splitCSV(propValue, SharedUtils.stringAggregator,
        groupsSet, Boolean.TRUE);
    this.serverGroups = Collections.unmodifiableSet(groupsSet);
  }
  else {
    this.serverGroups = null;
  }

  this.socketParams = new SocketParameters();
  // initialize read-timeout with DriverManager login timeout first
  int loginTimeout = DriverManager.getLoginTimeout();
  if (loginTimeout != 0) {
    SocketParameters.Param.READ_TIMEOUT.setParameter(this.socketParams,
        Integer.toString(loginTimeout));
  }
  // now check for the protocol details like SSL etc and thus get the required
  // GemFireXD ServerType
  boolean binaryProtocol = false;
  boolean useSSL = false;
  if (props != null) {
    binaryProtocol = Boolean.parseBoolean(props
        .remove(ClientAttribute.THRIFT_USE_BINARY_PROTOCOL));
    useSSL = Boolean.parseBoolean(props.remove(ClientAttribute.SSL));
    // set SSL properties (csv format) into SSL params in SocketParameters
    propValue = props.remove(ClientAttribute.THRIFT_SSL_PROPERTIES);
    if (propValue != null) {
      useSSL = true;
      ThriftUtils.getSSLParameters(this.socketParams, propValue);
    }
    // parse remaining properties like socket buffer sizes, read timeout
    // and keep alive settings
    for (SocketParameters.Param p : SocketParameters.getAllParamsNoSSL()) {
      propValue = (String)props.remove(p.getPropertyName());
      if (propValue != null) {
        p.setParameter(this.socketParams, propValue);
      }
    }
  }
  this.socketParams.setServerType(ServerType.getServerType(true,
      binaryProtocol, useSSL));

  connArgs.setProperties(props);

  openConnection(hostAddr, null);
}
 
Example 6
Source File: PooledDataSource.java    From mybaties with Apache License 2.0 4 votes vote down vote up
@Override
public int getLoginTimeout() throws SQLException {
  return DriverManager.getLoginTimeout();
}
 
Example 7
Source File: UnpooledDataSource.java    From mybaties with Apache License 2.0 4 votes vote down vote up
@Override
public int getLoginTimeout() throws SQLException {
  return DriverManager.getLoginTimeout();
}
 
Example 8
Source File: ClientService.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
public ClientService(String host, int port, OpenConnectionArgs connArgs)
    throws GFXDException {
  this.isOpen = false;

  Thread currentThread = Thread.currentThread();
  connArgs.setClientHostName(hostName).setClientID(
      hostId + '|' + currentThread.getName() + "<0x"
          + Long.toHexString(currentThread.getId()) + '>');

  HostAddress hostAddr = ThriftUtils.getHostAddress(host, port);
  this.currentHostConnection = null;
  this.connArgs = connArgs;

  Map<String, String> props = connArgs.getProperties();
  String propValue;
  // default for load-balance is true
  this.loadBalance = (props == null || !"false".equalsIgnoreCase(props
      .remove(ClientAttribute.LOAD_BALANCE)));

  // setup the original host list
  if (props != null && (propValue = props.remove(
      ClientAttribute.SECONDARY_LOCATORS)) != null) {
    this.connHosts = new ArrayList<HostAddress>(4);
    this.connHosts.add(hostAddr);
    final int[] portHolder = new int[1];
    SharedUtils.splitCSV(propValue, addHostAddresses, this.connHosts,
        portHolder);
  }
  else {
    this.connHosts = Collections.singletonList(hostAddr);
  }

  // read the server groups to use for connection
  if (props != null
      && (propValue = props.remove(ClientAttribute.SERVER_GROUPS)) != null) {
    @SuppressWarnings("unchecked")
    Set<String> groupsSet = new THashSet(4);
    SharedUtils.splitCSV(propValue, SharedUtils.stringAggregator,
        groupsSet, Boolean.TRUE);
    this.serverGroups = Collections.unmodifiableSet(groupsSet);
  }
  else {
    this.serverGroups = null;
  }

  this.socketParams = new SocketParameters();
  // initialize read-timeout with DriverManager login timeout first
  int loginTimeout = DriverManager.getLoginTimeout();
  if (loginTimeout != 0) {
    SocketParameters.Param.READ_TIMEOUT.setParameter(this.socketParams,
        Integer.toString(loginTimeout));
  }
  // now check for the protocol details like SSL etc and thus get the required
  // GemFireXD ServerType
  boolean binaryProtocol = false;
  boolean useSSL = false;
  if (props != null) {
    binaryProtocol = Boolean.parseBoolean(props
        .remove(ClientAttribute.THRIFT_USE_BINARY_PROTOCOL));
    useSSL = Boolean.parseBoolean(props.remove(ClientAttribute.SSL));
    // set SSL properties (csv format) into SSL params in SocketParameters
    propValue = props.remove(ClientAttribute.THRIFT_SSL_PROPERTIES);
    if (propValue != null) {
      useSSL = true;
      ThriftUtils.getSSLParameters(this.socketParams, propValue);
    }
    // parse remaining properties like socket buffer sizes, read timeout
    // and keep alive settings
    for (SocketParameters.Param p : SocketParameters.getAllParamsNoSSL()) {
      propValue = (String)props.remove(p.getPropertyName());
      if (propValue != null) {
        p.setParameter(this.socketParams, propValue);
      }
    }
  }
  this.socketParams.setServerType(ServerType.getServerType(true,
      binaryProtocol, useSSL));

  connArgs.setProperties(props);

  openConnection(hostAddr, null);
}
 
Example 9
Source File: DbDataSource.java    From weed3 with Apache License 2.0 4 votes vote down vote up
@Override
public int getLoginTimeout() throws SQLException {
    return DriverManager.getLoginTimeout();
}
 
Example 10
Source File: SimpleDataSource.java    From vibur-dbcp with Apache License 2.0 4 votes vote down vote up
@Override
public int getLoginTimeout() throws SQLException {
    return DriverManager.getLoginTimeout();
}
 
Example 11
Source File: CassandraDataSource.java    From cassandra-jdbc-wrapper with Apache License 2.0 4 votes vote down vote up
public int getLoginTimeout()
{
    return DriverManager.getLoginTimeout();
}
 
Example 12
Source File: FBManagedConnection.java    From jaybird with GNU Lesser General Public License v2.1 4 votes vote down vote up
FBManagedConnection(FBConnectionRequestInfo cri, FBManagedConnectionFactory mcf) throws SQLException {
    this.mcf = mcf;
    this.cri = getCombinedConnectionRequestInfo(cri);
    this.tpb = mcf.getDefaultTpb();
    this.transactionIsolation = mcf.getDefaultTransactionIsolation();

    //TODO: XIDs in limbo should be loaded so that XAER_DUPID can be thrown appropriately

    DatabaseParameterBuffer dpb = this.cri.getDpb();

    if (dpb.getArgumentAsString(DatabaseParameterBuffer.LC_CTYPE) == null
            && dpb.getArgumentAsString(DatabaseParameterBufferExtension.LOCAL_ENCODING) == null) {
        String defaultEncoding = getDefaultConnectionEncoding();
        if (defaultEncoding == null) {
            throw new SQLNonTransientConnectionException(ERROR_NO_CHARSET,
                    SQLStateConstants.SQL_STATE_CONNECTION_ERROR);
        }
        dpb.addArgument(DatabaseParameterBuffer.LC_CTYPE, defaultEncoding);

        String warningMessage = WARNING_NO_CHARSET + defaultEncoding;
        log.warn(warningMessage);
        notifyWarning(new SQLWarning(warningMessage));
    }

    if (!dpb.hasArgument(DatabaseParameterBuffer.CONNECT_TIMEOUT) && DriverManager.getLoginTimeout() > 0) {
        dpb.addArgument(DatabaseParameterBuffer.CONNECT_TIMEOUT, DriverManager.getLoginTimeout());
    }

    final FbConnectionProperties connectionProperties = new FbConnectionProperties();
    connectionProperties.fromDpb(dpb);
    // TODO Move this logic to the GDSType or database factory?
    final String gdsTypeName = mcf.getGDSType().toString();
    if (!(EmbeddedGDSFactoryPlugin.EMBEDDED_TYPE_NAME.equals(gdsTypeName)
            || LocalGDSFactoryPlugin.LOCAL_TYPE_NAME.equals(gdsTypeName))) {
        final DbAttachInfo dbAttachInfo = DbAttachInfo.parseConnectString(mcf.getDatabase());
        connectionProperties.setServerName(dbAttachInfo.getServer());
        connectionProperties.setPortNumber(dbAttachInfo.getPort());
        connectionProperties.setDatabaseName(dbAttachInfo.getFileName());
    } else {
        connectionProperties.setDatabaseName(mcf.getDatabase());
    }

    database = mcf.getDatabaseFactory().connect(connectionProperties);
    database.addDatabaseListener(new MCDatabaseListener());
    database.addExceptionListener(this);
    database.attach();
    syncObject = database.getSynchronizationObject();

    gdsHelper = new GDSHelper(database);
}
 
Example 13
Source File: SimpleDataSource.java    From doma-gen with Apache License 2.0 4 votes vote down vote up
@Override
public int getLoginTimeout() {
  return DriverManager.getLoginTimeout();
}
 
Example 14
Source File: SimpleDataSource.java    From doma with Apache License 2.0 4 votes vote down vote up
@Override
public int getLoginTimeout() {
  return DriverManager.getLoginTimeout();
}
 
Example 15
Source File: PooledDataSource.java    From mybatis with Apache License 2.0 4 votes vote down vote up
@Override
public int getLoginTimeout() throws SQLException {
  return DriverManager.getLoginTimeout();
}
 
Example 16
Source File: UnpooledDataSource.java    From mybatis with Apache License 2.0 4 votes vote down vote up
@Override
public int getLoginTimeout() throws SQLException {
  return DriverManager.getLoginTimeout();
}