• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 305
  • Last Modified:

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.

TIA,
DoughBoy


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

<%
String sDefinition = "";
String sLabelString = "";

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

//what driver do I need????????????
Class.forName("some.class.odbc.ms.access.Driver");
         
// 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 (rs.next())
{
sDefinition = rs.getString(1);
}
rs.close();
conn.close();
%>

<html>
<head>
<title>ODBC Result String</title>
</head>
<body>

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

</body>
</html>
0
DoughBoy
Asked:
DoughBoy
  • 2
1 Solution
 
Ryan ChongCommented:
I think you need to use DSN to connect to M$ Access database..
0
 
DoughBoyAuthor Commented:
thanks very much
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now