/*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
*
* - Neither the name of Oracle nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* This source code is provided to illustrate the usage of a given feature
* or technique and has been deliberately simplified. Additional steps
* required for a production-quality application, such as security checks,
* input validation and proper error handling, might not be present in
* this sample code.
*/
/**
* An adaptor, transforming the JDBC interface to the TableModel interface.
*
* @author Philip Milne
*/
@SuppressWarnings("serial")
try {
} catch (ClassNotFoundException ex) {
} catch (SQLException ex) {
}
}
return;
}
try {
// Get the column names and cache them.
// Then we can close the connection.
}
// Get all rows.
for (int i = 1; i <= getColumnCount(); i++) {
}
}
// close(); Need to copy the metaData, bug in jdbc:odbc driver.
// Tell the listeners a new table has arrived.
} catch (SQLException ex) {
}
}
connection.close();
}
close();
super.finalize();
}
//////////////////////////////////////////////////////////////////////////
//
// Implementation of the TableModel Interface
//
//////////////////////////////////////////////////////////////////////////
// MetaData
return columnNames[column];
} else {
return "";
}
}
int type;
try {
} catch (SQLException e) {
return super.getColumnClass(column);
}
switch (type) {
case Types.LONGVARCHAR:
return String.class;
return Boolean.class;
return Integer.class;
return Long.class;
return Double.class;
default:
return Object.class;
}
}
try {
} catch (SQLException e) {
return false;
}
}
public int getColumnCount() {
return columnNames.length;
}
// Data methods
public int getRowCount() {
}
}
int type;
return "null";
}
try {
} catch (SQLException e) {
}
switch (type) {
default:
}
}
try {
// Some of the drivers seem buggy, tableName should not be null.
}
// We don't have a model of the schema so we don't know the
// primary keys or which columns to lock on. To demonstrate
// that editing is possible, we'll just lock on everything.
continue;
}
if (col != 0) {
}
}
// statement.executeQuery(query);
} catch (SQLException e) {
// e.printStackTrace();
}
}
}