Обсуждение: Servlets and JDBC driver: Access Exception

Поиск
Список
Период
Сортировка

Servlets and JDBC driver: Access Exception

От
"Tom Donaldson"
Дата:
I am using Javasoft JDK1.2.2, with the Postgresql 6.5 driver for JDK1.2,
running under Windows 98 at present (though I'll be switching to Linux once
the JDK1.2 production release is available). I am running from a JSP page
executing on Sun's JavaWebServer2.0.

I am receiving the following exception when trying to connect to my
Postgresql database:

Something unusual has occured to cause the driver to fail. Please report
this exception: java.security.AccessControlException: access denied
(java.net.SocketPermission 192.168.254.4:5432 connect,resolve)
at postgresql.Driver.connect(Driver.java:125)
at java.sql.DriverManager.getConnection(DriverManager.java:457)
at java.sql.DriverManager.getConnection(DriverManager.java:137)
at pagecompile.jsp._postgre._jspService(_postgre.java:72)
at
com.sun.server.http.pagecompile.jsp.runtime.HttpJspBase.service(HttpJspBase.
java:87)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:840)
at
com.sun.server.http.pagecompile.jsp.runtime.JspServlet.runServlet(JspServlet
.java:469)
at
com.sun.server.http.pagecompile.jsp.runtime.JspServlet.processJspPage(JspSer
vlet.java:259)
at
com.sun.server.http.pagecompile.jsp.runtime.JspServlet.service(JspServlet.ja
va:97)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:840)
at com.sun.server.ServletState.callService(ServletState.java:226)
at com.sun.server.ServletManager.callServletService(ServletManager.java:936)
at
com.sun.server.ProcessingState.invokeTargetServlet(ProcessingState.java:423)
at
com.sun.server.http.HttpProcessingState.execute(HttpProcessingState.java:79)
at com.sun.server.http.stages.Runner.process(Runner.java:79)
at com.sun.server.ProcessingSupport.process(ProcessingSupport.java:294)
at com.sun.server.Service.process(Service.java:204)
at
com.sun.server.http.HttpServiceHandler.handleRequest(HttpServiceHandler.java
:374)
at
com.sun.server.http.HttpServiceHandler.handleRequest(HttpServiceHandler.java
:166)
at com.sun.server.HandlerThread.run(HandlerThread.java:162)


The code I'm calling from is
Class.forName("postgresql.Driver");

java.sql.Connection db =
java.sql.DriverManager.getConnection("jdbc:postgresql://192.168.254.4:5432/S
essamiLondon","Postgre","xxxxxxxxxxx");

java.sql.Statement st = db.createStatement();

The commands execute successfully when I call them from a Main class, using
the same JDK and driver. Any suggestions as to how to get this working.

Thanks in advance for any help

Tom Donaldson



Re: [INTERFACES] Servlets and JDBC driver: Access Exception

От
"Joe Shevland"
Дата:
I don't think the application (Main) class would change anything as you're
not running into, say, the applet sandbox, and the servlet engine is
effectively an application itself.

Try

i) Using a permissions file (under Java 2) e.g.

grant {
// Allow everything for now * MUST BE CHANGED FOR PRODUCTION
permission java.security.AllPermission;
};

*and* this to the JVM:

-Djava.security.policy=D:\<dir>\somename.policy

ii) Check the pg_hba.conf file in the Postgres data directory. This
specifies which hosts are allowed to connect to the database.

iii) Check the password :) !

Joe


----- Original Message -----
From: "Tom Donaldson" <tom@upstartinventions.com>
To: <pgsql-interfaces@postgreSQL.org>
Sent: Monday, January 24, 2000 6:33 PM
Subject: [INTERFACES] Servlets and JDBC driver: Access Exception


> I am using Javasoft JDK1.2.2, with the Postgresql 6.5 driver for JDK1.2,
> running under Windows 98 at present (though I'll be switching to Linux
once
> the JDK1.2 production release is available). I am running from a JSP page
> executing on Sun's JavaWebServer2.0.
>
> I am receiving the following exception when trying to connect to my
> Postgresql database:
>
> Something unusual has occured to cause the driver to fail. Please report
> this exception: java.security.AccessControlException: access denied
> (java.net.SocketPermission 192.168.254.4:5432 connect,resolve)
> at postgresql.Driver.connect(Driver.java:125)
> at java.sql.DriverManager.getConnection(DriverManager.java:457)
> at java.sql.DriverManager.getConnection(DriverManager.java:137)
> at pagecompile.jsp._postgre._jspService(_postgre.java:72)
> at
>
com.sun.server.http.pagecompile.jsp.runtime.HttpJspBase.service(HttpJspBase.
> java:87)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:840)
> at
>
com.sun.server.http.pagecompile.jsp.runtime.JspServlet.runServlet(JspServlet
> .java:469)
> at
>
com.sun.server.http.pagecompile.jsp.runtime.JspServlet.processJspPage(JspSer
> vlet.java:259)
> at
>
com.sun.server.http.pagecompile.jsp.runtime.JspServlet.service(JspServlet.ja
> va:97)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:840)
> at com.sun.server.ServletState.callService(ServletState.java:226)
> at
com.sun.server.ServletManager.callServletService(ServletManager.java:936)
> at
>
com.sun.server.ProcessingState.invokeTargetServlet(ProcessingState.java:423)
> at
>
com.sun.server.http.HttpProcessingState.execute(HttpProcessingState.java:79)
> at com.sun.server.http.stages.Runner.process(Runner.java:79)
> at com.sun.server.ProcessingSupport.process(ProcessingSupport.java:294)
> at com.sun.server.Service.process(Service.java:204)
> at
>
com.sun.server.http.HttpServiceHandler.handleRequest(HttpServiceHandler.java
> :374)
> at
>
com.sun.server.http.HttpServiceHandler.handleRequest(HttpServiceHandler.java
> :166)
> at com.sun.server.HandlerThread.run(HandlerThread.java:162)
>
>
> The code I'm calling from is
> Class.forName("postgresql.Driver");
>
> java.sql.Connection db =
>
java.sql.DriverManager.getConnection("jdbc:postgresql://192.168.254.4:5432/S
> essamiLondon","Postgre","xxxxxxxxxxx");
>
> java.sql.Statement st = db.createStatement();
>
> The commands execute successfully when I call them from a Main class,
using
> the same JDK and driver. Any suggestions as to how to get this working.
>
> Thanks in advance for any help
>
> Tom Donaldson
>
>
> ************
>
>



Re: [INTERFACES] Servlets and JDBC driver: Access Exception

От
Joseph Shraibman
Дата:
Use policytool to grant the codebase file://- a socketpermission for that
ipaddress with connect and resolve.

Tom Donaldson wrote:

> I am using Javasoft JDK1.2.2, with the Postgresql 6.5 driver for JDK1.2,
> running under Windows 98 at present (though I'll be switching to Linux once
> the JDK1.2 production release is available). I am running from a JSP page
> executing on Sun's JavaWebServer2.0.
>
> I am receiving the following exception when trying to connect to my
> Postgresql database:
>
> Something unusual has occured to cause the driver to fail. Please report
> this exception: java.security.AccessControlException: access denied
> (java.net.SocketPermission 192.168.254.4:5432 connect,resolve)
> at postgresql.Driver.connect(Driver.java:125)
> at java.sql.DriverManager.getConnection(DriverManager.java:457)
> at java.sql.DriverManager.getConnection(DriverManager.java:137)
> at pagecompile.jsp._postgre._jspService(_postgre.java:72)
> at
> com.sun.server.http.pagecompile.jsp.runtime.HttpJspBase.service(HttpJspBase.
> java:87)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:840)
> at
> com.sun.server.http.pagecompile.jsp.runtime.JspServlet.runServlet(JspServlet
> .java:469)
> at
> com.sun.server.http.pagecompile.jsp.runtime.JspServlet.processJspPage(JspSer
> vlet.java:259)
> at
> com.sun.server.http.pagecompile.jsp.runtime.JspServlet.service(JspServlet.ja
> va:97)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:840)
> at com.sun.server.ServletState.callService(ServletState.java:226)
> at com.sun.server.ServletManager.callServletService(ServletManager.java:936)
> at
> com.sun.server.ProcessingState.invokeTargetServlet(ProcessingState.java:423)
> at
> com.sun.server.http.HttpProcessingState.execute(HttpProcessingState.java:79)
> at com.sun.server.http.stages.Runner.process(Runner.java:79)
> at com.sun.server.ProcessingSupport.process(ProcessingSupport.java:294)
> at com.sun.server.Service.process(Service.java:204)
> at
> com.sun.server.http.HttpServiceHandler.handleRequest(HttpServiceHandler.java
> :374)
> at
> com.sun.server.http.HttpServiceHandler.handleRequest(HttpServiceHandler.java
> :166)
> at com.sun.server.HandlerThread.run(HandlerThread.java:162)
>
> The code I'm calling from is
> Class.forName("postgresql.Driver");
>
> java.sql.Connection db =
> java.sql.DriverManager.getConnection("jdbc:postgresql://192.168.254.4:5432/S
> essamiLondon","Postgre","xxxxxxxxxxx");
>
> java.sql.Statement st = db.createStatement();
>
> The commands execute successfully when I call them from a Main class, using
> the same JDK and driver. Any suggestions as to how to get this working.
>
> Thanks in advance for any help
>
> Tom Donaldson
>
> ************