Solve the problem of connecting tomcat to MySQL database _ MySQL in Linux

Source: Internet
Author: User
In linux, it is always unsuccessful to call a database during the development of a web application. if you write a class separately and compile and execute it to access the database, it is normal, however, when a web application calls this class to connect to the database, the following error occurs: com. mysql. jdbc. communicationsException: Communicationslinkfailureduetounderlyingexception:-g Tomcat

In linux, it is always unsuccessful to call a database during the development of a web application. if you write a class separately and compile and execute it to access the database, it is normal, however, when a web application calls this class to connect to the database, the following error occurs: com. mysql. jdbc. communicationsException: Communications link failure due to underlying exception:-g uDg XX_fn * s]
** Begin nested exception ** # (R.; Fz
W * xeyA
Java. security. AccessControlException X &) mDn
MESSAGE: access denied (java.net. SocketPermission localhost resolve) PujB> 5 ^ 1 {
B % C % f7hj6
STACKTRACE: % N-Pivt '* V
VyTH 8rSx =
Java. security. AccessControlException: access denied (java.net. SocketPermission localhost resolve) Gng = 6> uR
Dva 1 eOmO
It seems that the error is not in the database, but it should also be related to the web. Check the ports and find that all ports are open, and the file permission is also open to other users. Some people say it is a java security configuration issue. change/usr/lib/jvm/java-1.5.0-sun-1.5.0.10/jre/lib/security/java. the policy file under the policy cannot be accessed after modification. it seems that the problem is not here. in the tomcat folder, there are also several policy files in the/etc/tomcat5.5/policy. d. We should be able to see five. policy files, which have different roles. there are comments in them. Insert the following code in the corresponding place :! G} xz = M
Hwd [$ G ):/
Grant codeBase "file:/var/lib/tomcat5.5/webapps/project name/-" {* 0, U? 8 # h (
Permission java. security. AllPermission; '5 \ zssE
}; QCO & z ($) oy
JJ + 4 w
In this way, the project will have the corresponding permissions. if you really don't know which file to store, then put a sentence in each file, it will certainly work. W., 6I t
I2s5_yC
In this way, tomcat opens the database access permission for web applications.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.