[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[debian-users:37876] webからJDBC接続する方法



檜林と申します。
woody(カーネル 2.2.20)を使っています。

apache+tomcat4 で postgres へJDBC接続したいのですが、
文末のようなエラー(catalina.out)となってしまいます。
端末から実行するJavaアプリケーションからのアクセスは
可能なのですが、web経由(JSP、Servlet)だとだめみたいです。

org.postgresql.Driver.connect(Unknown Source)
になってしまう点について全く解決できませんでした。
解決策についてアドバイス頂けますでしょうか。

apache と tomcat4 は mod_jk で連携しています。

使用しているパッケージは以下の通りです。
ii  j2sdk1.3       1.3.1-1        Blackdown Java(TM) 2 SDK, Standard Edition
ii  java-common    0.14           Base of all Java packages
ii  libpgjava      7.2-1          Java database (JDBC) driver for PostgreSQL
ii  libregexp-java 1.2.20010409-3 regular expression library for Java
ii  libxerces-java 1.4.3-1        Validating XML parser for Java
ii  libtomcat4-jav 4.0.3-3woody2  Java Servlet engine -- core libraries
ii  tomcat4        4.0.3-3woody2  Java Servlet 2.3 engine with JSP 1.2 support
ii  tomcat4-webapp 4.0.3-3woody2  Java Servlet engine -- documentation and exa
ii  postgresql     7.2.1-2woody2  Object-relational SQL database, descended fr
ii  postgresql-cli 7.2.1-2woody2  Front-end programs for PostgreSQL
ii  postgresql-dev 7.2.1-2woody2  Header files for libpq (postgresql library)
ii  apache         1.3.26-0woody3 Versatile, high-performance HTTP server
ii  apache-common  1.3.26-0woody3 Support files for all Apache webservers
ii  libapache-mod- 3.3a-4woody1   Apache connector for Tomcat servlet engine


今回使用したJSPのプログラム(一部)です。

<%@ page import="java.sql.*" %>
<%
Connection con = null;
Statement stmt = null;
try {
  Class.forName("org.postgresql.Driver");
  con = DriverManager.getConnection("jdbc:postgresql:library1","www-data","");
  stmt = con.createStatement();
  String sql = "SELECT * FROM books";
  ResultSet rs = stmt.executeQuery(sql);
%>



出力されるエラー
= = = = = = = = catalina.out = = = = = = = = 

Something unusual has occured to cause the driver to fail. Please report this exception: Exception: java.security.AccessControlException: access denied (java.net.SocketPermission localhost resolve)
Stack Trace:

java.security.AccessControlException: access denied (java.net.SocketPermission localhost resolve)
	at java.security.AccessControlContext.checkPermission(AccessControlContext.java:272)
	at java.security.AccessController.checkPermission(AccessController.java:399)
	at java.lang.SecurityManager.checkPermission(SecurityManager.java:545)
	at java.lang.SecurityManager.checkConnect(SecurityManager.java:1042)
	at java.net.InetAddress.getAllByName0(InetAddress.java:559)
	at java.net.InetAddress.getAllByName0(InetAddress.java:540)
	at java.net.InetAddress.getByName(InetAddress.java:449)
	at java.net.Socket.<init>(Socket.java:100)
	at org.postgresql.PG_Stream.<init>(Unknown Source)
	at org.postgresql.Connection.openConnection(Unknown Source)
	at org.postgresql.Driver.connect(Unknown Source)
	at java.sql.DriverManager.getConnection(DriverManager.java:517)
	at java.sql.DriverManager.getConnection(DriverManager.java:177)
	at org.apache.jsp.jspdb1$jsp._jspService(jspdb1$jsp.java:81)
	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:202)
	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:382)
	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:474)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
	at org.apache.catalina.core.ApplicationFilterChain.access$0(ApplicationFilterChain.java:197)
	at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:176)
	at java.security.AccessController.doPrivileged(Native Method)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:172)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
	at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
	at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
	at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2343)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
	at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
	at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
	at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
	at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
	at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
	at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
	at org.apache.ajp.tomcat4.Ajp13Processor.process(Ajp13Processor.java:429)
	at org.apache.ajp.tomcat4.Ajp13Processor.run(Ajp13Processor.java:495)
	at java.lang.Thread.run(Thread.java:484)
End of Stack Trace

	at org.postgresql.Driver.connect(Unknown Source)
	at java.sql.DriverManager.getConnection(DriverManager.java:517)
	at java.sql.DriverManager.getConnection(DriverManager.java:177)
	at org.apache.jsp.jspdb1$jsp._jspService(jspdb1$jsp.java:81)
	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:202)
	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:382)
	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:474)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
	at org.apache.catalina.core.ApplicationFilterChain.access$0(ApplicationFilterChain.java:197)
	at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:176)
	at java.security.AccessController.doPrivileged(Native Method)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:172)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
	at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
	at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
	at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2343)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
	at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
	at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
	at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
	at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
	at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
	at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
	at org.apache.ajp.tomcat4.Ajp13Processor.process(Ajp13Processor.java:429)
	at org.apache.ajp.tomcat4.Ajp13Processor.run(Ajp13Processor.java:495)
	at java.lang.Thread.run(Thread.java:484)

= = = = = = = = end = = = = = = = =