-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 posts ] 
Author Message
 Post subject: Simple distrinct query
PostPosted: Mon Aug 11, 2008 2:33 pm 
Newbie

Joined: Thu Aug 07, 2008 3:41 pm
Posts: 14
I want to do this SQL:
Code:
"select distinct id, firstname, lastname, birthdate from clients"


So I made this up:
Code:
"select distinct id, firstname, lastname, birthdate from Client"


but I get this:
Quote:
java.lang.NumberFormatException: For input string: "firstname"


What am I doing wrong?


Top
 Profile  
 
 Post subject: Re: Simple distrinct query
PostPosted: Tue Aug 12, 2008 7:40 am 
Beginner
Beginner

Joined: Tue Sep 27, 2005 2:51 pm
Posts: 27
marcelk wrote:
I want to do this SQL:
Code:
"select distinct id, firstname, lastname, birthdate from clients"


So I made this up:
Code:
"select distinct id, firstname, lastname, birthdate from Client"


but I get this:
Quote:
java.lang.NumberFormatException: For input string: "firstname"


What am I doing wrong?


try
Code:
Select distinct(id), firstname, lastname, birthdate from Client


Dave

_________________
Dave Ziebol


Top
 Profile  
 
 Post subject: Re: Simple distrinct query
PostPosted: Tue Aug 12, 2008 8:25 am 
Newbie

Joined: Thu Aug 07, 2008 3:41 pm
Posts: 14
dziebol wrote:
marcelk wrote:
I want to do this SQL:
try
Code:
Select distinct(id), firstname, lastname, birthdate from Client

Dave


That didnt help, same error. Does anyone have an example for me?


Top
 Profile  
 
 Post subject: Re: Simple distrinct query
PostPosted: Tue Aug 12, 2008 8:28 am 
Beginner
Beginner

Joined: Tue Sep 27, 2005 2:51 pm
Posts: 27
marcelk wrote:
dziebol wrote:
marcelk wrote:
I want to do this SQL:
try
Code:
Select distinct(id), firstname, lastname, birthdate from Client

Dave


That didnt help, same error. Does anyone have an example for me?

It would be much easier to aid you if you posted the table format along with the database name being used.

Dave

_________________
Dave Ziebol


Top
 Profile  
 
 Post subject: Re: Simple distrinct query
PostPosted: Tue Aug 12, 2008 11:28 am 
Newbie

Joined: Thu Aug 07, 2008 3:41 pm
Posts: 14
Table name is CLIENTS

Layout:
ID Number (PRIMARY KEY)
FIRSTNAME Varchar2
LASTNAME Varchar2 64
BIRTHDATE Date 7
CYCLUS_ID Number (FOREIGN KEY AND PART OF PRIMARY KEY)

What I want is to show all clients, not I have duplicates because of the Foreign Key values in Cyclus ID.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 12, 2008 4:36 pm 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
How about?

Code:
select distinct c.id, c.firstname, c.lastname, c.birthdate from Client c


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 13, 2008 1:35 am 
Newbie

Joined: Thu Aug 07, 2008 3:41 pm
Posts: 14
nordborg wrote:
How about?

Code:
select distinct c.id, c.firstname, c.lastname, c.birthdate from Client c


Also tried that, I still get:
Code:
java.lang.NumberFormatException: For input string: "firstname"


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 13, 2008 2:43 am 
Newbie

Joined: Thu Jul 17, 2008 2:35 am
Posts: 5
Hi marcelk

This query is working perfectly fine
Code:
select distinct mod.ID , mod.FIRSTNAME from CLIENTS as mod


This doesn't work at your side then it means you must have not properly mapped the table with class

As you said it is showing
Code:
java.lang.NumberFormatException: For input string: "firstname"

This means
in Database table, the type of firstname is of varchar
and in class the datatype if firstname might be int or long

Just check it out

Hope this helped you

Thank you[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 13, 2008 4:41 am 
Newbie

Joined: Thu Aug 07, 2008 3:41 pm
Posts: 14
Thanks but, thats not the case.

The problem is that without distinct, it works (FROM Clients).

Why do i get strange results when using distinct?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 13, 2008 5:19 am 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
What is the rest of the stacktrace? Does this happen before or after the query has been executed on the database?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.