Package org.h2.engine
Class ConnectionInfo
java.lang.Object
org.h2.engine.ConnectionInfo
- All Implemented Interfaces:
Cloneable
Encapsulates the connection settings, including user name and password.
-
Constructor Summary
ConstructorDescriptionConnectionInfo
(String name) Create a connection info object.ConnectionInfo
(String u, Properties info, String user, Object password) Create a connection info object. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Clear authentication properties.clone()
byte[]
Get the file password hash if it is set.getName()
Get the unique and normalized database name (excluding settings).org.h2.util.NetworkConnectionInfo
Returns the network connection information, ornull
.Get the complete original database URL.boolean
getProperty
(String key, boolean defaultValue) Get a boolean property if it is set and return the value.getProperty
(String key, String defaultValue) Get the value of the given property.org.h2.util.TimeZoneProvider
Returns the time zone.getURL()
Get the database URL.Get the name of the user.static boolean
isIgnoredByParser
(String name) Returns whether setting with the specified name should be ignored by parser.boolean
Check if the referenced database is persistent.boolean
isRemote()
Check if this is a remote connection.boolean
removeProperty
(String key, boolean defaultValue) Remove a boolean property if it is set and return the value.void
setBaseDir
(String dir) Set the base directory of persistent databases, unless the database is in the user home folder (~).void
setFileEncryptionKey
(byte[] key) void
setFilePasswordHash
(byte[] hash) Set the file password hash.void
setNetworkConnectionInfo
(org.h2.util.NetworkConnectionInfo networkConnectionInfo) Sets the network connection information.void
setOriginalURL
(String url) Set the original database URL.void
setProperty
(String key, String value) Overwrite a property.void
setServerKey
(String serverKey) Switch to server mode, and set the server name and database key.void
setUserName
(String name) Overwrite the user name.void
setUserPasswordHash
(byte[] hash) Set the user password hash.
-
Constructor Details
-
ConnectionInfo
Create a connection info object.- Parameters:
name
- the database name (including tags), but without the "jdbc:h2:" prefix
-
ConnectionInfo
Create a connection info object.- Parameters:
u
- the database URL (must start with jdbc:h2:)info
- the connection properties ornull
user
- the user name ornull
password
- the password asString
orchar[]
, ornull
-
-
Method Details
-
isIgnoredByParser
Returns whether setting with the specified name should be ignored by parser.- Parameters:
name
- the name of the setting- Returns:
- whether setting with the specified name should be ignored by parser
-
clone
- Overrides:
clone
in classObject
- Throws:
CloneNotSupportedException
-
setBaseDir
Set the base directory of persistent databases, unless the database is in the user home folder (~).- Parameters:
dir
- the new base directory
-
isRemote
public boolean isRemote()Check if this is a remote connection.- Returns:
- true if it is
-
isPersistent
public boolean isPersistent()Check if the referenced database is persistent.- Returns:
- true if it is
-
getProperty
Get a boolean property if it is set and return the value.- Parameters:
key
- the property namedefaultValue
- the default value- Returns:
- the value
-
removeProperty
Remove a boolean property if it is set and return the value.- Parameters:
key
- the property namedefaultValue
- the default value- Returns:
- the value
-
getName
Get the unique and normalized database name (excluding settings).- Returns:
- the database name
-
getFilePasswordHash
public byte[] getFilePasswordHash()Get the file password hash if it is set.- Returns:
- the password hash or null
-
getUserName
Get the name of the user.- Returns:
- the user name
-
getProperty
Get the value of the given property.- Parameters:
key
- the property keydefaultValue
- the default value- Returns:
- the value as a String
-
setUserName
Overwrite the user name. The user name is case-insensitive and stored in uppercase. English conversion is used.- Parameters:
name
- the user name
-
setUserPasswordHash
public void setUserPasswordHash(byte[] hash) Set the user password hash.- Parameters:
hash
- the new hash value
-
setFilePasswordHash
public void setFilePasswordHash(byte[] hash) Set the file password hash.- Parameters:
hash
- the new hash value
-
setFileEncryptionKey
public void setFileEncryptionKey(byte[] key) -
setProperty
Overwrite a property.- Parameters:
key
- the property namevalue
- the value
-
getURL
Get the database URL.- Returns:
- the URL
-
getOriginalURL
Get the complete original database URL.- Returns:
- the database URL
-
setOriginalURL
Set the original database URL.- Parameters:
url
- the database url
-
getTimeZone
public org.h2.util.TimeZoneProvider getTimeZone()Returns the time zone.- Returns:
- the time zone
-
setServerKey
Switch to server mode, and set the server name and database key.- Parameters:
serverKey
- the server name, '/', and the security key
-
getNetworkConnectionInfo
public org.h2.util.NetworkConnectionInfo getNetworkConnectionInfo()Returns the network connection information, ornull
.- Returns:
- the network connection information, or
null
-
setNetworkConnectionInfo
public void setNetworkConnectionInfo(org.h2.util.NetworkConnectionInfo networkConnectionInfo) Sets the network connection information.- Parameters:
networkConnectionInfo
- the network connection information
-
getDbSettings
-
cleanAuthenticationInfo
public void cleanAuthenticationInfo()Clear authentication properties.
-