- java.lang.Object
-
- org.tentackle.sql.BackendInfo
-
public class BackendInfo extends java.lang.ObjectConfiguration info for a backend.- Author:
- harald
-
-
Constructor Summary
Constructors Constructor Description BackendInfo(java.lang.String backendName)Creates a backend info from a backend name.
The info cannot be used to connect.BackendInfo(java.lang.String url, java.lang.String user, char[] password, java.lang.String[] schemas)Creates a backend info.
This info is able to create a connection.BackendInfo(java.util.Properties backendProperties)Creates a backend info from backend properties.
The info is able to create a connection.BackendInfo(Backend backend)Creates a backend info from a backend.
The info cannot be used to connect.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearPassword()Clears all passwords (stored in char[]-arrays) so that they are no more visible in memory.java.sql.Connectionconnect()Creates a connection.BackendgetBackend()Gets the backend.javax.sql.DataSourcegetJndiDataSource()Gets the JNDI source.char[]getPassword()Gets the connection password.java.lang.String[]getSchemas()Gets the schemas.java.lang.StringgetUrl()Gets the connection url.java.lang.StringgetUser()Gets the username to connect.booleanisConnectable()Returns whether backend info can be used to connect.booleanisRemote()Returns whether this backend is remote.java.lang.StringtoString()
-
-
-
Constructor Detail
-
BackendInfo
public BackendInfo(Backend backend)
Creates a backend info from a backend.
The info cannot be used to connect.- Parameters:
backend- the backend
-
BackendInfo
public BackendInfo(java.lang.String backendName)
Creates a backend info from a backend name.
The info cannot be used to connect.- Parameters:
backendName- the backend name
-
BackendInfo
public BackendInfo(java.lang.String url, java.lang.String user, char[] password, java.lang.String[] schemas)Creates a backend info.
This info is able to create a connection.- Parameters:
url- the backend urluser- the usernamepassword- the passwordschemas- the optional schemas, null if no schema check
-
BackendInfo
public BackendInfo(java.util.Properties backendProperties)
Creates a backend info from backend properties.
The info is able to create a connection.- Parameters:
backendProperties- the properties
-
-
Method Detail
-
getBackend
public Backend getBackend()
Gets the backend.- Returns:
- the backend
-
isRemote
public boolean isRemote()
Returns whether this backend is remote.- Returns:
- true if remote
-
getJndiDataSource
public javax.sql.DataSource getJndiDataSource()
Gets the JNDI source.- Returns:
- the JNDI datasource if this a JNDI connection
-
getUrl
public java.lang.String getUrl()
Gets the connection url.- Returns:
- the url, null if info cannot connect
-
getUser
public java.lang.String getUser()
Gets the username to connect.- Returns:
- the username
-
getPassword
public char[] getPassword()
Gets the connection password.- Returns:
- the password
-
clearPassword
public void clearPassword()
Clears all passwords (stored in char[]-arrays) so that they are no more visible in memory.
-
getSchemas
public java.lang.String[] getSchemas()
Gets the schemas.- Returns:
- the schemas for migration
-
isConnectable
public boolean isConnectable()
Returns whether backend info can be used to connect.- Returns:
- true if connectable
-
connect
public java.sql.Connection connect() throws java.sql.SQLExceptionCreates a connection.- Returns:
- the connection in autocommit mode
- Throws:
java.sql.SQLException- if connection could not be created
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-