dcsimg
Column alias problem
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Kevin_Black
Posted On:   Tuesday, May 13, 2003 11:04 PM

Is it possible to do something like this using JDBC: SELECT tbl.a,count(tbl.a) AS foo FROM tbl GROUP BY tbl.a ORDER BY foo; This is a legit statement in MySQL but for some reason I get: java.lang.StringIndexOutOfBoundsException: String index out of range: -1 Here is the actual select: String DB_Query = "SELECT checkpoint.date_time, checkpoint.user, count(checkpoint.user) AS counter, action.action FROM checkpoint,action WHERE checkpoint.action = action.action_uid AND action.action = 'authcrypt' and TO_DAYS(NOW()) - TO_DAYS(checkpoint.date_time) <=30 "+TimeSelect_List[time_index]+" GROUP BY checkpoint.user ORDER BY counter DESC";    More>>

Is it possible to do something like this using JDBC:
SELECT tbl.a,count(tbl.a) AS foo FROM tbl GROUP BY tbl.a ORDER BY foo;




This is a legit statement in MySQL but for some reason I get:

java.lang.StringIndexOutOfBoundsException: String index out of range: -1




Here is the actual select:


String DB_Query = "SELECT checkpoint.date_time, checkpoint.user, count(checkpoint.user) AS counter, action.action FROM checkpoint,action WHERE checkpoint.action = action.action_uid AND action.action = 'authcrypt' and TO_DAYS(NOW()) - TO_DAYS(checkpoint.date_time) <=30 "+TimeSelect_List[time_index]+" GROUP BY checkpoint.user ORDER BY counter DESC";




This select works fine if I remove the "AS counter" and ORDER BY. Any ideas? I have spend hours on the mysql, google, and Sun sites looking for an answer and have found nothing...

   <<Less

Re: Column alias problem

Posted By:   Frank_Boehme  
Posted On:   Wednesday, May 14, 2003 12:38 AM

The Exception you get is not from JDBC. It looks like time_index is the Problem. A problem with the SQL/JDBC stuff would always throw a SQLException.


I think you have to reevaluate the surrounding code...



Hope that helps


Frank

About | Sitemap | Contact