Connect MS access database in JSP pages

10,332

Ancient question, but I shall answer anyway. Had to Google around a bit when the same question flummoxed me. Here goes (concise version of stuff found here):

Administratively Register Database

  1. Use MS Access to create a blank database in some directory. (eg. Database1.mdb.) Make sure to close the data base after it is created.

  2. Go to: Control panel -> Admin tool -> ODBC

  3. Under the System DSN tab (for Tomcat version 5 or later – User DSN for earlier versions), un-highlight any previously selected name and then click on the Add button.

  4. On the window that then opens up, highlight MS Access Driver & click Finish.

  5. On the ODBC Setup window that then opens, fill in the data source name. This is the name that you will use to refer to the data base in your Java program – like
    arc. This name does not have to match the file name.
    .

  6. Then click Select and navigate to the already created database in directory.
    Suppose the file name is Database1.mdb. After highlighting the named file,
    click OKs all the way back to the original window.

Connect a JSP page to an Access Database

 <%@ page import="java.sql.*" %>

    <%
            Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");             
            Connection  conn=null;  
    conn = DriverManager.getConnection("jdbc:odbc:arc", "", "");  
    out.println ("Database Connected.");
    %>
Share:
10,332
dali1985
Author by

dali1985

Updated on July 10, 2022

Comments

  • dali1985
    dali1985 almost 2 years

    I would like to ask you how can I connect a MS access database in JSP pages?Do you know any ready class which I can use?I am using Netbeans to create JSP pages!