Solved

Access Parameter querys in DMX with JSP

Posted on 2004-03-20
13
216 Views
Last Modified: 2010-04-01
hey i have an access data base
with many parameter queries
 i was wondering if it is possible to have the same queries incorporated into dreamweaver
if so how exactly
i am using Tomcat and JSP
i'm sure it is possible but have no idea where to begin
any pointers would be great

bit like
select stuff
from tables
where value= item on dropdown list selected by user

Gar
0
Comment
Question by:Gar04
  • 4
  • 3
  • 3
  • +2
13 Comments
 
LVL 13

Expert Comment

by:copyPasteGhost
ID: 10642702
do you mean using the results form a form to build a sql query?
Ghost
0
 
LVL 92

Expert Comment

by:objects
ID: 10642718
<%@ page import="java.util.*, java.sql.*" %>


<%
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = null;
PreparedStatement ps = null;
try
{
  con = DriverManager.getConnection("jdbc:odbc:mydb");
  ps = con.prepareStatement("select a, b from table where c=?");
  ps.setString(1, request.getParameter("c"));
  ResultSet rs = ps.executeQuery();
  while (rs.next())
  {
     Object a = rs.getObject("a");
     Object b = rs.getObject("b");
     // do what you want with results
  }
}
%>
0
 

Author Comment

by:Gar04
ID: 10644317
hey objects thanks for the code
would it be possible for you
to explain to me briefly how it works
as i am a bit unsure??
gaz
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 10644599
>> with many parameter queries
Haven't use MSAcces for a long while, but if my memery serves me, you'll need to use callable statement to call MS-Access parameter queries as well as update/delete/instead queries.

I'll try to see if I can find more information for you.
0
 

Author Comment

by:Gar04
ID: 10645039
thanks
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 10645051
I could find the webpage that I came acrossed about that topic, but I found something in my old code, there is an example of how to call into MS Access Parameter Query Object, you can use similar interface to call other type of MS Access Query, like append, update, insert and delete query.

CallableStatement cs = null;
cs = conn.prepareCall("{ call query1( ? ) }");
cs.setInt(1, 12 ); //depend on parameter type, you'll use setString, setDouble and etc.
//  more set statement if you have more parameters.
ResultSet rs = cs.executeQuery();
while (rs.next()) {
    ......
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 14

Expert Comment

by:kennethxu
ID: 10645053
I meant I COULDN'T find the webpage. :)
0
 
LVL 92

Expert Comment

by:objects
ID: 10645109
> to explain to me briefly how it works

It makes a queuy on the database using a request parameter.
0
 
LVL 92

Expert Comment

by:objects
ID: 10645117
// get connection to database
 con = DriverManager.getConnection("jdbc:odbc:mydb");
// create query statement
  ps = con.prepareStatement("select a, b from table where c=?");
// bind request parameter 'c' to first query statement
// eg. if queury contains ?c=3 the query would become:
// select a, b from table where c=3
  ps.setString(1, request.getParameter("c"));
// execute the queury
  ResultSet rs = ps.executeQuery();
// loop thru the results one row at a time
  while (rs.next())
  {
// get value of column 'a'
     Object a = rs.getObject("a");
// get value of column 'b'
     Object b = rs.getObject("b");
     // do what you want with results
  }
0
 

Author Comment

by:Gar04
ID: 10777694
Hey I eventually used something like this:

<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" %>
 <% Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn = null;
CallableStatement cs = null;
try
{
  conn = DriverManager.getConnection("jdbc:odbc:BillBoardCompany");
  cs = conn.prepareCall("{Call SiteSearchQ(?, ?, ?)}");         >>>>>>>>>>>>>>>>>>>>this calls the MS Access Query and then sends the
                                                                                       >>>>>>>>>>>>>>>>>>>> necessary parameters to the query
 
  String siteName = request.getParameter("SiteName");
  if( siteName == null ) siteName = "";
  int selCyc=Integer.parseInt( request.getParameter("SelectCyc"));
  int year=Integer.parseInt( request.getParameter("SelectYear"));
 
     cs.setString(1, siteName );
    cs.setInt(2, selCyc );
    cs.setInt(3, year);
   
  ResultSet rs = cs.executeQuery();
  %>
0
 
LVL 92

Expert Comment

by:objects
ID: 10778723
is it working ok?
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 10802132
Closed, 500 points refunded.
modulo
Community Support Moderator
Experts Exchange
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
form submissions on a web page 2 143
xjc and jaxb 2 90
Multiple Images Upload [JSP Web-application] 3 37
thymeleaf natural templating vs JSP 2 69
Knowledge base software has turned out to be a quite reliable method for storing information, promoting collaborative work and for sharing valuable input and solutions.However, some organizations are trying to develop a knowledge base that works wit…
: Microsoft Office Collaborate for free and online versions of Microsoft  Word, Excel, Powerpoint, OneNote, Onedrive , Email, Calendar etc. In short we can say that Microsoft office is a suite of servers, applications and services developed by  Micr…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

863 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

23 Experts available now in Live!

Get 1:1 Help Now