MySQL and JSP connection

25 pts.
Tags:
Apache Tomcat
Database connectivity
DSN
JSP
Linux servers
MySQL
Web development
I hosted my site and I got the mysql server. Now, I want to connect it with the jsp pages . I am not understanding how to use ip address in connection string and while creating DSN i used my local server that is tomcat. But my website is in linux server. Will it create a problem.
ASKED: February 25, 2009  5:43 AM
UPDATED: February 25, 2009  7:40 PM

Answer Wiki

Thanks. We'll let you know when a new response is added.

“<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:

<pre>try {
Class.forName(“com.mysql.jdbc.Driver”).newInstance();
// here we are connecting to localhost, port 3306. Change it to your db server address:port
con = DriverManager.getConnection(“jdbc:mysql://localhost:3306/databaseName”,
“root”, “secret”);
//or con = DriverManager.getConnection(“jdbc:mysql://localhost:3306/databaseName?user=
root&password=secret”;
}
catch(Exception e){
System.out.println(e.getMessage());
}</pre>

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following