ElegantJCharts Java API Specification v2.0

com.elegantj.data.dataprovider.sql
Class SqlDataProvider

java.lang.Object
  |
  +--com.elegantj.data.dataprovider.AbstractDataProvider
        |
        +--com.elegantj.data.dataprovider.sql.SqlDataProvider
All Implemented Interfaces:
DataProvider, java.io.Externalizable, java.io.Serializable

public class SqlDataProvider
extends AbstractDataProvider

This class encapsulates functionality of an SQL data provider.
The basic functionality can be summarized as follows:
- Retrieves the data from the Database.
- Saves the data to the Database.
This bean provides powerful designing aspects by providing following user friendly property
DataProvider the data provider
Connection the database connection
ConnectionProperties the connection properties (url, driver, username, password)
SqlString the sql query string
AllowUpdate indicates whether the data will be updated
UpdatetableTable the updateable table name
UpdateableColumns the updateable columns
UniqueColumns the unique columns
WhereClause indicates which columns are used to build the where clause
KeyModification indicates the process to update the data
SortCriteria the criteria for sorting the data
FilterCriteria the criteria for filtering the data
FilterState indicates whether the filter criteria is applied or not
SaveOnlyFilteredData indicates to save only filtered rows or all rows
FetchSize the maximum number of rows which can be retrieved
AppendDataOnFetchNext indicates whether the next fetched data is appended or replaced to existing data
SkippedRows the total number of rows to be skipped

See Also:
Serialized Form

Field Summary
static int UNIQUE
          Indicates that use only unique columns in the where clause
static int UNIQUE_AND_MODIFIED
          Indicates that use only unique and modified columns in the where clause
static int UNIQUE_AND_UPDATEABLE
          Indicates that use only unique and updateable columns in the where clause
static int USE_DELETE_THEN_INSERT
          Indicates that update the data by deleting and inserting it
static int USE_UPDATE
          Indicates that update the data by updating
 
Fields inherited from class com.elegantj.data.dataprovider.AbstractDataProvider
c11, changes, clientTable, columnNames, currentIndex, dataTable
 
Constructor Summary
SqlDataProvider()
           
 
Method Summary
 boolean close()
          Closes the database connection and statement
 boolean executeQuery(java.lang.String sqlQuery)
          Executes the sql query
protected  void finalize()
           
 boolean getAllowUpdate()
          Returns true if the data can be updated
 java.util.Vector getColumnAttribs()
          Returns the vector containing the ColumnAttribs objects which represents the column attributes
 int getColumnIndex(java.lang.String colName)
          Returns the index of the column colName
 int getColumnType(int colIndex)
          Returns the type of the column at the specified index
 java.sql.Connection getConnection()
          Gets the connection
 com.elegantj.data.editors.ConnectionProperties getConnectionProperties()
          Gets the connection properties
 int getKeyModification()
          Gets the modification option which used to update the data
 java.lang.String getSqlString()
          Gets the sql query string
 int getTableCount()
          Returns the total number of tables
 java.util.Vector getTableNames()
          Returns the table names
 java.lang.String getUniqueColumns()
          Gets the unique columns
 java.lang.String getUpdateableColumns()
          Gets the updateable columns
 java.lang.String getUpdateableTable()
          Gets the updateable table name
 int getWhereClause()
          Gets the where clause option which used to bulid the where clause
 boolean isFetchNext()
          Determines whether fetching the next rows or not
 boolean nextData()
          If more data can be fetched, it fetches and return true, otherwise return false
 boolean open()
          Opens the database connection and creates the statement
 void readExternal(java.io.ObjectInput in)
           
 void refreshQuery()
          Refresh the sql query
 void retrieve()
          Retrives the data
 void retrieve(java.lang.String[] str)
          Retrives the data
 void save()
          Saves the transaction
 boolean saveModifications()
          Saves the modifications
 void setAllowUpdate(boolean b)
          Allows the data to be updated
 void setConnection(java.sql.Connection conn)
          Sets the connection
 void setConnectionProperties(com.elegantj.data.editors.ConnectionProperties connProp)
          Sets the connection properties url, driver, user name, password
 void setKeyModification(int key)
          Sets the modification option which used to update the data
 void setSqlString(java.lang.String str)
          Sets the sql query string
 void setUniqueColumns(java.lang.String columns)
          Sets the unique columns
 void setUniqueKeys(java.util.Vector vector)
          Deprecated.  
 void setUpdateable(java.util.Vector vector)
          Deprecated.  
 void setUpdateableColumns(java.lang.String columns)
          Sets the updateable columns
 void setUpdateableTable(java.lang.String updateTable)
          Sets the updateable table name
 void setWhereClause(int criteria)
          Sets the where clause option which used to bulid the where clause
 void writeExternal(java.io.ObjectOutput out)
          Externalizable interface implementation to save and retrieve the state of this bean
 
Methods inherited from class com.elegantj.data.dataprovider.AbstractDataProvider
addDataListener, addPropertyChangeListener, addRow, appendData, dataChanged, dataChanged, deleteRow, equals, exportToSQL, exportToSQL, exportToSQL, exportToSQL, exportToText, exportToText, exportToText, exportToText, exportToXML, exportToXML, filterData, find, find, findNext, fireDataChanged, firePropertyChange, firstRecord, getColumnCount, getColumnNames, getColumnsArray, getColumnSeparator, getColumnsWidth, getColumnTag, getComputable, getCurrentIndex, getCurrentRecord, getData, getDataAt, getDataAt, getDataCount, getDataProvider, getDeletedCount, getFetchSize, getFilterCriteria, getFilteredCount, getLicenseKey, getModifiedCount, getRootTag, getRowSeparator, getRowTag, getSkippedRows, getSortColumns, getSortCriteria, getTextQualifier, insertDataAt, isAppendDataOnFetchNext, isColumnsDelimited, isFilterState, isFirstRowAsColumnNames, isSaveOnlyFilteredData, lastRecord, modifyDataAt, nextRecord, parseInt, previousRecord, rankData, refreshData, removeAll, removeAt, removeDataListener, removePropertyChangeListener, removeRange, rollbackModifications, scrollToRow, setAppendDataOnFetchNext, setColumnsDelimited, setColumnSeparator, setColumnsWidth, setColumnTag, setData, setDataArray, setDataProvider, setFetchSize, setFilterCriteria, setFilterState, setFirstRowAsColumnNames, setLicenseKey, setRootTag, setRowSeparator, setRowTag, setSaveOnlyFilteredData, setSkippedRows, setSortCriteria, setTextQualifier, sortData, sortData, sortData, sortData, sortData, sortData, sortData, sortData, sortData
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNIQUE

public static final int UNIQUE
Indicates that use only unique columns in the where clause

See Also:
Constant Field Values

UNIQUE_AND_UPDATEABLE

public static final int UNIQUE_AND_UPDATEABLE
Indicates that use only unique and updateable columns in the where clause

See Also:
Constant Field Values

UNIQUE_AND_MODIFIED

public static final int UNIQUE_AND_MODIFIED
Indicates that use only unique and modified columns in the where clause

See Also:
Constant Field Values

USE_DELETE_THEN_INSERT

public static final int USE_DELETE_THEN_INSERT
Indicates that update the data by deleting and inserting it

See Also:
Constant Field Values

USE_UPDATE

public static final int USE_UPDATE
Indicates that update the data by updating

See Also:
Constant Field Values
Constructor Detail

SqlDataProvider

public SqlDataProvider()
Method Detail

setConnectionProperties

public void setConnectionProperties(com.elegantj.data.editors.ConnectionProperties connProp)
Sets the connection properties url, driver, user name, password

Parameters:
connProp - the ConnectionProperties object

getConnectionProperties

public com.elegantj.data.editors.ConnectionProperties getConnectionProperties()
Gets the connection properties

Returns:
the ConnectionProperties object

setConnection

public void setConnection(java.sql.Connection conn)
                   throws java.sql.SQLException
Sets the connection

Parameters:
conn - the connection
java.sql.SQLException

getConnection

public java.sql.Connection getConnection()
Gets the connection

Returns:
the connection

setSqlString

public void setSqlString(java.lang.String str)
Sets the sql query string

Parameters:
str - the query string

getSqlString

public java.lang.String getSqlString()
Gets the sql query string

Returns:
the query string

refreshQuery

public void refreshQuery()
Refresh the sql query


setWhereClause

public void setWhereClause(int criteria)
Sets the where clause option which used to bulid the where clause

Parameters:
criteria - one of the constants : UNIQUE, UNIQUE_UPDATEABLE, UNIQUE_MODIFIED

getWhereClause

public int getWhereClause()
Gets the where clause option which used to bulid the where clause

Returns:
an integer represents the where clause option

setKeyModification

public void setKeyModification(int key)
Sets the modification option which used to update the data

Parameters:
key - one of the constants : USE_DELETE_THEN_INSERT, USE_UPDATE

getKeyModification

public int getKeyModification()
Gets the modification option which used to update the data

Returns:
an integer represents the modification option

setAllowUpdate

public void setAllowUpdate(boolean b)
Allows the data to be updated

Parameters:
b - if true, the data will be updated

getAllowUpdate

public boolean getAllowUpdate()
Returns true if the data can be updated

Returns:
true if the data can be updated, otherwise false

setUpdateableTable

public void setUpdateableTable(java.lang.String updateTable)
Sets the updateable table name

Parameters:
updateTable - the name of the table which can be updated

getUpdateableTable

public java.lang.String getUpdateableTable()
Gets the updateable table name

Returns:
the name of the table which can be updated

setUpdateableColumns

public void setUpdateableColumns(java.lang.String columns)
Sets the updateable columns

Parameters:
columns - the string which contains comma separated index of the updateable columns

getUpdateableColumns

public java.lang.String getUpdateableColumns()
Gets the updateable columns

Returns:
the string which contains comma separated index of the updateable columns

setUpdateable

public void setUpdateable(java.util.Vector vector)
Deprecated.  

Sets the column's updateable


setUniqueColumns

public void setUniqueColumns(java.lang.String columns)
Sets the unique columns

Parameters:
columns - the string which contains comma separated index of the unique columns

getUniqueColumns

public java.lang.String getUniqueColumns()
Gets the unique columns

Returns:
the string which contains comma separated index of the unique columns

setUniqueKeys

public void setUniqueKeys(java.util.Vector vector)
Deprecated.  

Sets the column's unique key


executeQuery

public boolean executeQuery(java.lang.String sqlQuery)
Executes the sql query

Parameters:
sqlQuery - the sql query to be executed

finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
java.lang.Throwable

open

public boolean open()
Opens the database connection and creates the statement

Returns:
true if successfully opens the connection, otherwise false

close

public boolean close()
Closes the database connection and statement

Returns:
true if successfully closes the connection, otherwise false

getColumnAttribs

public java.util.Vector getColumnAttribs()
Returns the vector containing the ColumnAttribs objects which represents the column attributes

Returns:
the vector containing the ColumnAttribs objects

getColumnIndex

public int getColumnIndex(java.lang.String colName)
Returns the index of the column colName

Specified by:
getColumnIndex in interface DataProvider
Overrides:
getColumnIndex in class AbstractDataProvider
Parameters:
colName - the name of the column
Returns:
the index of the column

getColumnType

public int getColumnType(int colIndex)
Returns the type of the column at the specified index

Specified by:
getColumnType in interface DataProvider
Overrides:
getColumnType in class AbstractDataProvider
Parameters:
colIndex - the index of the column
Returns:
the column type

getTableCount

public int getTableCount()
Returns the total number of tables

Returns:
the total number of tables

getTableNames

public java.util.Vector getTableNames()
Returns the table names

Returns:
the vector containing the table names

retrieve

public void retrieve(java.lang.String[] str)
Retrives the data

Parameters:
str - the array of the arguments

retrieve

public void retrieve()
Retrives the data

Returns:
true if data is retrieved successfully, otherwise false

save

public void save()
Saves the transaction


saveModifications

public boolean saveModifications()
Saves the modifications

Overrides:
saveModifications in class AbstractDataProvider
Returns:
true if the saving process has been done, otherwise false

nextData

public boolean nextData()
If more data can be fetched, it fetches and return true, otherwise return false

Returns:
true, if the data has been fetched, otherwise false

isFetchNext

public boolean isFetchNext()
Determines whether fetching the next rows or not

Returns:
true if fetching the next rows

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Externalizable interface implementation to save and retrieve the state of this bean

Specified by:
writeExternal in interface java.io.Externalizable
Overrides:
writeExternal in class AbstractDataProvider
java.io.IOException

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Specified by:
readExternal in interface java.io.Externalizable
Overrides:
readExternal in class AbstractDataProvider
java.io.IOException
java.lang.ClassNotFoundException

ElegantJCharts Java API Specification v2.0

For any feedback, suggestion, or query, please revert back to support@elegantcharts.com

Copyright(c)
Elegant Microweb Technologies Pvt. Ltd.
www.elegantmicroweb.com
www.elegantjcharts.com
All Rights Reserved.