sama Posted via mailing list.
|
Posted: Tue Mar 15, 2011 3:41 pm Post subject: Displaying a table from my database using database explore tutorial. |
|
|
In the tutorial it display the table and the related columns only I want to
display the whole table ( columns and rows).
I changed the createSceneFromConnection to this but it gave me error.any
help??
private void createSceneFromConnection(Connection jdbcConnection) throws
SQLException {
ArrayList< ArrayList> tables = new ArrayList< ArrayList>();
DatabaseMetaData databaseMetaData = jdbcConnection.getMetaData();
String[] names = {"TABLE"};
ResultSet resultSet = databaseMetaData.getTables(null, "%", "%",
names);
while (resultSet.next()) {
String table = resultSet.getString("TABLE_NAME");
tables.get(edgeID).add(table);
createNode(this, (int) (Math.random() * 800), (int)
(Math.random() * 800), IMAGE_LIST, table, "Table", null);
ResultSet columns =
jdbcConnection.getMetaData().getColumns(null, null, table.toUpperCase(),
"%");
while (columns.next()) {
String columnName = columns.getString("COLUMN_NAME");
tables.get(edgeID).add(columnName);
createNode(this, (int) (Math.random() * 800), (int)
(Math.random() * 800), IMAGE_LIST, columnName, null, null);
// createPin(this, table, table + ":" + columnName,
IMAGE_ITEM, columnName, columnName);
ResultSet rows = jdbcConnection.createStatement(edgeID,
edgeID, edgeID).executeQuery(columnName);
while (rows.next()) {
String rowelment= rows.getNString(edgeID);
tables.get(edgeID).add(rowelment);
createPin(this, table, table + ":" + rowelment, IMAGE_ITEM,
rowelment, rowelment);
}
}
}
for (ArrayList string : tables) {
ResultSet resultSet1 = databaseMetaData.getExportedKeys(null,
null, null);
while (resultSet1.next()) {
String pkTable = resultSet1.getString("PKTABLE_NAME");
String pkColumn = resultSet1.getString("PKCOLUMN_NAME");
String fkTable = resultSet1.getString("FKTABLE_NAME");
String fkColumn = resultSet1.getString("FKCOLUMN_NAME");
createEdge(this, fkTable + ":" + fkColumn, pkTable + ":" +
pkColumn);
}
}
this.moveTo(null);
}
--
View this message in context: http://netbeans-org.1045718.n5.nabble.com/Displaying-a-table-from-my-database-using-database-explore-tutorial-tp3706716p3706716.html
Sent from the Netbeans IDE Users mailing list archive at Nabble.com. |
|