“<pre>i used my local server that is tomcat. But my website is in linux server.</pre>”
You are talking about two different things here. Tomcat is a jsp/servlet container, while Linux is an operating system. Tomcat can run on many different operating systems, including Linux.
As for the database connection: are you using jdbc ?
If so, the code to connect to the database should look like this:
// here we are connecting to localhost, port 3306. Change it to your db server address:port
con = DriverManager.getConnection(“jdbc:mysql://localhost:3306/databaseName”,
//or con = DriverManager.getConnection(“jdbc:mysql://localhost:3306/databaseName?user=