Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HELP! Tomcat Mysql Connection Problem (Again)

Status
Not open for further replies.

cjhowland

Programmer
Apr 25, 2002
12
0
0
GB
Now... I've searched and read through most postings on the Rackshack and Ensim forums looking at the problems people have had getting Tomcat and MySQL to work together. Despite this, and despite already having one Ensim 3.1.0-25 server working just fine (given the fact that the MySQL user table needs and entry for ensim.rackshack.net as well as localhost), I just can't get JSP to connect to a MySQL database on a new Ensim 3.1.9-2 server.

I have upgraded the Ensim Tomcat to 4.1.24 on both servers, and uploaded the very latest version of the mysql-connector-java-3.0.8-stable-bin.jar into the tomcat4/common/lib directory, which also has mm.mysql-2.0.4-bin.jar installed. I am using the following code to connect the the MySQL database :

try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
} catch(Exception e) {
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
}

Connection C = DriverManager.getConnection("jdbc:mysql://ensim.rackshack.net/DATABASE?user=USER&password=PASSWORD");


I have one site that was working perfectly on the old server, but when copied onto the new server fails as follows :

org.apache.jasper.JasperException: Cannot connect to MySQL server on ensim.rackshack.net:3306. Is there a MySQL server running on the machine/port you are trying to connect to? (java.security.AccessControlException)

Ah-ha, you are all saying, "he's not set up the correct entry in the MySQL user table" - wrong, it's fine. "He's got a copy of the MySQL connector class in the site WEB-INF/lib directory" - wrong, there's no connector jar there. "He's not set up permissions in a sitex.policy.custom file." - wrong, here it is :

permission java.security.AllPermission;
permission java.net.SocketPermission "127.0.0.1:25", "listen,connect,accept,resolve";
permission java.net.SocketPermission "localhost:25", "listen,connect,accept,resolve";
permission java.net.SocketPermission "127.0.0.1:3306", "listen,connect,accept,resolve";
permission java.net.SocketPermission "localhost:3306", "listen,connect,accept,resolve";
permission java.net.SocketPermission "69.57.130.2:25", "listen,connect,accept,resolve";
permission java.net.SocketPermission "69.57.130.2:3306", "listen,connect,accept,resolve";
permission java.net.SocketPermission "69.57.131.31:25", "listen,connect,accept,resolve";
permission java.net.SocketPermission "69.57.131.31:3306", "listen,connect,accept,resolve";
permission java.net.SocketPermission "ensim.rackshack.net:25", "listen,connect,accept,resolve";
permission java.net.SocketPermission "ensim.rackshack.net:3306", "listen,connect,accept,resolve";
permission java.net.SocketPermission "karisto-hosting.co.uk:25", "listen,connect,accept,resolve";
permission java.net.SocketPermission "karisto-hosting.co.uk:3306", "listen,connect,accept,resolve";
permission java.net.SocketPermission "*", "listen,connect,accept,resolve";

I've edited the site through the control panel, restarted Tomcat and Apache, all to no avail.

If I start Tomcat without the security manager, using :

export JAVA_HOME=/usr/java/j2sdk1.4.0
/var/tomcat4/bin/catalina.sh start

Then everything works perfectly, showing that the MySQL setup is correct, and that it is some permission problem.

I've read everything I can find on these forums, but I can't actually find anything that anyone did to solve the problem. I also can't see any difference between the setup of the two servers I am running but one works fine (with the ensim.rackshack.net entry in the MySQL user table), and the other one does not.

I've already got one customer on the new server wanting to do this, and usually have a steady stream of new customers, so I am desperate to get this working!!!

I can only think that there is something in catalina.policy that needs changing, and am thinking of copying the catalina.* files across from the working server, but I'm not sure what might happen if I do this!

Somebody please HELP!

Thanks

Chris Howland
Karisto Limited
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top