APIdia Launch Partner
Top Fields Constructors Methods
net.ucanaccess.jdbc

public Class UcanaccessDataSource

extends Object
implements Serializable, Referenceable, DataSource
Class Inheritance
All Implemented Interfaces
javax.sql.DataSource, java.sql.Wrapper, javax.sql.CommonDataSource, javax.naming.Referenceable, java.io.Serializable
Annotations
@SuppressWarnings:PMD.UnnecessaryFullyQualifiedName, serial
Static Imports
net.ucanaccess.converters.Metadata.Property.*

Field Summary

Modifier and TypeField and Description
private String
private int
private transient PrintWriter
private final Map<Metadata.Property, String>
private static final long
private final Map<Metadata.Property, String>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public String
public String
public Boolean
public Connection

Returns:

java.sql.Connection object
getConnection
()

Implements javax.sql.DataSource.getConnection.

Opens the connection to the Access database.

public Connection

Returns:

database connection
getConnection
(String
user name
user
,
String
password
pass
)

Implements javax.sql.DataSource.getConnection.

Opens the connection to the Access database using the provided user name and password.

public Boolean
getEncrypt()

See setEncrypt(Boolean) for details.

public Boolean
public Boolean
public Integer
public String
public String
public Integer
public int
getLoginTimeout()

Implements javax.sql.DataSource.getLoginTimeout.

Gets the maximum time in seconds that this data source can wait while attempting to connect to a database.

public PrintWriter
getLogWriter()

Implements javax.sql.DataSource.getLogWriter.

Retrieves the log writer for this DataSource object.

public Boolean
getMemory()

See setMemory(Boolean) for details.

public String
public String
public Boolean
public java.util.logging.Logger
getParentLogger()

Implements javax.sql.CommonDataSource.getParentLogger.

Return the parent Logger of all the Loggers used by this data source.

public Boolean
private Boolean
private Integer
private String
public Reference
getReference()

Implements javax.naming.Referenceable.getReference.

Retrieves the Reference of this object.

public String
getReMap()

See setReMap(String) for details.

public Boolean
public Boolean
public Boolean
public String
public boolean
isWrapperFor(Class<?> iface)

Implements java.sql.Wrapper.isWrapperFor.

Returns true if this either implements the interface argument or is directly or indirectly a wrapper for an object that does.

public void
setAccessPath(String
path
accessPath
)

Specifies the path to the Access database file.

public void
setColumnOrder(String
Valid values for this parameter are: "DATA", or "DISPLAY".
value
)

Controls the order in which columns are returned by operations like SELECT *.

public void
setConcatNulls(Boolean
  • false (the default): null & 'thing' returns 'thing'
  • true: null & 'thing' returns null
value
)

Controls what is returned by concatenations involving null values.

public void
setEncrypt(Boolean
Setting this value to true tells UCanAccess to encrypt the HSQLDB backing database.
value
)

Encrypts the backing database.

public void
setIgnoreCase(Boolean
(default = true)
value
)

Enables case-insensitive string comparisons.

public void
setImmediatelyReleaseResources(Boolean
Setting this value to true tells UCanAccess to close the Access database file, shut down HSQLDB, and release all related resources (e.g., memory or disk space) as soon as the Connection is closed. Otherwise, UCanAccess will "hold on" to those resources for the setInactivityTimeout(Integer) in case the Access database gets re-opened.
value
)

Releases the Access database and shuts down HSQLDB immediately after the Connection is closed.

public void
setInactivityTimeout(Integer
(in minutes)
value
)

For an in-memory backing database (memory=true), this parameter controls the time (in minutes, default=2), that HSQLDB remains active and the in-memory database remains available after the last connection is closed.

public void
setJackcessOpener(String
name of custom class
value
)

Specifies the name of the custom class to be used by Jackcess when opening the Access database.

public void
setKeepMirror(String
path
value
)

Specifies the path where a persistent copy of the HSQLDB backing database files should be stored.

public void
setLobScale(Integer
Values allowed are 1, 2, 4, 8, 16, or 32 (the unit is kB). Default is 2 if memory=true, and 32 (the HSQLDB default) otherwise.
value
)

Controls the allocation unit size for "OLE Object" (i.e., BLOB) data in the HSQLDB backing database.

public void
setLoginTimeout(int value)

Implements javax.sql.DataSource.setLoginTimeout.

Sets the maximum time in seconds that this data source will wait while attempting to connect to a database.

public void
setLogWriter(PrintWriter logWriter)

Implements javax.sql.DataSource.setLogWriter.

Sets the log writer for this DataSource object to the given java.io.PrintWriter object.

public void
setMemory(Boolean
Create the backing database in memory (value=true, the default) or on disk (value=false). Creating the backing database on disk will be slower, but it can greatly reduce JVM memory usage.
value
)

Controls whether the HSQLDB backing database is created in memory (the default) or on disk.

public void
setMirrorFolder(String
value
value
)

Specifies the path where the temporary HSQLDB backing database files should be stored.

public void
setNewDatabaseVersion(String
database versions, valid values are defined in enum AccessVersion ("V2000", "V2003", "V2007" etc.).
version
)

Creates a new, empty Access database in the specified format if the database specified by setAccessPath(String) does not exist.

public void
public void
setOpenExclusive(Boolean
Setting this value to true tells UCanAccess to open the Access database as "exclusive" (preventing other processes from opening it at the same time).
value
)

Opens the Access database in "exclusive" mode.

public void
setPassword(String password)

public void
setPreventReloading(Boolean
Setting this value to true prevents UCanAccess from unnecessarily re-loading the backing database under very specific circumstances.
value
)

Prevents unnecessary re-loading of backing database under very specific circumstances.

private void
public void
setReMap(String
value
value
)

For this connection, temporarily re-directs linked tables in the Access database to point to a different Access database.

public void
setShowSchema(Boolean
(default = false)
value
)

Exposes the HSQLDB catalog and schema names (e.g., "PUBLIC") in DatabaseMetadata.

public void
setSkipIndexes(Boolean
Setting this value to true tells UCanAccess to skip the creation of simple indexes (not associated with a constraint). It doesn't have an effect on referential integrity constraints (i.e., Index Unique, Foreign Key or Primary Key).
value
)

Reduces memory consumption by not creating simple indexes in the backing database.

public void
setSysSchema(Boolean
(default = false)
value
)

Exposes the Access system tables in a read-only schema named "SYS".

public void
public <T> T
unwrap(Class<T> iface)

Implements java.sql.Wrapper.unwrap.

Returns an object that implements the given interface to allow access to non-standard methods, or standard methods not exposed by the proxy.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

accessPathback to summary
private String accessPath
loginTimeoutback to summary
private int loginTimeout
logWriterback to summary
private transient PrintWriter logWriter
propsback to summary
private final Map<Metadata.Property, String> props
serialVersionUIDback to summary
private static final long serialVersionUID
userPassback to summary
private final Map<Metadata.Property, String> userPass

Constructor Detail

UcanaccessDataSourceback to summary
public UcanaccessDataSource()

Method Detail

getAccessPathback to summary
public String getAccessPath()

See setAccessPath(String) for details.

getColumnOrderback to summary
public String getColumnOrder()

See setColumnOrder(String) for details.

getConcatNullsback to summary
public Boolean getConcatNulls()

See setConcatNulls(Boolean) for details.

getConnectionback to summary
public Connection getConnection() throws SQLException

Implements javax.sql.DataSource.getConnection.

Opens the connection to the Access database.

Returns:Connection

java.sql.Connection object

Annotations
@Override
Exceptions
SQLException:

Doc from javax.sql.DataSource.getConnection.

if a database access error occurs

getConnectionback to summary
public Connection getConnection(String user, String pass) throws SQLException

Implements javax.sql.DataSource.getConnection.

Opens the connection to the Access database using the provided user name and password.

Parameters
user:String

user name

pass:String

password

Returns:Connection

database connection

Annotations
@Override
Exceptions
SQLException:

Doc from javax.sql.DataSource.getConnection.

if a database access error occurs

getEncryptback to summary
public Boolean getEncrypt()

See setEncrypt(Boolean) for details.

getIgnoreCaseback to summary
public Boolean getIgnoreCase()

See setIgnoreCase(Boolean) for details.

getImmediatelyReleaseResourcesback to summary
public Boolean getImmediatelyReleaseResources()

See setImmediatelyReleaseResources(Boolean) for details.

getInactivityTimeoutback to summary
public Integer getInactivityTimeout()

See setInactivityTimeout(Integer) for details.

getJackcessOpenerback to summary
public String getJackcessOpener()

See setJackcessOpener(String) for details.

getKeepMirrorback to summary
public String getKeepMirror()

See setKeepMirror(String) for details.

getLobScaleback to summary
public Integer getLobScale()

See setLobScale(Integer) for details.

getLoginTimeoutback to summary
public int getLoginTimeout()

Implements javax.sql.DataSource.getLoginTimeout.

Doc from javax.sql.DataSource.getLoginTimeout.

Gets the maximum time in seconds that this data source can wait while attempting to connect to a database. A value of zero means that the timeout is the default system timeout if there is one; otherwise, it means that there is no timeout. When a DataSource object is created, the login timeout is initially zero.

Annotations
@Override
getLogWriterback to summary
public PrintWriter getLogWriter()

Implements javax.sql.DataSource.getLogWriter.

Doc from javax.sql.DataSource.getLogWriter.

Retrieves the log writer for this DataSource object.

The log writer is a character output stream to which all logging and tracing messages for this data source will be printed. This includes messages printed by the methods of this object, messages printed by methods of other objects manufactured by this object, and so on. Messages printed to a data source specific log writer are not printed to the log writer associated with the java.sql.DriverManager class. When a DataSource object is created, the log writer is initially null; in other words, the default is for logging to be disabled.

Annotations
@Override
getMemoryback to summary
public Boolean getMemory()

See setMemory(Boolean) for details.

getMirrorFolderback to summary
public String getMirrorFolder()

See setMirrorFolder(String) for details.

getNewDatabaseVersionback to summary
public String getNewDatabaseVersion()

See setNewDatabaseVersion(String) for details.

getOpenExclusiveback to summary
public Boolean getOpenExclusive()

See setOpenExclusive(Boolean) for details.

getParentLoggerback to summary
public java.util.logging.Logger getParentLogger() throws SQLFeatureNotSupportedException

Implements javax.sql.CommonDataSource.getParentLogger.

Doc from javax.sql.CommonDataSource.getParentLogger.

Return the parent Logger of all the Loggers used by this data source. This should be the Logger farthest from the root Logger that is still an ancestor of all of the Loggers used by this data source. Configuring this Logger will affect all of the log messages generated by the data source. In the worst case, this may be the root Logger.

Annotations
@Override
Exceptions
SQLFeatureNotSupportedException:
if the data source does not use java.util.logging
getPreventReloadingback to summary
public Boolean getPreventReloading()

See setPreventReloading(Boolean) for details.

getPropAsBooleanback to summary
private Boolean getPropAsBoolean(Metadata.Property key)
getPropAsIntegerback to summary
private Integer getPropAsInteger(Metadata.Property key)
getPropAsStringback to summary
private String getPropAsString(Metadata.Property key)
getReferenceback to summary
public Reference getReference()

Implements javax.naming.Referenceable.getReference.

Doc from javax.naming.Referenceable.getReference.

Retrieves the Reference of this object.

Annotations
@Override
getReMapback to summary
public String getReMap()

See setReMap(String) for details.

getShowSchemaback to summary
public Boolean getShowSchema()

See setShowSchema(Boolean) for details.

getSkipIndexesback to summary
public Boolean getSkipIndexes()

See setSkipIndexes(Boolean) for details.

getSysSchemaback to summary
public Boolean getSysSchema()

See setSysSchema(Boolean) for details.

getUserback to summary
public String getUser()
isWrapperForback to summary
public boolean isWrapperFor(Class<?> iface)

Implements java.sql.Wrapper.isWrapperFor.

Doc from java.sql.Wrapper.isWrapperFor.

Returns true if this either implements the interface argument or is directly or indirectly a wrapper for an object that does. Returns false otherwise. If this implements the interface then return true, else if this is a wrapper then return the result of recursively calling isWrapperFor on the wrapped object. If this does not implement the interface and is not a wrapper, return false. This method should be implemented as a low-cost operation compared to unwrap so that callers can use this method to avoid expensive unwrap calls that may fail. If this method returns true then calling unwrap with the same argument should succeed.

Annotations
@Override
setAccessPathback to summary
public void setAccessPath(String accessPath)

Specifies the path to the Access database file.

For example: C:/folder/database.accdb

Parameters
accessPath:String

path

setColumnOrderback to summary
public void setColumnOrder(String value)

Controls the order in which columns are returned by operations like SELECT *. The default is "DATA". See the UCanAccess website for details.

Parameters
value:String

Valid values for this parameter are: "DATA", or "DISPLAY".

Since
2.0.9
setConcatNullsback to summary
public void setConcatNulls(Boolean value)

Controls what is returned by concatenations involving null values. This setting affects all concatenation operators (&, +, ||).

Parameters
value:Boolean

  • false (the default): null & 'thing' returns 'thing'
  • true: null & 'thing' returns null
Since
3.0.0
setEncryptback to summary
public void setEncrypt(Boolean value)

Encrypts the backing database.

Parameters
value:Boolean

Setting this value to true tells UCanAccess to encrypt the HSQLDB backing database.

Since
1.0.4
setIgnoreCaseback to summary
public void setIgnoreCase(Boolean value)

Enables case-insensitive string comparisons.

Parameters
value:Boolean

(default = true)

setImmediatelyReleaseResourcesback to summary
public void setImmediatelyReleaseResources(Boolean value)

Releases the Access database and shuts down HSQLDB immediately after the Connection is closed.

Parameters
value:Boolean

Setting this value to true tells UCanAccess to close the Access database file, shut down HSQLDB, and release all related resources (e.g., memory or disk space) as soon as the Connection is closed. Otherwise, UCanAccess will "hold on" to those resources for the setInactivityTimeout(Integer) in case the Access database gets re-opened.

setInactivityTimeoutback to summary
public void setInactivityTimeout(Integer value)

For an in-memory backing database (memory=true), this parameter controls the time (in minutes, default=2), that HSQLDB remains active and the in-memory database remains available after the last connection is closed.

Parameters
value:Integer

(in minutes)

Since
0.1.1
setJackcessOpenerback to summary
public void setJackcessOpener(String value)

Specifies the name of the custom class to be used by Jackcess when opening the Access database. Mainly for use with Jackcess Encrypt to open encrypted databases. See the UCanAccess website for details.

Parameters
value:String

name of custom class

Since
0.0.2
setKeepMirrorback to summary
public void setKeepMirror(String value)

Specifies the path where a persistent copy of the HSQLDB backing database files should be stored. Implies memory=false. See the UCanAccess website for details.

Parameters
value:String

path

Since
2.0.2
setLobScaleback to summary
public void setLobScale(Integer value)

Controls the allocation unit size for "OLE Object" (i.e., BLOB) data in the HSQLDB backing database. See the UCanAccess website for details.

Parameters
value:Integer

Values allowed are 1, 2, 4, 8, 16, or 32 (the unit is kB). Default is 2 if memory=true, and 32 (the HSQLDB default) otherwise.

Since
2.0.9.4
setLoginTimeoutback to summary
public void setLoginTimeout(int value)

Implements javax.sql.DataSource.setLoginTimeout.

Doc from javax.sql.DataSource.setLoginTimeout.

Sets the maximum time in seconds that this data source will wait while attempting to connect to a database. A value of zero specifies that the timeout is the default system timeout if there is one; otherwise, it specifies that there is no timeout. When a DataSource object is created, the login timeout is initially zero.

Annotations
@Override
setLogWriterback to summary
public void setLogWriter(PrintWriter logWriter)

Implements javax.sql.DataSource.setLogWriter.

Doc from javax.sql.DataSource.setLogWriter.

Sets the log writer for this DataSource object to the given java.io.PrintWriter object.

The log writer is a character output stream to which all logging and tracing messages for this data source will be printed. This includes messages printed by the methods of this object, messages printed by methods of other objects manufactured by this object, and so on. Messages printed to a data source- specific log writer are not printed to the log writer associated with the java.sql.DriverManager class. When a DataSource object is created the log writer is initially null; in other words, the default is for logging to be disabled.

Annotations
@Override
setMemoryback to summary
public void setMemory(Boolean value)

Controls whether the HSQLDB backing database is created in memory (the default) or on disk.

Parameters
value:Boolean

Create the backing database in memory (value=true, the default) or on disk (value=false). Creating the backing database on disk will be slower, but it can greatly reduce JVM memory usage.

setMirrorFolderback to summary
public void setMirrorFolder(String value)

Specifies the path where the temporary HSQLDB backing database files should be stored. Implies memory=false. To create a persistent copy of the backing database, use setKeepMirror(String) instead. See the UCanAccess website for details.

Parameters
value:String

value

Since
2.0.9.3
setNewDatabaseVersionback to summary
public void setNewDatabaseVersion(String version)

Creates a new, empty Access database in the specified format if the database specified by setAccessPath(String) does not exist.

Parameters
version:String

database versions, valid values are defined in enum AccessVersion ("V2000", "V2003", "V2007" etc.).

setNewDatabaseVersionback to summary
public void setNewDatabaseVersion(AccessVersion version)
setOpenExclusiveback to summary
public void setOpenExclusive(Boolean value)

Opens the Access database in "exclusive" mode.

Parameters
value:Boolean

Setting this value to true tells UCanAccess to open the Access database as "exclusive" (preventing other processes from opening it at the same time).

setPasswordback to summary
public void setPassword(String password)
setPreventReloadingback to summary
public void setPreventReloading(Boolean value)

Prevents unnecessary re-loading of backing database under very specific circumstances.
USE WITH CAUTION! See the UCanAccess website for details.

Parameters
value:Boolean

Setting this value to true prevents UCanAccess from unnecessarily re-loading the backing database under very specific circumstances.

Since
3.0.0
setPropback to summary
private void setProp(Metadata.Property key, Object value)
setReMapback to summary
public void setReMap(String value)

For this connection, temporarily re-directs linked tables in the Access database to point to a different Access database. See the UCanAccess website for details.

Parameters
value:String

value

Since
2.0.2
setShowSchemaback to summary
public void setShowSchema(Boolean value)

Exposes the HSQLDB catalog and schema names (e.g., "PUBLIC") in DatabaseMetadata.

Parameters
value:Boolean

(default = false)

setSkipIndexesback to summary
public void setSkipIndexes(Boolean value)

Reduces memory consumption by not creating simple indexes in the backing database.

Parameters
value:Boolean

Setting this value to true tells UCanAccess to skip the creation of simple indexes (not associated with a constraint). It doesn't have an effect on referential integrity constraints (i.e., Index Unique, Foreign Key or Primary Key).

Since
2.0.9.4
setSysSchemaback to summary
public void setSysSchema(Boolean value)

Exposes the Access system tables in a read-only schema named "SYS".

Parameters
value:Boolean

(default = false)

setUserback to summary
public void setUser(String user)
unwrapback to summary
public <T> T unwrap(Class<T> iface)

Implements java.sql.Wrapper.unwrap.

Doc from java.sql.Wrapper.unwrap.

Returns an object that implements the given interface to allow access to non-standard methods, or standard methods not exposed by the proxy. If the receiver implements the interface then the result is the receiver or a proxy for the receiver. If the receiver is a wrapper and the wrapped object implements the interface then the result is the wrapped object or a proxy for the wrapped object. Otherwise return the the result of calling unwrap recursively on the wrapped object or a proxy for that result. If the receiver is not a wrapper and does not implement the interface, then an SQLException is thrown.

Annotations
@Override