JdbcDataSource STATBEAN®


Purpose: Reads data from a database by issuing a SQL query and saves the results in an invisible rectangular data table. 

Read/Write Properties

Name Type Description Possible Values Default Value
jdbcColumns String The columns names to be read, or "*" to read all columns. Any string. "*"
jdbcDriverClass String The jdbc driver class to be used. Any string. "sun.jdbc.odbc.JdbcOdbcDriver"
jdbcPassword String The password associated with the user name. Any string. ""
jdbcSchema String The schema of the table to be read. Any string. ""
jdbcSelection String A string used after the WHERE in a SQL query to select a subset of the records. Any string. ""
jdbcTable String The name of the table to be read. Any string. ""
jdbcURL String The URL of the database to be read. Any string. "jdbc:odbc:dsname"
jdbcUsername String The user name used to access the database. Any string. ""
missingValueCode double A numeric value used to represent missing values in the file to be read. Any numeric value. -32768.0


Other Public Methods

Name Description Arguments Return Value
int getMaxRows() Gets the number of rows which were read. None. Number of rows.
int getMaxColumns() Gets the number of columns which were read. None. Number of columns.
boolean readData() Causes the data to be read and all listeners notified. None. true if data is read successfully


Other properties are inherited from the java.awt.Object class and from the general StatDataSource class. 

Code Sample 

//create the JdbcDataSource bean 
JdbcDataSource jdbcDataSource1 = new JdbcDataSource(); 

//create a bean to display the data 
DataDisplayTable dataDisplayTable1 = new DataDisplayTable(); 

//set the database name to be read 
jdbcDataSource1.setJdbcURL("jdbc:odbc:Northwind"); 

//set the name of the table in the database 
jdbcDataSource1.setJdbcTable("Employees"); 

//set the column names to be read 
jdbcDataSource1.setJdbcColumns("City,EmployeeID,BirthDate"); 

//make the data table a listener for changes in the jdbcDataSource bean 
jdbcDataSource1.addDataChangeListener(dataDisplayTable1.listenerForDataChange); 

//instruct the jdbcDataSource bean to read the file 
jdbcDataSource1.readData();