• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Microsoft Access Store Query

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am sure someone ask this question before but I can not find the topic using the searsh soooooo....
Would anyone know how to access a stored query in Microsoft Access using the ODBC-JDBC?
Thank you in advance.
 
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can select rows from an Access query just like you would select from an Access table. For example, once you have your Connection object you can do something like this:
 
Allen Tomas
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for replying.
However, I was actually looking helping in accessing a pre-defined query in access using jdbc connection. For example, in Access you could create a query and save as (for argument sake) myquery. Then in my java code, I want to access that query "myquery" and process it. It is sort of like a stored procedure in SQL Server.
Allen
 
Blake Minghelli
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Allen Tomas:
Thank you for replying.
However, I was actually looking helping in accessing a pre-defined query in access using jdbc connection. For example, in Access you could create a query and save as (for argument sake) myquery. Then in my java code, I want to access that query "myquery" and process it. It is sort of like a stored procedure in SQL Server.
Allen


That's exactly what that code is doing, just replace "query1" with "myquery". The code above does however assume that the "stored" query is a "select" query. If it is not a "select" query, then you can do this:

I'm not sure though if you can pass parameters using that method, so if your Access query is expecting some params, it probably won't work. I don't believe PreparedStatement or CallableStatement are supported.
 
Blake Minghelli
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I'm not sure though if you can pass parameters using that method


Out of curiousity, I tried this and it worked:
 
Allen Tomas
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you so much Blake. I'm curious. How does your stored query look like when you are passing it a parameter?
[ April 22, 2004: Message edited by: Allen Tomas ]
 
Blake Minghelli
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Allen Tomas:
Thank you so much Blake. I'm curious. How does your stored query look like when you are passing it a parameter?
[ April 22, 2004: Message edited by: Allen Tomas ]


I'm not sure I understand what you are asking, but... I created a query in Access and in the query designer, I added "[Enter param]" in the "Criteria" row of one of the query's columns. When you run the query in Access, you get an InputBox that asks the user to "Enter param". But when you do the "exec myquery..." in Java it uses the param supplied in the exec string.
Does that help?
 
Allen Tomas
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, Thank you again. It works.
[ April 23, 2004: Message edited by: Allen Tomas ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic