MySQL and JSP connection
25 pts.
0
Q:
MySQL and JSP connection
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: Feb 25 2009  5:44 AM GMT
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
0
29820 pts.
0
A:
 RATE THIS ANSWER
0
Click to Vote:
  •   0
  •  0
  • AddThis Social Bookmark Button
"
i used my local server that is tomcat. But my website is in linux server.
"

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:

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());
}
Last Answered: Feb 25 2009  7:40 PM GMT by Carlosdl   29820 pts.
0
0
Discuss This Answer:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



0