agora inbox for pljava-dev@postgresql.org  
help / color / mirror / Atom feed
Subject: [Pljava-dev] java.lang.SecurityException
Date: Mon, 28 Mar 2005 14:34:04 -0500
Message-ID: <11C803742910E84E9CDBFD344773B814759F87@srqech02.teltronics.com> (raw)

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;



view thread (35+ messages)  latest in thread

Message-ID: <11C803742910E84E9CDBFD344773B814759F87@srqech02.teltronics.com>
Permalink:  ../11C803742910E84E9CDBFD344773B814759F87@srqech02.teltronics.com/
Also on:    postgresql.org/message-id/11C803742910E84E9CDBFD344773B814759F87@srqech02.teltronics.com

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pljava-dev@postgresql.org
  Subject: Re: [Pljava-dev] java.lang.SecurityException
  In-Reply-To: <11C803742910E84E9CDBFD344773B814759F87@srqech02.teltronics.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox