尝试使用tomcat数据源连接到mysql时访问被拒绝 [英] access denied when trying to connect to mysql using tomcat datasource

查看:473
本文介绍了尝试使用tomcat数据源连接到mysql时访问被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用tomcat 6和数据源在jsp页面中本地连接到mysql 5服务器.
我已经按照tomcat手册(web.xml,context.xml等)配置了所有内容,但出现了以下异常:

I'm trying to connect locally to mysql 5 server in jsp page using tomcat 6 and datasource.
I've configured everything as in the tomcat manual (web.xml, context.xml, etc.), but I get this exception:

java.net.SocketException:java.security.AccessControlException:访问被拒绝(java.net.SocketPermission 127.0.0.1:3306 connect,resolve)

java.net.SocketException: java.security.AccessControlException: access denied (java.net.SocketPermission 127.0.0.1:3306 connect,resolve)

我检查了mysql,连接本身没有问题,实际上我什至成功使用直接JDBC连接(即不使用数据源)进行连接.

I checked the mysql and there is no problem with the connection itself, in fact I even succeeded connecting using direct JDBC connection (i.e. without using datasource).

我需要在tomcat策略文件中进行任何设置吗?还有其他想法吗?

Do I need to set anything in the tomcat policy file? other ideas?

谢谢

推荐答案

我找到了一种解决方法,尽管我不喜欢它,因为我不明白为什么在任何地方都没有提到它,以及为什么连接器的权限还不够吗?
谁能解释我?

I found a workaround, though I don't like it because I don't understand why it isn't mentioned anywhere, and why the permissions for the connector is not enough?
Can anyone explain me?

解决方法-将以下行添加到您的tomcat策略文件中:

The workaround - add these lines to your tomcat policy file:

grant {
        permission java.net.SocketPermission "localhost:3306", "connect, resolve";
};

这篇关于尝试使用tomcat数据源连接到mysql时访问被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆