Package org.pentaho.commons.connection
Interface IPentahoConnection
-
public interface IPentahoConnectionA PentahoConnection represents metadata and functions required to execute queries against data sources. It also contains constants that are properties in data components SQLLookupRule and MDXLookupRule.- Author:
- wseyler
- See Also:
SQLLookupRule,MDXLookupRule
-
-
Field Summary
Fields Modifier and Type Field Description static StringCLASSNAME_KEYSetting for class name used to look up a connection in the pentaho.xml.static StringCONNECTIONStandard key to use for a connection property.static StringCONNECTION_NAMEStandard key to use for a connection's name property.static StringDRIVER_KEYDefines the XML element in the component-definition that holds the JDBC driver.static StringHQL_DATASOURCEstatic StringJNDI_NAME_KEYDefines the XML element in the component-definition that holds the JNDI (Java Naming and Directory Interface) name for the database connection.static String[]KEYSArray of the XML element keys defined above.static StringLOCATION_KEYDefines the XML element in the component-definition that holds the JDBC URL.static StringMDX_DATASOURCEstatic StringMDX_OLAP4J_DATASOURCEstatic intNONE_DATASOURCEstatic StringPASSWORD_KEYDefines the XML element in the component-definition that holds the password used to connect to the JDBC driver.static StringPROVIDERStandard key to use for a provider property.static StringQUERY_KEYDefines the XML element in the component-definition that holds the database query (e.g.static StringSQL_DATASOURCEstatic StringUSERNAME_KEYDefines the XML element in the component-definition that holds the user name used to connect to the JDBC driver.static StringXML_DATASOURCE
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidclearWarnings()Clears any warnings cached by the connection.voidclose()Closes the connection.booleanconnect(Properties props)Connects to the data source using the supplied properties.IPentahoResultSetexecuteQuery(String query)Executes the specified query against the connection.StringgetDatasourceType()Returns the connection type.StringgetLastQuery()Retrieves the string representation of the last executed query.IPentahoResultSetgetResultSet()Returns resultset of the last executed query.booleaninitialized()Checks if the connection is initialized or not.booleanisClosed()Checks if the connection is closed or not.booleanisReadOnly()Checks if the connection is read only or not.IPentahoResultSetprepareAndExecuteQuery(String query, List parameters)Builds the query based on the pattern and parameters list and executes it against the connection.booleanpreparedQueriesSupported()Checks if the given connection supports prepared queries.voidsetFetchSize(int fetchSize)Sets size of the fetch buffer used when retrieving rows from the underlying database.voidsetMaxRows(int maxRows)Sets maximum rows that will be returned by the next query.voidsetProperties(Properties props)Sets the properties to be used when the connection is made.
-
-
-
Field Detail
-
NONE_DATASOURCE
static final int NONE_DATASOURCE
- See Also:
- Constant Field Values
-
SQL_DATASOURCE
static final String SQL_DATASOURCE
- See Also:
- Constant Field Values
-
MDX_DATASOURCE
static final String MDX_DATASOURCE
- See Also:
- Constant Field Values
-
MDX_OLAP4J_DATASOURCE
static final String MDX_OLAP4J_DATASOURCE
- See Also:
- Constant Field Values
-
XML_DATASOURCE
static final String XML_DATASOURCE
- See Also:
- Constant Field Values
-
HQL_DATASOURCE
static final String HQL_DATASOURCE
- See Also:
- Constant Field Values
-
CLASSNAME_KEY
static final String CLASSNAME_KEY
Setting for class name used to look up a connection in the pentaho.xml.- See Also:
- Constant Field Values
-
JNDI_NAME_KEY
static final String JNDI_NAME_KEY
Defines the XML element in the component-definition that holds the JNDI (Java Naming and Directory Interface) name for the database connection.- See Also:
- Constant Field Values
-
DRIVER_KEY
static final String DRIVER_KEY
Defines the XML element in the component-definition that holds the JDBC driver.- See Also:
- Constant Field Values
-
LOCATION_KEY
static final String LOCATION_KEY
Defines the XML element in the component-definition that holds the JDBC URL.- See Also:
- Constant Field Values
-
USERNAME_KEY
static final String USERNAME_KEY
Defines the XML element in the component-definition that holds the user name used to connect to the JDBC driver.- See Also:
- Constant Field Values
-
PASSWORD_KEY
static final String PASSWORD_KEY
Defines the XML element in the component-definition that holds the password used to connect to the JDBC driver.- See Also:
- Constant Field Values
-
QUERY_KEY
static final String QUERY_KEY
Defines the XML element in the component-definition that holds the database query (e.g. MDX, SQL).- See Also:
- Constant Field Values
-
CONNECTION
static final String CONNECTION
Standard key to use for a connection property.- See Also:
- Constant Field Values
-
CONNECTION_NAME
static final String CONNECTION_NAME
Standard key to use for a connection's name property.- See Also:
- Constant Field Values
-
PROVIDER
static final String PROVIDER
Standard key to use for a provider property.- See Also:
- Constant Field Values
-
KEYS
static final String[] KEYS
Array of the XML element keys defined above.
-
-
Method Detail
-
setProperties
void setProperties(Properties props)
Sets the properties to be used when the connection is made. The standard keys for the properties are defined in this interface.- Parameters:
props- Properties to be used when the connection is made.
-
close
void close()
Closes the connection.
-
getLastQuery
String getLastQuery()
Retrieves the string representation of the last executed query.- Returns:
- Returns the last query string executed.
-
executeQuery
IPentahoResultSet executeQuery(String query) throws Exception
Executes the specified query against the connection.- Parameters:
query- SQL-like query string. May be data source specific.- Returns:
- Returns the result set of the query.
- Throws:
Exception
-
prepareAndExecuteQuery
IPentahoResultSet prepareAndExecuteQuery(String query, List parameters) throws Exception
Builds the query based on the pattern and parameters list and executes it against the connection.- Parameters:
query- SQL-like query string. May be data source specific.parameters- List of objects to bind into prepared query.- Returns:
- Returns result set of the query.
- Throws:
Exception
-
preparedQueriesSupported
boolean preparedQueriesSupported()
Checks if the given connection supports prepared queries.- Returns:
- Returns true if the connection supports prepared queries.
-
getResultSet
IPentahoResultSet getResultSet()
Returns resultset of the last executed query.- Returns:
- Returns the resultset from the last query executed.
-
isClosed
boolean isClosed()
Checks if the connection is closed or not.- Returns:
- Returns true if this connection has been closed.
-
isReadOnly
boolean isReadOnly()
Checks if the connection is read only or not.- Returns:
- true if this connection is read only. NOTE: Current implementation for all connections is read only.
-
clearWarnings
void clearWarnings()
Clears any warnings cached by the connection.
-
connect
boolean connect(Properties props)
Connects to the data source using the supplied properties.- Parameters:
props- Data source connection properties.- Returns:
- Returns true if the connection was successful.
-
setMaxRows
void setMaxRows(int maxRows)
Sets maximum rows that will be returned by the next query.- Parameters:
maxRows- Maximum rows that are returned by the next query.
-
setFetchSize
void setFetchSize(int fetchSize)
Sets size of the fetch buffer used when retrieving rows from the underlying database.- Parameters:
fetchSize- The size of the buffer.
-
initialized
boolean initialized()
Checks if the connection is initialized or not.- Returns:
- Return true if the connection has been properly initialized.
-
getDatasourceType
String getDatasourceType()
Returns the connection type.- Returns:
- Returns the type of the connection.
-
-