On Tue, Apr 20, 2010 at 3:00 PM, Shinan Kassam <shin...@gmail.com> wrote:
>
> I currently have custom authentication working using JDBCRealm. Hence, I
> have some database parameters in server.xml as well as my application. Is it
> possible to use a portion of the URL as a parameter to connect to a
> different database.
>

shot from the hip:

- specify all databases available inside your context.xml-file

- from the url, read a parameter (such as "&customer=scrooge")

- depending on the parameter, create the datasource:


                        try {
                                Context env = (Context) new 
InitialContext().lookup("java:comp/env");
                                dbDS = (DataSource) env.lookup(customer);
                                if (dbDS == null) {
                                        logger.error("seems that '" + 
dataSourceName + "' is an unknown
DataSource");
                                        throw new ServletException("'" + 
dataSourceName + "' is an
unknown DataSource");
                                }
                        } catch (NamingException e) {
                                logger.error("Exception caught:", e);
                                throw new ServletException(e);
                        }

hth

gregor
-- 
just because you're paranoid, don't mean they're not after you...
gpgp-fp: 79A84FA526807026795E4209D3B3FE028B3170B2
gpgp-key available
@ http://pgpkeys.pca.dfn.de:11371
@ http://pgp.mit.edu:11371/
skype:rc46fi

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to