ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Clinton Begin <clinton.be...@gmail.com>
Subject Re: To get the URL out of DataSource
Date Sat, 09 Jul 2005 21:00:36 GMT
Why not just grab it from the properties file? 

Cheers,
Clinton

On 7/7/05, Bing Qiao <qiaobing@gmail.com> wrote:
> 
> Dear all,
> 
> I need to get the URL string to show which environment (dev, test or
> production) the application is running in.
> 
> Here is what I did.
> /////////////////////////////////////////////////
> import org.apache.commons.dbcp.BasicDataSource;
> ...
> String environment = "";
> DataSource ds = sqlmap.getDataSource();
> 
> if (ds instanceof BasicDataSource) {
> StringTokenizer cnnString = new StringTokenizer( ( (BasicDataSource) 
> (ds)).
> getUrl(), ":");
> 
> /////////////////////////////////////////////
> 
> It works. But I'm not sure if it is the right way. Is the Datasource
> object returned from sqlmap really a BasicDataSource object?
> 
> Thanks very much for your attention!
> 
> Bqiao
>

Mime
View raw message