[Pljava-dev] java.lang.SecurityException

From: jluo at teltronics(dot)com (Joves Luo)
To:
Subject: [Pljava-dev] java.lang.SecurityException
Date: 2005-03-28 19:34:04
Message-ID: 11C803742910E84E9CDBFD344773B814759F87@srqech02.teltronics.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pljava-dev

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: <http://lists.pgfoundry.org/pipermail/pljava-dev/attachments/20050328/1f1e9041/attachment.html>

Responses

Browse pljava-dev by date

  From Date Subject
Next Message Thomas Hallgren 2005-03-28 21:01:21 [Pljava-dev] java.lang.SecurityException
Previous Message Thomas Hallgren 2005-03-28 19:09:59 [Pljava-dev] java.lang.SecurityException