类 HostInfo
- java.lang.Object
-
- com.mysql.cj.conf.HostInfo
-
- 所有已实现的接口:
DatabaseUrlContainer
public class HostInfo extends Object implements DatabaseUrlContainer
This class holds the following MySQL host information:- host: an IP or host name.
- port: the port number or 0 if not known.
- user: the user name.
- password: the password.
- host properties: host specific connection arguments.
-
-
字段概要
字段 修饰符和类型 字段 说明 static intNO_PORT
-
构造器概要
构造器 构造器 说明 HostInfo()Constructs an emptyHostInfoinstance.HostInfo(DatabaseUrlContainer url, String host, int port, String user, String password)Constructs aHostInfoinstance initialized with the provided host, port and user info.HostInfo(DatabaseUrlContainer url, String host, int port, String user, String password, Map<String,String> properties)Constructs aHostInfoinstance initialized with the provided host, port, user, password and connection arguments.
-
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 booleanequalHostPortPair(HostInfo hi)PropertiesexposeAsProperties()Exposes this host info as a single properties instance.StringgetDatabase()Shortcut to the database connection argument.StringgetDatabaseUrl()Returns the original database URL that produced this host info.StringgetHost()Returns the host.StringgetHostPortPair()Returns a host:port representation of this host.Map<String,String>getHostProperties()Returns the properties specific to this host.StringgetPassword()Returns the password.intgetPort()Returns the port.StringgetProperty(String key)Returns the connection argument for the given key.StringgetUser()Returns the user name.StringtoString()Returns a string representation of this object.
-
-
-
字段详细资料
-
NO_PORT
public static final int NO_PORT
- 另请参阅:
- 常量字段值
-
-
构造器详细资料
-
HostInfo
public HostInfo()
Constructs an emptyHostInfoinstance.
-
HostInfo
public HostInfo(DatabaseUrlContainer url, String host, int port, String user, String password)
Constructs aHostInfoinstance initialized with the provided host, port and user info.- 参数:
url- a reference to the original database URL that produced this host infohost- the host ip or nameport- the portuser- the user namepassword- the user's password
-
HostInfo
public HostInfo(DatabaseUrlContainer url, String host, int port, String user, String password, Map<String,String> properties)
Constructs aHostInfoinstance initialized with the provided host, port, user, password and connection arguments.- 参数:
url- a reference to the original database URL that produced this host infohost- the host ip or nameport- the portuser- the user namepassword- this user's passwordproperties- a connection arguments map.
-
-
方法详细资料
-
getHost
public String getHost()
Returns the host.- 返回:
- the host
-
getPort
public int getPort()
Returns the port.- 返回:
- the port
-
getHostPortPair
public String getHostPortPair()
Returns a host:port representation of this host.- 返回:
- the host:port representation of this host
-
getUser
public String getUser()
Returns the user name.- 返回:
- the user name
-
getPassword
public String getPassword()
Returns the password.- 返回:
- the password
-
getHostProperties
public Map<String,String> getHostProperties()
Returns the properties specific to this host.- 返回:
- this host specific properties
-
getProperty
public String getProperty(String key)
Returns the connection argument for the given key.- 参数:
key- key- 返回:
- the connection argument for the given key
-
getDatabase
public String getDatabase()
Shortcut to the database connection argument.- 返回:
- the database name
-
exposeAsProperties
public Properties exposeAsProperties()
Exposes this host info as a single properties instance. The values for host, port, user and password are added to the properties map with their standard keys.- 返回:
- a
Propertiesinstance containing the full host information.
-
getDatabaseUrl
public String getDatabaseUrl()
Returns the original database URL that produced this host info.- 指定者:
getDatabaseUrl在接口中DatabaseUrlContainer- 返回:
- the original database URL
-
equalHostPortPair
public boolean equalHostPortPair(HostInfo hi)
- 参数:
hi- theHostInfoto compare with.- 返回:
trueif both objects have equal host and port pairs,falseotherwise.
-
-