Solved

Getting data from an MS Access Database

Posted on 2002-05-28
4
301 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 51

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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Fisheye tool 2 122
java beans and EJBs 5 201
HTML5 vs JSP - REST based application development 4 1,350
Looking for some programs to resell or buy source codes 1 78
Original post  on Monitis Blog. Web performance monitoring is broken into two camps: passive and active. Passive monitoring is defined as looking at real-world historical performance by monitoring actual log-ins, site hits, clicks, requests for…
Adults who share images on social media aren’t the only ones who need to worry about their privacy. Our culture’s tendency to share every move and celebration affects the privacy of our children, too.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

733 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