users@glassfish.java.net

Re: JSP: Want to retrieve unknown number of rows

From: Hadraba Petr <hadrabap_at_bluetone.cz>
Date: Thu, 17 Jan 2008 21:11:33 +0100

Hi,

my approach is very simple.

If you need to display user activity for ten days ago, I see several
simple solutions:
 - you can display ten entries,
 - or you can display ten days.

I don't know anythink about your database model, but consider the following:
 - One table with the following structure:
CREATE TABLE user_activities (
    ud_id BIGINT NOT NULL, -- primary key
    ud_user_id BIGINT NOT NULL, -- references the USERS table
    ud_login_time TIMESTAMP WITH TIME ZONE NOT NULL -- time of the login
);

In the first case you can use the following SQL statement:
SELECT
    ua.ud_login_time
FROM
    user_activities ua
WHERE
    ua.ud_user_id = ?
ORDER BY
    us.ud_login_time DESC
LIMIT 10;

In the second case you just need to group all logins for specified
user by day and then select ten entries.

I think, your issue is a little bit out of scope this mailing list
because of I don't see any relation to Glassfish. If you want or need
more help, feel free to contact me directly at hadrabap_at_gmail.com.

PETR


On Jan 17, 2008 5:05 PM, <glassfish_at_javadesktop.org> wrote:
> Yep, user activity for past 10days
> [Message sent by forum member 'shopperswing' (shopperswing)]
>
> http://forums.java.net/jive/thread.jspa?messageID=254448
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>