db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Knut Anders Hatlen <knut.hat...@oracle.com>
Subject Re: Java DB / Apache Derby Table Functions,current user?
Date Mon, 09 Dec 2013 09:30:07 GMT
Frans Verster <fverster@gmail.com> writes:

> Hi Guys and Girls,
> Sorry to bother.. I am making some Java DB / Apache Derby Table
> Functions, working very nice. I need to know the user querying the
> function to return only his/her items. How can I get the
> session/login/current user?

Hi Frans,

The SESSION_USER function returns the name of the user that invoked the
table function. Something like this should do the trick, I think:

    public static ResultSet tablefunc() throws SQLException {
        String user;
        try (Connection c = DriverManager.getConnection("jdbc:default:connection");
                Statement stmt = c.createStatement();
                ResultSet rs = stmt.executeQuery("values session_user")) {
            user = rs.getString(1);

        return createResultSetForUser(user);

Hope this helps,

Knut Anders

View raw message