Getting data from an MS Access Database

Hi All,
Below is my psuedo code JSP page. What do I need to adjust in order to connect to an MS Access MDB file with or without a DSN reference, open the database, search and retrieve a string from the datbase.


//what other packages should I import
<%@ page import="java.sql.*" %>

String sDefinition = "";
String sLabelString = "";

sLabelString = request.getParameter("currlabel"));

//what driver do I need????????????
// what Parameters do I need????????????? for an
// MS Access database with or with a DSN reference.
Connection conn = DriverManager.getConnection("odbc:dsn://mymdbfile", "someuser-not-needed", "somepwd-not-needed");
PreparedStatement stmt1 = conn.prepareStatement("select resultstring from mytable where column1data =" + string1 + " and column2data = " + sLabelString);

ResultSet rs = stmt1.executeQuery();

while (
sDefinition = rs.getString(1);

<title>ODBC Result String</title>

<p> <% =sDefinition %> </p>

Who is Participating?
Ryan ChongCommented:
I think you need to use DSN to connect to M$ Access database..
DoughBoyAuthor Commented:
thanks very much
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.