mysql| Solution | data | database | problem
troubleshoot Linux under Tomcat connection MySQL database
Under Linux, developing a Web application that is always unsuccessful when calling a database, if you write a class individually and compile and execute access to the database, is normal, but use Web applications to tune this class to connect to the database. There will be an error: Com.mysql.jdbc.CommunicationsException:Communications link failure due to underlying exception:
It seems that the error is not in the database and should be in the web-related place. All ports are checked, the discovery is open, and file permissions are open to other users. A search on the internet, some people say that is the problem of Java Security Configuration, change/usr/lib/jvm/java-1.5.0-sun-1.5.0.10/jre/lib/security/ The policy file under Java.policy, changed, still inaccessible, looks like the problem is not here, under the Tomcat folder, there are several policy files, in the/ETC/TOMCAT5.5/ POLICY.D, we should be able to see 5. Policy files, each with a different function, with annotations in them and inserting the following code in the appropriate place:
Grant CodeBase "file:/var/lib/tomcat5.5/webapps/Project name/-" {
Permission java.security.AllPermission;
};
This project will have the appropriate permissions, if it is not know which file should be placed under, then put a sentence in each file, it will certainly work.
In this way, Tomcat will open the Web application Access database permissions.
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