Solved

Getting data from an MS Access Database

Posted on 2002-05-28
4
297 Views
Last Modified: 2010-04-01
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
Comment
Question by:DoughBoy
  • 2
4 Comments
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 7040939
I think you need to use DSN to connect to M$ Access database..
0
 
LVL 6

Accepted Solution

by:
kotan earned 100 total points
ID: 7040950
0
 
LVL 6

Expert Comment

by:kotan
ID: 7040951
0
 

Author Comment

by:DoughBoy
ID: 7042604
thanks very much
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

We have come a long way with backup and data protection — from backing up to floppies, external drives, CDs, Blu-ray, flash drives, SSD drives, and now to the cloud.
Find out what the Office 365 disclaimer function is, why you would use it and its limited ability to create Office 365 signatures.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now