From: jluo at teltronics.com (Joves Luo) Date: Mon, 28 Mar 2005 14:34:04 -0500 Subject: [Pljava-dev] java.lang.SecurityException Message-ID: <11C803742910E84E9CDBFD344773B814759F87@srqech02.teltronics.com> Here is my code that calls the Driver. The host, database, username, and password all come from another constants file included in the PGtoXML package. I guess there is something wrong with the way I use the JDBC driver. I tried removing the import java.sql.* line to stop it from looking for the JDBC jar files. But now everything is broken without it. Do I need to rewrite all my code to use the pljava JDBC driver? Also why is it that this works 100% on a windows system, ( I can even access the Linux database with the windows postgresql function)? Thank you for your help, I would have gotten nowhere without it. package PGtoXML; import java.sql.*; public class OWDBConnection { private Connection db; public OWDBConnection() throws ClassNotFoundException, SQLException{ Class.forName("org.postgresql.Driver"); db = DriverManager.getConnection("jdbc:postgresql:" + Constants.host + Constants.database, Constants.username, Constants.password); } public ResultSet getTableNames() throws SQLException{ Statement sql = db.createStatement(); ResultSet results = sql.executeQuery ("select viewname from pg_views where schemaname = 'public' and viewname like 'xml_%'"); return results; } public ResultSet getTableColNames (String name) throws SQLException{ Statement sql = db.createStatement(); ResultSet results = sql.executeQuery ("select column_name from information_schema.columns where table_name = '" + name + "' order by ordinal_position"); return results; } public ResultSet getTableData (String name) throws SQLException{ Statement sql = db.createStatement(); ResultSet results = sql.executeQuery("select * from " + name); return results; } public static void main (String args[]) { try{ OWDBConnection demo = new OWDBConnection(); System.out.println("\n"); ResultSet tableNames = demo.getTableNames(); ResultSet tableData; while (tableNames.next()) { System.out.println(tableNames.getString(1)); tableData = demo.getTableData(tableNames.getString(1)); for (int i=1; i<=tableData.getMetaData().getColumnCount(); i++){ System.out.print("\t\t\t" + tableData.getMetaData().getColumnName(i)); } while (tableData.next()){ System.out.println(); for (int i=1; i<=tableData.getMetaData().getColumnCount(); i++){ System.out.print("\t\t\t" + tableData.getString(i)); } } System.out.println("\n"); } } catch (Exception ex) { System.out.println("***Exception:\n"+ex); ex.printStackTrace(); } } } -------------- next part -------------- An HTML attachment was scrubbed... URL: