I am doing project in JSP with database WampServer and glassfish as server .when i done database connection then i get an error java.lang.ClassNotFoundException: com.mysql.jdbc.Driver. The following is the code of connection. Please suggest the solution or give sample code of mysql connection. Your inputs are very valuable to me.
<%@ page import="java.sql.*" %> <%@ page import="java.io.*" %>
<% try { /* Create string of connection url within specified format with machine name, port number and database name. Here machine name id localhost and database name is usermaster. */ String connectionURL = "jdbc:mysql://shree:8080/tickettool";
// declare a connection by using Connection interface Connection connection = null;
// Load JBBC driver "com.mysql.jdbc.Driver" Class.forName("com.mysql.jdbc.Driver" + "").newInstance();
/* Create a connection by using getConnection() method that takes parameters of string type connection url, user name and password to connect to database. */ connection = DriverManager.getConnection(connectionURL,"","");
// check weather connection is established or not by isClosed() method if(!connection.isClosed()) %>
<% out.println("Successfully connected to " + "MySQL server using TCP/IP..."); connection.close(); } catch(Exception ex){ %> <% out.println("Unable to connect to database."+ex); } %>