org.pentaho.platform.plugin.services.connections.sql
Class SQLConnection

java.lang.Object
  extended by org.pentaho.platform.plugin.services.connections.sql.SQLConnection
All Implemented Interfaces:
IPentahoLoggingConnection

public class SQLConnection
extends Object
implements IPentahoLoggingConnection

Author:
wseyler TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates

Field Summary
static int CONCUR_READONLY
           
static int CONCUR_UPDATABLE
           
static int RESULTSET_FORWARDONLY
           
static int RESULTSET_SCROLLABLE
           
 
Constructor Summary
SQLConnection()
           
SQLConnection(String driverName, String location, String userName, String password, ILogger logger)
           
 
Method Summary
 void clearWarnings()
           
 void close()
           
 boolean connect(Properties props)
           
 int execute(String query)
           
 int execute(String query, int scrollType, int concur)
           
 IPentahoResultSet executeQuery(String query)
          Executes the specified query.
 IPentahoResultSet executeQuery(String query, int scrollType, int concur)
          Executes the specified query with the defined parameters
 String getDatasourceType()
          return datasource type SQL
 int getFetchSize()
           
 String getLastQuery()
           
 int getMaxRows()
           
 Connection getNativeConnection()
           
 int getQueryTimeout()
          Returns the query timeout value (in seconds)
 boolean getReadOnly()
          Returns the state of the readonly flag
 IPentahoResultSet getResultSet()
           
 boolean initialized()
           
 boolean isClosed()
           
 boolean isFallBackToNonscrollableOnError()
           
 boolean isForcedForwardOnly()
           
 boolean isReadOnly()
           
 IPentahoResultSet prepareAndExecuteQuery(String query, List parameters)
           
 IPentahoResultSet prepareAndExecuteQuery(String query, List parameters, int scrollType, int concur)
           
 boolean preparedQueriesSupported()
           
 void setFallBackToNonscrollableOnError(boolean fallBackToNonscrollableOnError)
           
 void setFetchSize(int fetchSize)
           
 void setForcedForwardOnly(boolean forcedForwardOnly)
           
 void setLogger(ILogger logger)
           
 void setMaxRows(int maxRows)
           
 void setProperties(Properties props)
           
 void setQueryTimeout(int timeInSec)
          Sets the valid of the timeout (in seconds)
 void setReadOnly(boolean value)
          Sets the connection object to readonly.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RESULTSET_SCROLLABLE

public static final int RESULTSET_SCROLLABLE
See Also:
Constant Field Values

RESULTSET_FORWARDONLY

public static final int RESULTSET_FORWARDONLY
See Also:
Constant Field Values

CONCUR_READONLY

public static final int CONCUR_READONLY
See Also:
Constant Field Values

CONCUR_UPDATABLE

public static final int CONCUR_UPDATABLE
See Also:
Constant Field Values
Constructor Detail

SQLConnection

public SQLConnection()

SQLConnection

public SQLConnection(String driverName,
                     String location,
                     String userName,
                     String password,
                     ILogger logger)
Method Detail

setLogger

public void setLogger(ILogger logger)
Specified by:
setLogger in interface IPentahoLoggingConnection

setProperties

public void setProperties(Properties props)

setQueryTimeout

public void setQueryTimeout(int timeInSec)
Sets the valid of the timeout (in seconds)


setReadOnly

public void setReadOnly(boolean value)
Sets the connection object to readonly.

Parameters:
value -

getQueryTimeout

public int getQueryTimeout()
Returns the query timeout value (in seconds)


initialized

public boolean initialized()

getDatasourceType

public String getDatasourceType()
return datasource type SQL

Returns:
datasource type

close

public void close()

getLastQuery

public String getLastQuery()

executeQuery

public IPentahoResultSet executeQuery(String query)
                               throws SQLException,
                                      InterruptedException,
                                      PentahoSystemException
Executes the specified query.

Parameters:
query - the query to execute
Returns:
the resultset from the query
Throws:
SQLException - indicates an error running the query
InterruptedException - indicates that the query took longer than the allowed timeout value
PentahoSystemException

executeQuery

public IPentahoResultSet executeQuery(String query,
                                      int scrollType,
                                      int concur)
                               throws SQLException,
                                      InterruptedException,
                                      PentahoSystemException
Executes the specified query with the defined parameters

Parameters:
query - the query to be executed
scrollType -
concur -
Returns:
the result set of data for the query
Throws:
SQLException - indicates an error running the query
InterruptedException - indicates the query took longer than allowable by the query timeout
PentahoSystemException

prepareAndExecuteQuery

public IPentahoResultSet prepareAndExecuteQuery(String query,
                                                List parameters)
                                         throws SQLException
Throws:
SQLException

prepareAndExecuteQuery

public IPentahoResultSet prepareAndExecuteQuery(String query,
                                                List parameters,
                                                int scrollType,
                                                int concur)
                                         throws SQLException
Throws:
SQLException

preparedQueriesSupported

public boolean preparedQueriesSupported()

isClosed

public boolean isClosed()

isReadOnly

public boolean isReadOnly()

clearWarnings

public void clearWarnings()

getResultSet

public IPentahoResultSet getResultSet()

connect

public boolean connect(Properties props)

execute

public int execute(String query)
            throws SQLException
Throws:
SQLException

execute

public int execute(String query,
                   int scrollType,
                   int concur)
            throws SQLException
Throws:
SQLException

getNativeConnection

public Connection getNativeConnection()
Returns:
Returns the nativeConnection.

getFetchSize

public int getFetchSize()
Returns:
Returns the fetchSize.

setFetchSize

public void setFetchSize(int fetchSize)
Parameters:
fetchSize - The fetchSize to set.

getMaxRows

public int getMaxRows()
Returns:
Returns the maxRows.

setMaxRows

public void setMaxRows(int maxRows)
Parameters:
maxRows - The maxRows to set.

getReadOnly

public boolean getReadOnly()
Returns the state of the readonly flag

Returns:
true if the connection is set to readonly

setFallBackToNonscrollableOnError

public void setFallBackToNonscrollableOnError(boolean fallBackToNonscrollableOnError)

isFallBackToNonscrollableOnError

public boolean isFallBackToNonscrollableOnError()

isForcedForwardOnly

public boolean isForcedForwardOnly()

setForcedForwardOnly

public void setForcedForwardOnly(boolean forcedForwardOnly)