You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Reuben Christie <rc...@decisiontech.com> on 2004/07/08 18:24:06 UTC
how to get Table names in the datasource
I m newbie to cocoon. I am trying to get list of tables in my MSSQL
datasource using XSP. how do I do that ? i am confused because in xsp you
dont create connection its cocoon who manages the connection to db.so how do
i get object of type java.sql.Connection ? so that i can write the following
code to get the table name in that database
try {
// Gets the database metadata
DatabaseMetaData dbmd = connection.getMetaData();
// Specify the type of object; in this case we want tables
String[] types = {"TABLE"};
ResultSet resultSet = dbmd.getTables(null, null, "%", types);
// Get the table names
while (resultSet.next()) {
// Get the table name
String tableName = resultSet.getString(3);
// Get the table's catalog and schema names (if any)
String tableCatalog = resultSet.getString(1);
String tableSchema = resultSet.getString(2);
}
} catch (SQLException e) {
}
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org