Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

SELECT DISTINCT in MySQL gives error...

843836Oct 2 2003 — edited Oct 3 2003
Anyone help with this one - I'm sure it's easy.

I have a working bean for a jsp where the statement sent to the QUERY is >> private String "SELECT * FROM mytablename ORDER BY afieldname <<. It works fine and there's no overt problems. But I dont want to return all the >> hasNext in the resultSet rs << To see the working example of why, log in at www.klaatu2u.com and go to the "ballets" menu item.
I'm trying to modify the query string to
private String "SELECT DISTINCT afieldname FROM mytablename ORDER BY afieldname " << and it's giving me a column index out of range error 3 > 1 error. As far as I can tell this comes from the resultset class in the see here below
//error i keep getting...from mysql/jdbc2/
// if (columnIndex < 1 || columnIndex > Fields.length) {
// throw new java.sql.SQLException("Column Index out of range ( " + columnIndex + " > " + Fields.length + ").", "S1002");
// }

At any rate it is erroring on my mod'd query string. No clue as to why it wont see the column index properly. I have tried "SELECT DISTINCT afieldname FROM tablename WHERE afieldname = '*' " and it doesnt give the error, just no resultset.

I'm using NETBEANS for my compiler :-/ , and mysql connector-j. I'm doing a lot of other fun stuff with it (stringtokenizing data for SPEED!) and all works well - just the DISTINCT myfieldname is no-go.

No I'm not to smart - but could sure use help anyway. Thanx much for anyone who responds...
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 31 2003
Added on Oct 2 2003
1 comment
259 views