Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-28-2008, 06:30 PM
Member
 
Join Date: Apr 2008
Posts: 12
Fleur is on a distinguished road
ms access jdbc query problem
Dear Forum,
I'm a complete java newby so please bear with me :/

I'm trying some things out with java and ms access.
I manage to connect to my db, and get data from a table. However I'm running into problems when I need data from 2 related tables.
The following query works fine in access

Code:
select * from table1 t1, table2 t2
i get a column not found error when trying to get the data in java using
Code:
table1id = rs.getInt("t1.Id");
rs is a resultset from the executed query and works fine when i use
Code:
select * from table1
I can't seem to find an example with google of a 2 table query

Can anyone point me in the right direction?

Cheers!

f.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 04-28-2008, 08:32 PM
danielstoner's Avatar
Senior Member
 
Join Date: Apr 2008
Location: Canada
Posts: 191
danielstoner is on a distinguished road
Try to use rs.getMetaData() to see what are the column names. I don't think you will get the column names prefixed with table names. On the other hand "select *" is not such a good idea. It is way better to specify what columns you want exactly and in what order and to specify your own names in case of duplication.
One thing I don't understand is the purpose of your query. I don't know Access but it looks like you are gonna get a cartesian product of all the rows in the two tables. Is this what you want?
__________________
Daniel @ [
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
]
Language is froth on the surface of thought
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 04-30-2008, 07:55 PM
Member
 
Join Date: Apr 2008
Posts: 12
Fleur is on a distinguished road
2WIMC: the error was in the following line:

Quote:
Originally Posted by Fleur View Post
Code:
table1id = rs.getInt("t1.Id");
The name of the column in the rs is "Id" and NOT "t1.Id"
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Jdbc problem abhiN Database 1 03-21-2008 06:10 AM
JDBC select problem abhiN Database 0 03-12-2008 09:09 AM
Problem in Servlet with JDBC *New Programer* Java Servlet 2 12-20-2007 10:15 AM
JDBC problem Swamipsn New To Java 1 08-13-2007 07:05 PM
JDBC problem peiceonly Threads and Synchronization 2 08-03-2007 02:42 PM


All times are GMT +3. The time now is 07:29 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org