|
From: Rod J. <rod...@in...> - 2004-03-30 06:09:16
|
+1
----- Original Message -----
From: "Thomas Risberg" <tho...@tr...>
To: <spr...@li...>
Sent: Tuesday, March 30, 2004 3:54 AM
Subject: [Springframework-developer] SQLErrorCodesFactory Product Name
lookup
> I have been watching my logs and the constant lookup of the database
> product name is bothering me. Colin had the same issue a while ago, but
> we never really resolved it. I have a potential solution which entails
> storing the hash code of the datasource along with the retreived
> database product name in a static HashMap. Next time, before looking up
> the name we could check this HashMap and pull the name from there if it
> is found. Can anyone see a flaw in this solution? Any chance of two
> datasource objects having the same hash code? Any chance of a
> datasource switching to a different database while we are running?
>
> Here is the added code:
>
> public SQLErrorCodes getErrorCodes(DataSource ds) {
> // Lets avoid looking up database product info if we can.
> Integer dataSourceHash = new Integer(ds.hashCode());
> if (dataSourceProductName.containsKey(dataSourceHash)) {
> String dataSourceDbName =
> (String)dataSourceProductName.get(dataSourceHash);
> logger.info("Database Product found in cache {" +
> dataSourceHash + "}. Name is " + dataSourceDbName);
> return getErrorCodes(dataSourceDbName);
> }
> // We could not find it - got to look it up.
> logger.info("Looking up default SQLErrorCodes for DataSource");
> ... (this part is already there)
>
> Thomas
>
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by: IBM Linux Tutorials
> Free Linux tutorial presented by Daniel Robbins, President and CEO of
> GenToo technologies. Learn everything from fundamentals to system
> administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
> _______________________________________________
> Springframework-developer mailing list
> Spr...@li...
> https://lists.sourceforge.net/lists/listinfo/springframework-developer
>
|