下面列出了java.sql.DriverManager#getLoginTimeout ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
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);
}
});
}
}
private void loadDefaults()
{
if (_loginTimeout == -1)
{
_loginTimeout = DriverManager.getLoginTimeout();
}
}
@Override
public int getLoginTimeout() {
return DriverManager.getLoginTimeout();
}
public int getLoginTimeout() throws SQLException {
return DriverManager.getLoginTimeout();
}
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);
}
@Override
public int getLoginTimeout() throws SQLException {
return DriverManager.getLoginTimeout();
}
@Override
public int getLoginTimeout() throws SQLException {
return DriverManager.getLoginTimeout();
}
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);
}
@Override
public int getLoginTimeout() throws SQLException {
return DriverManager.getLoginTimeout();
}
@Override
public int getLoginTimeout() throws SQLException {
return DriverManager.getLoginTimeout();
}
public int getLoginTimeout()
{
return DriverManager.getLoginTimeout();
}
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);
}
@Override
public int getLoginTimeout() {
return DriverManager.getLoginTimeout();
}
@Override
public int getLoginTimeout() {
return DriverManager.getLoginTimeout();
}
@Override
public int getLoginTimeout() throws SQLException {
return DriverManager.getLoginTimeout();
}
@Override
public int getLoginTimeout() throws SQLException {
return DriverManager.getLoginTimeout();
}