|
connecting to mysql database
Hi,
I have written a simple jsp file in netbeans 5.0, which connects to mysql database.
I am using a Connector/J driver,
This is my code :
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@page import="java.sql.Connection,
java.sql.DriverManager,
java.sql.SQLException"
%>
<%
Connection con = null;
out.println("coming here...");
try
{
Class.forName("com.mysql.jdbc.Driver").newInstance ();
con = DriverManager.getConnection("jdbc:mysql:///ebusiness","root", "nbuser");
if(!con.isClosed())
{
out.println("Successfully connected to " +"MySQL server using TCP/IP...");
}
}catch(SQLException e) {
e.printStackTrace();
}
catch(Exception ex) {
out.println("Exception: " + ex.getMessage());
} finally
{
try
{
if(con != null)
con.close();
} catch(SQLException e) {
out.println("Exception: " + e.getMessage());
}
}
%>
when i run this program,
I m getting exception as : Exception: com.mysql.jdbc.Driver
while I have installed mysql driver on my machine.., but do i need to keep my Driver class file at any perticular location/
Please help me.
|