Reputation: 16639
I am trying to display table data in JSP
<%@ page import="java.sql.*" %>
<%@ page import="com.mysql.*" %>
<html>
<body>
<%
Class.forName("com.mysql.jdbc.Driver");
Connection conn = null;
conn = DriverManager.getConnection(connection, username, password);
String query = "select * from table1";
Statement stmt = null;
stmt = conn.createStatement();
ResultSet rs = null;
rs = stmt.ExecuteQuery(query);
while(rs.next()){
}
%>
</body>
</html>
It gives cannot find class com.mysql.jdbc.Driver.
Upvotes: 0
Views: 529
Reputation: 6260
Your JDBC Driver is not in the Classpath. Do the following:
Upvotes: 1
Reputation: 17151
You need to add com.mysql.jdbc.Driver in your classpath.
Simply calling Class.forName(...)
is not enough.
Upvotes: 0