java - Display table data from mysql to jsp page -
i have
<%@ page import="com.mysql.*" %> <%@ page import="java.sql.*" %> <html> <body> <div id="content"> <p>displaying table contents: </p> <table border="0" cellpadding="10"> <thead> <tr> <th>id</th> <th>name</th> <th>company</th> <th>salary</th> </tr> </thead> <tbody> <% class.forname("com.mysql.jdbc.driver"); connection conn = null; conn = drivermanager.getconnection("jdbc:mysql://localhost:8080/connection", "username", "password"); statement stmt = null; stmt = conn.createstatement(); string query = "select * employeee"; resultset rs = null; rs = stmt.executequery(query); while(rs.next()){ %> <tr> <% int id = rs.getint("id"); string name = rs.getstring("name"); string company = rs.getstring("company"); int salary = rs.getint("salary"); %> <td><%=id %></td> <td><%=name %></td> <td><%=company %></td> <td><%=salary %></td> </tr> <% } %> </tbody> </table> </div> </body> </html>
i getting class not found exception com.mysql.jdbc.driver
i have added external jar project , using same code results in normal java file.
what wrong here?
place mysql jar inside lib folder .. in local might of have done external jar
Comments
Post a Comment