DoughBoy
asked on
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("curr label"));
//what driver do I need????????????
Class.forName("some.class. odbc.ms.ac cess.Drive r");
// what Parameters do I need????????????? for an
// MS Access database with or with a DSN reference.
Connection conn = DriverManager.getConnectio n("odbc:ds n://mymdbf ile", "someuser-not-needed", "somepwd-not-needed");
PreparedStatement stmt1 = conn.prepareStatement("sel ect 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>
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("curr
//what driver do I need????????????
Class.forName("some.class.
// what Parameters do I need????????????? for an
// MS Access database with or with a DSN reference.
Connection conn = DriverManager.getConnectio
PreparedStatement stmt1 = conn.prepareStatement("sel
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>
I think you need to use DSN to connect to M$ Access database..
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks very much