org.caleigo.core.service
Class JDBCDataService

java.lang.Object
  extended byorg.caleigo.core.AbstractDataService
      extended byorg.caleigo.core.service.JDBCDataService
All Implemented Interfaces:
IDataService, IDistributable, ISecureService, IService, java.io.Serializable
Direct Known Subclasses:
DemoDataService

public class JDBCDataService
extends AbstractDataService

Version:
1.00
Author:
Dennis Zikovic
See Also:
Serialized Form

Nested Class Summary
protected  class JDBCDataService.ConnectionPool
           
protected  class JDBCDataService.JDBCDataTransaction
           
 
Nested classes inherited from class org.caleigo.core.AbstractDataService
AbstractDataService.AbstractDataTransaction
 
Field Summary
static int DEFAULT_MAX_CONNECTION_POOL_SIZE
           
 
Fields inherited from class org.caleigo.core.AbstractDataService
DEFAULT_TIMEOUT
 
Constructor Summary
JDBCDataService(IDataSourceDescriptor descriptor)
          Default constructor for JDBCDataService.
JDBCDataService(IDataSourceDescriptor descriptor, java.lang.Object serviceIdentity, java.lang.String url)
           
JDBCDataService(IDataSourceDescriptor descriptor, java.lang.Object serviceIdentity, java.lang.String url, java.util.Properties info, int maxConnectionPoolSize)
           
JDBCDataService(IDataSourceDescriptor descriptor, java.lang.Object serviceIdentity, java.lang.String url, java.lang.String user, java.lang.String password)
           
JDBCDataService(IDataSourceDescriptor descriptor, java.lang.Object serviceIdentity, java.lang.String url, java.lang.String user, java.lang.String password, int maxConnectionPoolSize)
           
JDBCDataService(IDataSourceDescriptor descriptor, java.lang.Object serviceIdentity, java.lang.String url, java.lang.String user, java.lang.String password, java.lang.String catalog)
           
 
Method Summary
protected  void closeConnection(java.sql.Connection connection)
           
protected  void executeCreateRelation(java.sql.Connection connection, IEntityRelation entityRelation)
           
protected  void executeCreateTable(java.sql.Connection connection, IEntityDescriptor entityDescriptor)
           
protected  void executeDelete(java.sql.Connection connection, IEntity entity)
           
protected  void executeInsert(java.sql.Connection connection, IEntity entity)
           
protected  void executeLoad(java.sql.Connection connection, IEntity entity, Qualifier qualifier)
           
protected  void executeQuery(java.sql.Connection connection, DataQuery query, ISelection selection)
           
protected  void executeUpdate(java.sql.Connection connection, IEntity entity, Qualifier qualifier)
           
 java.lang.String getPassword()
           
protected  java.lang.Object getSetData(java.sql.ResultSet set, int index, DataType dataType)
           
 SQLToolKit getSQLToolKit()
           
 java.lang.String getURL()
           
 java.lang.String getUser()
           
protected  boolean hasAutoIndexField(IEntityDescriptor entityDescriptor)
           
 IDataTransaction newTransaction()
          Returns a new IDataTransaction object that can be used to batch data operations and wrap them in a transaction.
protected  java.sql.Connection openConnection()
           
 boolean ping()
          Should return true if the service is online and reponding to calls.
protected  void readResultSetRow(java.sql.ResultSet set, IEntity entity, boolean useFastSetData)
           
 void setCalculateQuerySize(boolean calculateSize)
          Sets if this data service should calculate the size of a quary before the query result data is proccessed.
static void setDriver(java.sql.Driver driver)
           
 void setMaxConnectionPoolSize(int maxConnectionPoolSize)
          Changes the size of the connection pool.
 void setSQLToolKit(SQLToolKit kit)
           
protected  void updateAutoIndex(java.sql.Statement statement, IEntity entity)
          This method updates autogenerated primary key field values.
 
Methods inherited from class org.caleigo.core.AbstractDataService
checkEntityAsDeletable, checkEntityAsStorable, delete, finalizeService, getCustomProxyService, getDataSourceDescriptor, getServiceIdentity, getServiceInterface, getServiceInterfaceClass, getServiceType, getTimeout, hasCustomProxyService, initializeService, isValidating, load, loadSelection, loadSelection, refresh, setEntityData, setTimeout, setValidating, store
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_MAX_CONNECTION_POOL_SIZE

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

JDBCDataService

public JDBCDataService(IDataSourceDescriptor descriptor)
Default constructor for JDBCDataService.


JDBCDataService

public JDBCDataService(IDataSourceDescriptor descriptor,
                       java.lang.Object serviceIdentity,
                       java.lang.String url)

JDBCDataService

public JDBCDataService(IDataSourceDescriptor descriptor,
                       java.lang.Object serviceIdentity,
                       java.lang.String url,
                       java.lang.String user,
                       java.lang.String password)

JDBCDataService

public JDBCDataService(IDataSourceDescriptor descriptor,
                       java.lang.Object serviceIdentity,
                       java.lang.String url,
                       java.lang.String user,
                       java.lang.String password,
                       int maxConnectionPoolSize)

JDBCDataService

public JDBCDataService(IDataSourceDescriptor descriptor,
                       java.lang.Object serviceIdentity,
                       java.lang.String url,
                       java.lang.String user,
                       java.lang.String password,
                       java.lang.String catalog)

JDBCDataService

public JDBCDataService(IDataSourceDescriptor descriptor,
                       java.lang.Object serviceIdentity,
                       java.lang.String url,
                       java.util.Properties info,
                       int maxConnectionPoolSize)
Method Detail

setDriver

public static void setDriver(java.sql.Driver driver)

newTransaction

public IDataTransaction newTransaction()
Description copied from interface: IDataService
Returns a new IDataTransaction object that can be used to batch data operations and wrap them in a transaction.

Specified by:
newTransaction in interface IDataService
Specified by:
newTransaction in class AbstractDataService

ping

public boolean ping()
Should return true if the service is online and reponding to calls.

Specified by:
ping in interface IService
Specified by:
ping in class AbstractDataService

executeLoad

protected void executeLoad(java.sql.Connection connection,
                           IEntity entity,
                           Qualifier qualifier)
                    throws DataServiceException
Throws:
DataServiceException

executeQuery

protected void executeQuery(java.sql.Connection connection,
                            DataQuery query,
                            ISelection selection)
                     throws DataServiceException
Throws:
DataServiceException

executeInsert

protected void executeInsert(java.sql.Connection connection,
                             IEntity entity)
                      throws DataServiceException
Throws:
DataServiceException

executeUpdate

protected void executeUpdate(java.sql.Connection connection,
                             IEntity entity,
                             Qualifier qualifier)
                      throws DataServiceException
Throws:
DataServiceException

executeDelete

protected void executeDelete(java.sql.Connection connection,
                             IEntity entity)
                      throws DataServiceException
Throws:
DataServiceException

executeCreateTable

protected void executeCreateTable(java.sql.Connection connection,
                                  IEntityDescriptor entityDescriptor)
                           throws DataServiceException
Throws:
DataServiceException

executeCreateRelation

protected void executeCreateRelation(java.sql.Connection connection,
                                     IEntityRelation entityRelation)
                              throws DataServiceException
Throws:
DataServiceException

getURL

public java.lang.String getURL()

getUser

public java.lang.String getUser()

getPassword

public java.lang.String getPassword()

getSQLToolKit

public SQLToolKit getSQLToolKit()

setSQLToolKit

public void setSQLToolKit(SQLToolKit kit)

setMaxConnectionPoolSize

public void setMaxConnectionPoolSize(int maxConnectionPoolSize)
Changes the size of the connection pool.

Parameters:
maxConnectionPoolSize -
Throws:
java.lang.IllegalStateException - if there are open connections in the connection pool.

setCalculateQuerySize

public void setCalculateQuerySize(boolean calculateSize)

Sets if this data service should calculate the size of a quary before the query result data is proccessed. This is used for calculating the progress of a query. Invoking this mehtod with true means that each query will be executed two times in the database. Depending on the jdbc driver implementation this could have a great impact on performance.

By default no query sizes are calculated.


openConnection

protected java.sql.Connection openConnection()
                                      throws DataServiceException
Throws:
DataServiceException

closeConnection

protected void closeConnection(java.sql.Connection connection)
                        throws DataServiceException
Throws:
DataServiceException

readResultSetRow

protected void readResultSetRow(java.sql.ResultSet set,
                                IEntity entity,
                                boolean useFastSetData)
                         throws DataServiceException
Throws:
DataServiceException

getSetData

protected java.lang.Object getSetData(java.sql.ResultSet set,
                                      int index,
                                      DataType dataType)

updateAutoIndex

protected void updateAutoIndex(java.sql.Statement statement,
                               IEntity entity)
                        throws DataServiceException
This method updates autogenerated primary key field values. Note that this method can only be used directly after a insert and should still not be considered safe in an environment with frequent inserts to the entity's table.

Throws:
DataServiceException

hasAutoIndexField

protected boolean hasAutoIndexField(IEntityDescriptor entityDescriptor)


Copyright © 2005 Caleigo. All Rights Reserved.