Top Description Fields Constructors Methods
org.h2.engine

public Class ConnectionInfo

extends Object
implements Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable
Imports
java.io.File, .IOException, java.util.Arrays, .HashMap, .HashSet, .Properties, org.h2.api.ErrorCode, org.h2.command.dml.SetTypes, org.h2.message.DbException, org.h2.security.SHA256, org.h2.store.fs.FileUtils, org.h2.store.fs.encrypt.FilePathEncrypt, org.h2.store.fs.rec.FilePathRec, org.h2.util.IOUtils, .NetworkConnectionInfo, .SortedProperties, .StringUtils, .TimeZoneProvider, .Utils

Encapsulates the connection settings, including user name and password.

Field Summary

Modifier and TypeField and Description
private byte[]
private byte[]
private static final HashSet<String>
private static final HashSet<String>
private String
name

The database name

private String
private NetworkConnectionInfo
private String
private boolean
private Properties
private boolean
private boolean
private TimeZoneProvider
private boolean
private String
private String
private byte[]

Constructor Summary

AccessConstructor and Description
public
ConnectionInfo(String
the database name (including tags), but without the "jdbc:h2:" prefix
name
)

Create a connection info object.

public
ConnectionInfo(String
the database URL (must start with jdbc:h2:)
u
,
Properties
the connection properties or null
info
,
String
the user name or null
user
,
Object
the password as String or char[], or null
password
)

Create a connection info object.

Method Summary

Modifier and TypeMethod and Description
public void
cleanAuthenticationInfo()

Clear authentication properties.

public ConnectionInfo
clone()

Overrides java.lang.Object.clone.

Creates and returns a copy of this object.

private void
convertPasswords()

Split the password property into file password and user password if necessary, and convert them to the internal hash format.

public DbSettings
pack-priv byte[]
public byte[]

Returns:

the password hash or null
getFilePasswordHash
()

Get the file password hash if it is set.

pack-priv DbException

Returns:

the exception
getFormatException
()

Generate a URL format exception.

pack-priv int

Returns:

the value as an integer
getIntProperty
(int
the setting id
setting
,
int
the default value
defaultValue
)

Get the value of the given property.

pack-priv String[]

Returns:

the property keys
getKeys
()

Get the property keys.

public String

Returns:

the database name
getName
()

Get the unique and normalized database name (excluding settings).

public NetworkConnectionInfo

Returns:

the network connection information, or null
getNetworkConnectionInfo
()

Returns the network connection information, or null.

public String

Returns:

the database URL
getOriginalURL
()

Get the complete original database URL.

public boolean

Returns:

the value
getProperty
(String
the property name
key
,
boolean
the default value
defaultValue
)

Get a boolean property if it is set and return the value.

pack-priv String

Returns:

the value as a String
getProperty
(String
the property key
key
)

Get the value of the given property.

pack-priv int

Returns:

the value as a String
getProperty
(String
the property key
key
,
int
the default value
defaultValue
)

Get the value of the given property.

public String

Returns:

the value as a String
getProperty
(String
the property key
key
,
String
the default value
defaultValue
)

Get the value of the given property.

pack-priv String

Returns:

the value as a String
getProperty
(int
the setting id
setting
,
String
the default value
defaultValue
)

Get the value of the given property.

public TimeZoneProvider

Returns:

the time zone
getTimeZone
()

Returns the time zone.

public String

Returns:

the URL
getURL
()

Get the database URL.

public String

Returns:

the user name
getUserName
()

Get the name of the user.

pack-priv byte[]

Returns:

the password hash
getUserPasswordHash
()

Get the user password hash.

private static byte[]
hashPassword(boolean passwordHash, String userName, char[] password)

public static boolean

Returns:

whether setting with the specified name should be ignored by parser
isIgnoredByParser
(String
the name of the setting
name
)

Returns whether setting with the specified name should be ignored by parser.

private static boolean
public boolean

Returns:

true if it is
isPersistent
()

Check if the referenced database is persistent.

public boolean

Returns:

true if it is
isRemote
()

Check if this is a remote connection.

pack-priv boolean

Returns:

true if it is
isSSL
()

Check if this is a remote connection with SSL enabled.

pack-priv boolean

Returns:

true if it is
isUnnamedInMemory
()

Check if the referenced database is an unnamed in-memory database.

private void
private void
private void
private void
private static String
private char[]
public boolean

Returns:

the value
removeProperty
(String
the property name
key
,
boolean
the default value
defaultValue
)

Remove a boolean property if it is set and return the value.

pack-priv String

Returns:

the value
removeProperty
(String
the property name
key
,
String
the default value
defaultValue
)

Remove a String property if it is set and return the value.

public void
setBaseDir(String
the new base directory
dir
)

Set the base directory of persistent databases, unless the database is in the user home folder (~).

public void
public void
setFilePasswordHash(byte[]
the new hash value
hash
)

Set the file password hash.

public void
setNetworkConnectionInfo(NetworkConnectionInfo
the network connection information
networkConnectionInfo
)

Sets the network connection information.

public void
setOriginalURL(String
the database url
url
)

Set the original database URL.

public void
setProperty(String
the property name
key
,
String
the value
value
)

Overwrite a property.

public void
setServerKey(String
the server name, '/', and the security key
serverKey
)

Switch to server mode, and set the server name and database key.

public void
setUserName(String
the user name
name
)

Overwrite the user name.

public void
setUserPasswordHash(byte[]
the new hash value
hash
)

Set the user password hash.

Inherited from java.lang.Object:
equalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

fileEncryptionKeyback to summary
private byte[] fileEncryptionKey
filePasswordHashback to summary
private byte[] filePasswordHash
IGNORED_BY_PARSERback to summary
private static final HashSet<String> IGNORED_BY_PARSER
KNOWN_SETTINGSback to summary
private static final HashSet<String> KNOWN_SETTINGS
nameback to summary
private String name

The database name

nameNormalizedback to summary
private String nameNormalized
networkConnectionInfoback to summary
private NetworkConnectionInfo networkConnectionInfo
originalURLback to summary
private String originalURL
persistentback to summary
private boolean persistent
propback to summary
private Properties prop
remoteback to summary
private boolean remote
sslback to summary
private boolean ssl
timeZoneback to summary
private TimeZoneProvider timeZone
unnamedback to summary
private boolean unnamed
urlback to summary
private String url
userback to summary
private String user
userPasswordHashback to summary
private byte[] userPasswordHash

Constructor Detail

ConnectionInfoback to summary
public ConnectionInfo(String name)

Create a connection info object.

Parameters
name:String

the database name (including tags), but without the "jdbc:h2:" prefix

ConnectionInfoback to summary
public ConnectionInfo(String u, Properties info, String user, Object password)

Create a connection info object.

Parameters
u:String

the database URL (must start with jdbc:h2:)

info:Properties

the connection properties or null

user:String

the user name or null

password:Object

the password as String or char[], or null

Method Detail

cleanAuthenticationInfoback to summary
public void cleanAuthenticationInfo()

Clear authentication properties.

cloneback to summary
public ConnectionInfo clone() throws CloneNotSupportedException

Overrides java.lang.Object.clone.

Doc from java.lang.Object.clone.

Creates and returns a copy of this object. The precise meaning of "copy" may depend on the class of the object. The general intent is that, for any object x, the expression:

x.clone() != x
will be true, and that the expression:
x.clone().getClass() == x.getClass()
will be true, but these are not absolute requirements. While it is typically the case that:
x.clone().equals(x)
will be true, this is not an absolute requirement.

By convention, the returned object should be obtained by calling super.clone. If a class and all of its superclasses (except Object) obey this convention, it will be the case that x.clone().getClass() == x.getClass().

By convention, the object returned by this method should be independent of this object (which is being cloned). To achieve this independence, it may be necessary to modify one or more fields of the object returned by super.clone before returning it. Typically, this means copying any mutable objects that comprise the internal "deep structure" of the object being cloned and replacing the references to these objects with references to the copies. If a class contains only primitive fields or references to immutable objects, then it is usually the case that no fields in the object returned by super.clone need to be modified.

Returns:ConnectionInfo

a clone of this instance.

Annotations
@Override
Exceptions
CloneNotSupportedException:
if the object's class does not support the Cloneable interface. Subclasses that override the clone method can also throw this exception to indicate that an instance cannot be cloned.
convertPasswordsback to summary
private void convertPasswords()

Split the password property into file password and user password if necessary, and convert them to the internal hash format.

getDbSettingsback to summary
public DbSettings getDbSettings()
getFileEncryptionKeyback to summary
pack-priv byte[] getFileEncryptionKey()
getFilePasswordHashback to summary
public byte[] getFilePasswordHash()

Get the file password hash if it is set.

Returns:byte[]

the password hash or null

getFormatExceptionback to summary
pack-priv DbException getFormatException()

Generate a URL format exception.

Returns:DbException

the exception

getIntPropertyback to summary
pack-priv int getIntProperty(int setting, int defaultValue)

Get the value of the given property.

Parameters
setting:int

the setting id

defaultValue:int

the default value

Returns:int

the value as an integer

getKeysback to summary
pack-priv String[] getKeys()

Get the property keys.

Returns:String[]

the property keys

getNameback to summary
public String getName()

Get the unique and normalized database name (excluding settings).

Returns:String

the database name

getNetworkConnectionInfoback to summary
public NetworkConnectionInfo getNetworkConnectionInfo()

Returns the network connection information, or null.

Returns:NetworkConnectionInfo

the network connection information, or null

getOriginalURLback to summary
public String getOriginalURL()

Get the complete original database URL.

Returns:String

the database URL

getPropertyback to summary
public boolean getProperty(String key, boolean defaultValue)

Get a boolean property if it is set and return the value.

Parameters
key:String

the property name

defaultValue:boolean

the default value

Returns:boolean

the value

getPropertyback to summary
pack-priv String getProperty(String key)

Get the value of the given property.

Parameters
key:String

the property key

Returns:String

the value as a String

getPropertyback to summary
pack-priv int getProperty(String key, int defaultValue)

Get the value of the given property.

Parameters
key:String

the property key

defaultValue:int

the default value

Returns:int

the value as a String

getPropertyback to summary
public String getProperty(String key, String defaultValue)

Get the value of the given property.

Parameters
key:String

the property key

defaultValue:String

the default value

Returns:String

the value as a String

getPropertyback to summary
pack-priv String getProperty(int setting, String defaultValue)

Get the value of the given property.

Parameters
setting:int

the setting id

defaultValue:String

the default value

Returns:String

the value as a String

getTimeZoneback to summary
public TimeZoneProvider getTimeZone()

Returns the time zone.

Returns:TimeZoneProvider

the time zone

getURLback to summary
public String getURL()

Get the database URL.

Returns:String

the URL

getUserNameback to summary
public String getUserName()

Get the name of the user.

Returns:String

the user name

getUserPasswordHashback to summary
pack-priv byte[] getUserPasswordHash()

Get the user password hash.

Returns:byte[]

the password hash

hashPasswordback to summary
private static byte[] hashPassword(boolean passwordHash, String userName, char[] password)
isIgnoredByParserback to summary
public static boolean isIgnoredByParser(String name)

Returns whether setting with the specified name should be ignored by parser.

Parameters
name:String

the name of the setting

Returns:boolean

whether setting with the specified name should be ignored by parser

isKnownSettingback to summary
private static boolean isKnownSetting(String s)
isPersistentback to summary
public boolean isPersistent()

Check if the referenced database is persistent.

Returns:boolean

true if it is

isRemoteback to summary
public boolean isRemote()

Check if this is a remote connection.

Returns:boolean

true if it is

isSSLback to summary
pack-priv boolean isSSL()

Check if this is a remote connection with SSL enabled.

Returns:boolean

true if it is

isUnnamedInMemoryback to summary
pack-priv boolean isUnnamedInMemory()

Check if the referenced database is an unnamed in-memory database.

Returns:boolean

true if it is

parseNameback to summary
private void parseName()
preservePasswordForAuthenticationback to summary
private void preservePasswordForAuthentication(Object password)
readPropertiesback to summary
private void readProperties(Properties info)
readSettingsFromURLback to summary
private void readSettingsFromURL()
remapURLback to summary
private static String remapURL(String url)
removePasswordback to summary
private char[] removePassword()
removePropertyback to summary
public boolean removeProperty(String key, boolean defaultValue)

Remove a boolean property if it is set and return the value.

Parameters
key:String

the property name

defaultValue:boolean

the default value

Returns:boolean

the value

removePropertyback to summary
pack-priv String removeProperty(String key, String defaultValue)

Remove a String property if it is set and return the value.

Parameters
key:String

the property name

defaultValue:String

the default value

Returns:String

the value

setBaseDirback to summary
public void setBaseDir(String dir)

Set the base directory of persistent databases, unless the database is in the user home folder (~).

Parameters
dir:String

the new base directory

setFileEncryptionKeyback to summary
public void setFileEncryptionKey(byte[] key)
setFilePasswordHashback to summary
public void setFilePasswordHash(byte[] hash)

Set the file password hash.

Parameters
hash:byte[]

the new hash value

setNetworkConnectionInfoback to summary
public void setNetworkConnectionInfo(NetworkConnectionInfo networkConnectionInfo)

Sets the network connection information.

Parameters
networkConnectionInfo:NetworkConnectionInfo

the network connection information

setOriginalURLback to summary
public void setOriginalURL(String url)

Set the original database URL.

Parameters
url:String

the database url

setPropertyback to summary
public void setProperty(String key, String value)

Overwrite a property.

Parameters
key:String

the property name

value:String

the value

setServerKeyback to summary
public void setServerKey(String serverKey)

Switch to server mode, and set the server name and database key.

Parameters
serverKey:String

the server name, '/', and the security key

setUserNameback to summary
public void setUserName(String name)

Overwrite the user name. The user name is case-insensitive and stored in uppercase. English conversion is used.

Parameters
name:String

the user name

setUserPasswordHashback to summary
public void setUserPasswordHash(byte[] hash)

Set the user password hash.

Parameters
hash:byte[]

the new hash value