Connect JSP to ACCESS database

Asked

Viewed 98 times

0

Hello, I am trying to connect a JSP class with ACCESS but is returning the following error: "java.lang.Classnotfoundexception: sun.jdbc.odbc.Jdbcodbcdriver" someone knows how to fix it?

<%@ page import ="java.sql.*" %>
<%
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String database = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=/caminho do banco.accdb;DriverID=22;READONLY=true}";
Connection con = DriverManager.getConnection(database);
String SQL = "Select * from valores order by equipamento";

Statement stmt = con.createStatement();
ResultSet rst = stmt.executeQuery(SQL);

 while (rst.next()) {
   out.println(rst.getString("equipamento") + " " + rst.getString("valor") + "<br>");
 }

rst.close();
stmt.close();
con.close();
%>

  • Dude, stop it. No bank access inside JSP.

  • 1

    Create a class responsible for access to your bank Servlet you deliver the ready data to your .jsp

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.