Class ConnectionInfo
java.lang.Object
org.h2.engine.ConnectionInfo
- All Implemented Interfaces:
Cloneable
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate byte[]private byte[]private StringThe database nameprivate Stringprivate NetworkConnectionInfoprivate Stringprivate booleanprivate Propertiesprivate booleanprivate booleanprivate TimeZoneProviderprivate booleanprivate Stringprivate Stringprivate byte[] -
Constructor Summary
ConstructorsConstructorDescriptionConnectionInfo(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 TypeMethodDescriptionvoidClear authentication properties.clone()private voidSplit the password property into file password and user password if necessary, and convert them to the internal hash format.(package private) byte[]byte[]Get the file password hash if it is set.(package private) DbExceptionGenerate a URL format exception.(package private) intgetIntProperty(int setting, int defaultValue) Get the value of the given property.(package private) String[]getKeys()Get the property keys.getName()Get the unique and normalized database name (excluding settings).Returns the network connection information, ornull.Get the complete original database URL.(package private) StringgetProperty(int setting, String defaultValue) Get the value of the given property.(package private) StringgetProperty(String key) Get the value of the given property.booleangetProperty(String key, boolean defaultValue) Get a boolean property if it is set and return the value.(package private) intgetProperty(String key, int defaultValue) Get the value of the given property.getProperty(String key, String defaultValue) Get the value of the given property.Returns the time zone.getURL()Get the database URL.Get the name of the user.(package private) byte[]Get the user password hash.private static byte[]hashPassword(boolean passwordHash, String userName, char[] password) static booleanisIgnoredByParser(String name) Returns whether setting with the specified name should be ignored by parser.private static booleanbooleanCheck if the referenced database is persistent.booleanisRemote()Check if this is a remote connection.(package private) booleanisSSL()Check if this is a remote connection with SSL enabled.(package private) booleanCheck if the referenced database is an unnamed in-memory database.private voidprivate voidpreservePasswordForAuthentication(Object password) private voidreadProperties(Properties info) private voidprivate static Stringprivate char[]booleanremoveProperty(String key, boolean defaultValue) Remove a boolean property if it is set and return the value.(package private) StringremoveProperty(String key, String defaultValue) Remove a String property if it is set and return the value.voidsetBaseDir(String dir) Set the base directory of persistent databases, unless the database is in the user home folder (~).voidsetFileEncryptionKey(byte[] key) voidsetFilePasswordHash(byte[] hash) Set the file password hash.voidsetNetworkConnectionInfo(NetworkConnectionInfo networkConnectionInfo) Sets the network connection information.voidsetOriginalURL(String url) Set the original database URL.voidsetProperty(String key, String value) Overwrite a property.voidsetServerKey(String serverKey) Switch to server mode, and set the server name and database key.voidsetUserName(String name) Overwrite the user name.voidsetUserPasswordHash(byte[] hash) Set the user password hash.
-
Field Details
-
KNOWN_SETTINGS
-
IGNORED_BY_PARSER
-
prop
-
originalURL
-
url
-
user
-
filePasswordHash
private byte[] filePasswordHash -
fileEncryptionKey
private byte[] fileEncryptionKey -
userPasswordHash
private byte[] userPasswordHash -
timeZone
-
name
The database name -
nameNormalized
-
remote
private boolean remote -
ssl
private boolean ssl -
persistent
private boolean persistent -
unnamed
private boolean unnamed -
networkConnectionInfo
-
-
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 ornulluser- the user name ornullpassword- the password asStringorchar[], ornull
-
-
Method Details
-
isKnownSetting
-
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:
clonein classObject- Throws:
CloneNotSupportedException
-
parseName
private void parseName() -
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
-
isUnnamedInMemory
boolean isUnnamedInMemory()Check if the referenced database is an unnamed in-memory database.- Returns:
- true if it is
-
readProperties
-
readSettingsFromURL
private void readSettingsFromURL() -
preservePasswordForAuthentication
-
removePassword
private char[] removePassword() -
convertPasswords
private void convertPasswords()Split the password property into file password and user password if necessary, and convert them to the internal hash format. -
hashPassword
-
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
-
removeProperty
-
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
-
getFileEncryptionKey
byte[] getFileEncryptionKey() -
getUserName
-
getUserPasswordHash
byte[] getUserPasswordHash()Get the user password hash.- Returns:
- the password hash
-
getKeys
-
getProperty
-
getProperty
Get the value of the given property.- Parameters:
key- the property keydefaultValue- the default value- Returns:
- the value as a String
-
getProperty
-
getProperty
-
getIntProperty
int getIntProperty(int setting, int defaultValue) Get the value of the given property.- Parameters:
setting- the setting iddefaultValue- the default value- Returns:
- the value as an integer
-
isSSL
boolean isSSL()Check if this is a remote connection with SSL enabled.- Returns:
- true if it is
-
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
-
getURL
-
getOriginalURL
-
setOriginalURL
Set the original database URL.- Parameters:
url- the database url
-
getTimeZone
-
getFormatException
-
setServerKey
Switch to server mode, and set the server name and database key.- Parameters:
serverKey- the server name, '/', and the security key
-
getNetworkConnectionInfo
Returns the network connection information, ornull.- Returns:
- the network connection information, or
null
-
setNetworkConnectionInfo
Sets the network connection information.- Parameters:
networkConnectionInfo- the network connection information
-
getDbSettings
-
remapURL
-
cleanAuthenticationInfo
public void cleanAuthenticationInfo()Clear authentication properties.
-