Download connector / j Jar file and copy in to Apache Software Foundation\Apache Tomcat 6.0.14\lib folder and restart tomcat server.
Now creat a connection.jsp file to test the connectivity..
<%@ page language="java" import="java.sql.*" %>
<%
Connection conn = null;
Statement st =null;
ResultSet rst = null;
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:mysql:///databsename","mysql-username", "mysql-password");
if(!conn.isClosed())
out.println("Successfully connected to " +"MySQL server using TCP/IP...\n");
} catch (SQLException ex) {
// handle any errors
out.println("SQLException: " + ex.getMessage());
out.println("SQLState: " + ex.getSQLState());
out.println("VendorError: " + ex.getErrorCode());
}
%>
Sunday, January 24, 2010
Subscribe to:
Posts (Atom)