com.sas.storage.jdbc
Class JDBCToComboBoxModelAdapter

com.sas.storage.jdbc.JDBCToComboBoxModelAdapter
All Implemented Interfaces:
com.sas.table.StaticColumnInfoInterface, com.sas.util.transforms.DisplayTransformInterface, javax.swing.ComboBoxModel, javax.swing.ListModel

public class JDBCToComboBoxModelAdapter
implements javax.swing.ComboBoxModel

The JDBCToComboBoxModelAdapter allows JDBC data sources to be displayed in any viewer that requires a model of type javax.swing.ComboBoxModel, mainly being a javax.swing.JComboBox.

The adapter requires a java.sql.Connection object and a query statement. They can be passed in on the constructor or set via methods. The setConnection() method will apply the connection object. The setQueryStatement() method will apply the SQL query statement. When non-null values for both connection and query statement have been applied, the adapter is initialized and ready to use.

The query statement must be a SQL query that is valid for the JDBC data source. This may include a blank statement, if valid.

The setTemplateText method can be used to control which column values from the result set are displayed in the list. Multiple column values can be used along with text. The template text uses the default marker, open, and close characters from com.sas.util.SimpleTemplate( "%", "(", and ")" ). The column names must be defined in the template text as all uppercase variables. If no template text is defined, only the values from the first column of the result set are used as list items.

The general form of the template text is:

 text %COL1 more text %COL2
 
 Where COL1 and COL2 are fully uppercased column names. The '%' acts as a delimiter and is not part of the column name. 

 

The adapter can be configured and used within a webAF project. Add a com.sas.storage.jdbc.JDBCConnection component to your project. Open the customizer and specify the values needed for your JDBC connection.These include driver name and URL. Now open the customizer for the adapter. Specify the value for JDBC Connection using the top combo box. The drop-down list will show all JDBC Connection objects that exist in your project. You can set the properties for query statement, autoCommit, and read-only, as well.


Field Summary
static java.lang.String RB_KEY
           
protected  java.lang.Object selectedItem
          selectedItem for ComboBox
 
Fields inherited from class com.sas.storage.jdbc.JDBCToListModelAdapter
listenerList, mapTransform, templateText
 
Fields inherited from class com.sas.storage.jdbc.JDBCColumnValuesAdapter
columnValuesTransform, retrieveAllColumnValues
 
Fields inherited from class com.sas.storage.jdbc.JDBCAdapter
autoCommit, CLASS_NAME, columnInfoUsed, conn, designTime, displayTransform, forwardOnly, initialized, isRowCountKnown, LABEL, meta, NAME, printWarnings, queryRowCountDisabled, queryStatement, readOnly, result, resultSetRequeryUsed, resultSetType, resultSetUsed, retrieveNumericTypesAsDouble, rowCount, rowCountQueryString, rowNumber, spcs, stmt, trimUsed
 
Constructor Summary
JDBCToComboBoxModelAdapter()
          Default constructor called when the adapter is made in a webAF project.
JDBCToComboBoxModelAdapter(java.sql.Connection conn, java.lang.String queryStatement)
          Constructor used to create an initialized adapter.
JDBCToComboBoxModelAdapter(java.sql.ResultSet result)
          Constructor used to connect an adapter directly to a previously created ResultSet.
 
Method Summary
static com.sas.beans.ExtendedBeanInfo getExtendedBeanInfo()
          Returns information used by the com.sas.beans.Introspector to augment the automatically introspected information about this JDBCToComboBoxModelAdapter.
 java.lang.Object getSelectedItem()
          Return the selected item
 void setSelectedItem(java.lang.Object anItem)
          Set the selected item
 
Methods inherited from class com.sas.storage.jdbc.JDBCToListModelAdapter
addListDataListener, fireCellEvent, fireModelEvent, fireModelEvent, getElementAt, getElementsAt, getSize, getTemplateText, initializeData, removeListDataListener, setTemplateText
 
Methods inherited from class com.sas.storage.jdbc.JDBCColumnValuesAdapter
getColumnValuesMap, getColumnValuesTransform, isRetrieveAllColumnValues, retrieveColumnValueAt, retrieveValueAt, setColumnValuesTransform, setRetrieveAllColumnValues
 
Methods inherited from class com.sas.storage.jdbc.JDBCAdapter
addPropertyChangeListener, addPropertyChangeListener, calculateRowCount, close, doAbsolute, doCountColumns, doUpdateCell, finalize, getAutoCommit, getColumnInfo, getColumnInfoNames, getConnection, getDisplayTransform, getModel, getPrintWarnings, getQueryStatement, getResultSetConcurrency, getResultSetRowCount, getResultSetType, getRowCountByCountFunction, getRowCountQueryString, init, isQueryRowCountDisabled, isReadOnly, isResultSetRequeryUsed, isRetrieveNumericTypesAsDouble, isTrimUsed, printSQLWarning, putColumnInfoUsed, putValueAt, refresh, removePropertyChangeListener, removePropertyChangeListener, retrieveColumnClass, retrieveColumnCount, retrieveColumnIndex, retrieveColumnInfoUsed, retrieveColumnLabel, retrieveRawSASNumericValue, retrieveRawSASNumericValue, retrieveValueAt, setAutoCommit, setConnection, setDisplayTransform, setModel, setPrintWarnings, setQueryRowCountDisabled, setQueryStatement, setReadOnly, setResultSetRequeryUsed, setResultSetType, setRetrieveNumericTypesAsDouble, setRowCountQueryString, setTrimUsed
 

Field Detail

RB_KEY

public static final java.lang.String RB_KEY
See Also:
Constant Field Values

selectedItem

protected java.lang.Object selectedItem
selectedItem for ComboBox

Constructor Detail

JDBCToComboBoxModelAdapter

public JDBCToComboBoxModelAdapter()
Default constructor called when the adapter is made in a webAF project.


JDBCToComboBoxModelAdapter

public JDBCToComboBoxModelAdapter(java.sql.ResultSet result)
Constructor used to connect an adapter directly to a previously created ResultSet.

Parameters:
result - ResultSet to use.

JDBCToComboBoxModelAdapter

public JDBCToComboBoxModelAdapter(java.sql.Connection conn,
                                  java.lang.String queryStatement)
Constructor used to create an initialized adapter.

Parameters:
conn - A java.sql.Connection object.
queryStatement - A SQL query that is valid for the database represented by conn.
Method Detail

getExtendedBeanInfo

public static com.sas.beans.ExtendedBeanInfo getExtendedBeanInfo()
Returns information used by the com.sas.beans.Introspector to augment the automatically introspected information about this JDBCToComboBoxModelAdapter.


getSelectedItem

public java.lang.Object getSelectedItem()
Return the selected item

Specified by:
getSelectedItem in interface javax.swing.ComboBoxModel

setSelectedItem

public void setSelectedItem(java.lang.Object anItem)
Set the selected item

Specified by:
setSelectedItem in interface javax.swing.ComboBoxModel



Copyright © 2009 SAS Institute Inc. All Rights Reserved.