Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id D2A6D9FB5AB; Tue, 23 Jan 2007 01:37:43 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-new, port 10024) with ESMTP id 14954-02-7; Tue, 23 Jan 2007 01:37:35 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from alnrmhc11.comcast.net (alnrmhc11.comcast.net [204.127.225.91]) by postgresql.org (Postfix) with ESMTP id AB1BD9FB5DC; Tue, 23 Jan 2007 01:25:59 -0400 (AST) Received: from [192.168.111.100] (70.91.164.89-busname-atlanta.hfc.comcastbusiness.net?[70.91.164.89]) by comcast.net (alnrmhc11) with ESMTP id <20070123052558b110010mqle>; Tue, 23 Jan 2007 05:25:58 +0000 Message-ID: <45B59C68.8080203@comcast.net> Date: Tue, 23 Jan 2007 00:26:00 -0500 From: Marc User-Agent: Thunderbird 1.5.0.9 (Windows/20061207) MIME-Version: 1.0 To: pgsql-jdbc@postgresql.org, pgsql-novice@postgresql.org Subject: Applet Connectivity - PLEASE help Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.409 tagged_above=0 required=5 tests=AWL, BAYES_50, DNS_FROM_RFC_POST X-Spam-Level: X-Archive-Number: 200701/149 X-Sequence-Number: 16514 OK, I'll say right up front I'm a postgres novice at best. I've spent quite some time researching this tonight and trying out a few things to no avail. The basic question is can an applet connect to a postgres database and if so how (I need specific details)? Postgres, the database, the web server and signed applet are all on the same machine. I'm using Postgres 8.2 and Java 1.5 w/ the postgresql-8.2-504.jdbc3 jdbc driver. The software works when run through my IDE (Eclipse) but not as an applet in a browser. I've set listen_addresses = '*' in postgresql.conf and my pg_hba settings are: local all all md5 host all all 127.0.0.1/32 trust. Here's the code I'm using to try to make the connection where strServer = :jdbc:postgresql://localhost/Arco strDriver = org.postgresql.Driver strUser = postgres strPswd = fred public DBConnection(Trace trace, JApplet p_applet) throws Exception { URL dbIniURL; URLConnection urlConn; BufferedReader in; int vals = 0; String nextVal; String strProp; String strVal; String strUser = ""; String strPswd = ""; int pos; Properties props = new Properties(); try { System.out.println("Instantiate DBConnection."); dbIniURL = new URL(p_applet.getDocumentBase(), "db.ini"); urlConn = dbIniURL.openConnection(); in = new BufferedReader(new InputStreamReader(urlConn.getInputStream())); while (vals < 4) { nextVal = in.readLine(); vals = vals + 1; System.out.println("db.ini: " + nextVal.trim()); pos = nextVal.indexOf(":"); if (pos>0) { strProp = nextVal.substring(0,pos); strVal = nextVal.substring(pos+1); if (strProp.compareToIgnoreCase("Server") == 0) { strServer = strVal; } else if (strProp.compareToIgnoreCase("Driver") == 0) { strDriver = strVal; } else if (strProp.compareToIgnoreCase("User") == 0) { strUser = strVal; } else if (strProp.compareToIgnoreCase("Password") == 0) { strPswd = strVal; } } } drv = (Driver)Class.forName(strDriver).newInstance(); DriverManager.registerDriver(drv); props.setProperty("user",strUser.trim()); props.setProperty("password",strPswd.trim()); System.out.println("Attempting to connecting to postgres db..."); dbConn= DriverManager.getConnection(strServer, props); System.out.println("Connected to postgres db."); } catch (IOException ioe) { System.out.println("Error trying to connect to postgres db:"); ioe.printStackTrace(); throw new Exception(ioe.getMessage()); } } The error I get in the console is: Java Plug-in 1.6.0 Using JRE version 1.6.0 Java HotSpot(TM) Client VM User home directory = C:\Documents and Settings\Marc ---------------------------------------------------- c: clear console window f: finalize objects on finalization queue g: garbage collect h: display this help message l: dump classloader list m: print memory usage o: trigger logging p: reload proxy configuration q: hide console r: reload policy configuration s: dump system and deployment properties t: dump thread list v: dump thread stack x: clear classloader cache 0-5: set trace level to ---------------------------------------------------- Init applet. Call new DBConnection. Instantiate DBConnection. db.ini: Server:jdbc:postgresql://localhost/Arco db.ini: Driver:org.postgresql.Driver Attempting to connecting to postgres db... org.postgresql.util.PSQLException: Something unusual has occured to cause the driver to fail. Please report this exception. at org.postgresql.Driver.connect(Driver.java:276) at java.sql.DriverManager.getConnection(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Source) at db.DBConnection.(DBConnection.java:169) at ui.BaseApplet.init(BaseApplet.java:138) at sun.applet.AppletPanel.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: java.security.AccessControlException: access denied (java.net.SocketPermission 127.0.0.1:5432 connect,resolve) at java.security.AccessControlContext.checkPermission(Unknown Source) at java.security.AccessController.checkPermission(Unknown Source) at java.lang.SecurityManager.checkPermission(Unknown Source) at java.lang.SecurityManager.checkConnect(Unknown Source) at java.net.Socket.connect(Unknown Source) at java.net.Socket.connect(Unknown Source) at java.net.Socket.(Unknown Source) at java.net.Socket.(Unknown Source) at org.postgresql.core.PGStream.(PGStream.java:59) at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:77) at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:66) at org.postgresql.jdbc2.AbstractJdbc2Connection.(AbstractJdbc2Connection.java:125) at org.postgresql.jdbc3.AbstractJdbc3Connection.(AbstractJdbc3Connection.java:30) at org.postgresql.jdbc3.Jdbc3Connection.(Jdbc3Connection.java:24) at org.postgresql.Driver.makeConnection(Driver.java:382) at org.postgresql.Driver.connect(Driver.java:260) ... 6 more I think that covers it. I'm pretty wiped out being as I've been working on this for about 4 hrs now. Your help is really appreciated! Thanks, Marc