|
From: Colin S. <col...@ex...> - 2004-02-22 02:56:39
|
I've been sitting here all day watching logs go by as I try to get a system into production, and seeing a lot of pauses as the new JdbcTemplate(dataSource) in JdbcHelper causes, every single time JdbcHelper is created, the exception metadata to be pulled from the DB. Now this is code using Spring slightly post RC1. I realize JdbcHelper has gone away, but the same thing happens of course when you just do a 'new JdbcTemplate(dataSource)' directly. I don't know why JdbcAccessor (and hence JdbcTemplate) really needs to eager init the exception translator. The access method is synchronized, so there should be no issues letting it lazy init. I would like to remove this eager init (in afterPropertiesSet()) of the exception translator. Please let me know if you have a problem with this. I was thinking that if somebody wants to still allow it to be eagerly inited, for the case where JdbcTemplate is coming out of a beanfactory/context then we can add a 'lazyInitExceptionTranslator' property, which would default to true. Regards, Colin |
|
From: <tri...@tr...> - 2004-02-22 03:53:30
|
Colin, I think Rod did make it lazy init at some point, but the problem was that some jdbc driver (I think MS SQL Server) was not letting us use the connection after some exception was thrown. This prevented us from loading the meta data and the translation mapping. All we really need is the database product name, so if you could set that explicitly, then we don't need to look it up. There is already code in SQLErrorCodesFactory to avoid the database metadata lookup if you pass in a database product name. public SQLErrorCodes getErrorCodes(String dbName) I think all you need now is to do is create a custom SQLErrorCodeSQLExceptionTranslator where you set the database product name explicitly and load the error codes using this rather than the data source. Thomas Quoting Colin Sampaleanu <col...@ex...>: > I've been sitting here all day watching logs go by as I try to get a > system into production, and seeing a lot of pauses as the > new JdbcTemplate(dataSource) > in JdbcHelper causes, every single time JdbcHelper is created, the > exception metadata to be pulled from the DB. > > Now this is code using Spring slightly post RC1. I realize JdbcHelper > has gone away, but the same thing happens of course when you just do a > 'new JdbcTemplate(dataSource)' directly. > > I don't know why JdbcAccessor (and hence JdbcTemplate) really needs to > eager init the exception translator. The access method is synchronized, > so there should be no issues letting it lazy init. > > I would like to remove this eager init (in afterPropertiesSet()) of the > exception translator. Please let me know if you have a problem with > this. I was thinking that if somebody wants to still allow it to be > eagerly inited, for the case where JdbcTemplate is coming out of a > beanfactory/context then we can add a 'lazyInitExceptionTranslator' > property, which would default to true. > > Regards, > Colin > > > > ------------------------------------------------------- > SF.Net is sponsored by: Speed Start Your Linux Apps Now. > Build and deploy apps & Web services for Linux with > a free DVD software kit from IBM. Click Now! > http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click > _______________________________________________ > Springframework-developer mailing list > Spr...@li... > https://lists.sourceforge.net/lists/listinfo/springframework-developer > |
|
From: Colin S. <col...@ex...> - 2004-02-22 13:30:19
|
Hmm, too bad. The problem is that if you can get your hands on the database name, which is something that you would never want to hard-code in your code, then you can probably also just get your hands on a jdbcTemplate instance from the context, used as a singleton. I was hoping to just make 'new jdbcTemplate(datasource)' as efficient as that approach... tri...@tr... wrote: >Colin, > >I think Rod did make it lazy init at some point, but the problem was that some >jdbc driver (I think MS SQL Server) was not letting us use the connection after >some exception was thrown. This prevented us from loading the meta data and the >translation mapping. > >All we really need is the database product name, so if you >could set that explicitly, then we don't need to look it up. > >There is already code in SQLErrorCodesFactory to avoid the database metadata >lookup if you pass in a database product name. > > public SQLErrorCodes getErrorCodes(String dbName) > >I think all you need now is to do is create a custom >SQLErrorCodeSQLExceptionTranslator where you set the database product name >explicitly and load the error codes using this rather than the data source. > >Thomas > > > >Quoting Colin Sampaleanu <col...@ex...>: > > > >>I've been sitting here all day watching logs go by as I try to get a >>system into production, and seeing a lot of pauses as the >> new JdbcTemplate(dataSource) >>in JdbcHelper causes, every single time JdbcHelper is created, the >>exception metadata to be pulled from the DB. >> >>Now this is code using Spring slightly post RC1. I realize JdbcHelper >>has gone away, but the same thing happens of course when you just do a >>'new JdbcTemplate(dataSource)' directly. >> >>I don't know why JdbcAccessor (and hence JdbcTemplate) really needs to >>eager init the exception translator. The access method is synchronized, >>so there should be no issues letting it lazy init. >> >>I would like to remove this eager init (in afterPropertiesSet()) of the >>exception translator. Please let me know if you have a problem with >>this. I was thinking that if somebody wants to still allow it to be >>eagerly inited, for the case where JdbcTemplate is coming out of a >>beanfactory/context then we can add a 'lazyInitExceptionTranslator' >>property, which would default to true. >> >>Regards, >>Colin >> >> >> |
|
From: <tri...@tr...> - 2004-02-23 02:25:13
|
Maybe we could make lazy init it configurable with the default beeing eager init. I'll give it some thouhgt this week - maybe we can squeeze it in before RC2. Thomas Quoting Colin Sampaleanu <col...@ex...>: > Hmm, too bad. The problem is that if you can get your hands on the > database name, which is something that you would never want to hard-code > in your code, then you can probably also just get your hands on a > jdbcTemplate instance from the context, used as a singleton. I was > hoping to just make 'new jdbcTemplate(datasource)' as efficient as that > approach... > > > tri...@tr... wrote: > > >Colin, > > > >I think Rod did make it lazy init at some point, but the problem was that > some > >jdbc driver (I think MS SQL Server) was not letting us use the connection > after > >some exception was thrown. This prevented us from loading the meta data and > the > >translation mapping. > > > >All we really need is the database product name, so if you > >could set that explicitly, then we don't need to look it up. > > > >There is already code in SQLErrorCodesFactory to avoid the database > metadata > >lookup if you pass in a database product name. > > > > public SQLErrorCodes getErrorCodes(String dbName) > > > >I think all you need now is to do is create a custom > >SQLErrorCodeSQLExceptionTranslator where you set the database product name > >explicitly and load the error codes using this rather than the data source. > > > >Thomas > > > > > > > >Quoting Colin Sampaleanu <col...@ex...>: > > > > > > > >>I've been sitting here all day watching logs go by as I try to get a > >>system into production, and seeing a lot of pauses as the > >> new JdbcTemplate(dataSource) > >>in JdbcHelper causes, every single time JdbcHelper is created, the > >>exception metadata to be pulled from the DB. > >> > >>Now this is code using Spring slightly post RC1. I realize JdbcHelper > >>has gone away, but the same thing happens of course when you just do a > >>'new JdbcTemplate(dataSource)' directly. > >> > >>I don't know why JdbcAccessor (and hence JdbcTemplate) really needs to > >>eager init the exception translator. The access method is synchronized, > >>so there should be no issues letting it lazy init. > >> > >>I would like to remove this eager init (in afterPropertiesSet()) of the > >>exception translator. Please let me know if you have a problem with > >>this. I was thinking that if somebody wants to still allow it to be > >>eagerly inited, for the case where JdbcTemplate is coming out of a > >>beanfactory/context then we can add a 'lazyInitExceptionTranslator' > >>property, which would default to true. > >> > >>Regards, > >>Colin > >> > >> > >> > > > > > ------------------------------------------------------- > SF.Net is sponsored by: Speed Start Your Linux Apps Now. > Build and deploy apps & Web services for Linux with > a free DVD software kit from IBM. Click Now! > http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click > _______________________________________________ > Springframework-developer mailing list > Spr...@li... > https://lists.sourceforge.net/lists/listinfo/springframework-developer > |
|
From: Colin S. <col...@ex...> - 2004-02-23 03:50:38
|
Well, it's quite easy to make it configurable (in the fashion I mentioned below). However, somebody putting it in the context, where it's easy to configure, would probably not even care about the eager init, since they'll be using it as a singleton. On the other hand, somebody using 'new JdbcTemplate(datasource, eagerInitFlag), who would benefit from not doing the eager init unless absolutely necessary, since they are using non-singleton instances, probably has no easy way to configure that value. The whole point was to not have to pass both a datasource and jdbctemplate to various component, but only a datasource. If an eager init config flag is passed, then the jdbctemplate can just as readily be passed. There are probably still a few edge cases where the flag would be useful though... Regards, Colin tri...@tr... wrote: >Maybe we could make lazy init it configurable with the default beeing eager >init. I'll give it some thouhgt this week - maybe we can squeeze it in before RC2. > >Thomas > >Quoting Colin Sampaleanu <col...@ex...>: > > > >>Hmm, too bad. The problem is that if you can get your hands on the >>database name, which is something that you would never want to hard-code >>in your code, then you can probably also just get your hands on a >>jdbcTemplate instance from the context, used as a singleton. I was >>hoping to just make 'new jdbcTemplate(datasource)' as efficient as that >>approach... >> >> >>tri...@tr... wrote: >> >> >> >>>Colin, >>> >>>I think Rod did make it lazy init at some point, but the problem was that >>> >>> >>some >> >> >>>jdbc driver (I think MS SQL Server) was not letting us use the connection >>> >>> >>after >> >> >>>some exception was thrown. This prevented us from loading the meta data and >>> >>> >>the >> >> >>>translation mapping. >>> >>>All we really need is the database product name, so if you >>>could set that explicitly, then we don't need to look it up. >>> >>>There is already code in SQLErrorCodesFactory to avoid the database >>> >>> >>metadata >> >> >>>lookup if you pass in a database product name. >>> >>> public SQLErrorCodes getErrorCodes(String dbName) >>> >>>I think all you need now is to do is create a custom >>>SQLErrorCodeSQLExceptionTranslator where you set the database product name >>>explicitly and load the error codes using this rather than the data source. >>> >>>Thomas >>> >>> >>> >>>Quoting Colin Sampaleanu <col...@ex...>: >>> >>> >>> >>> >>> >>>>I've been sitting here all day watching logs go by as I try to get a >>>>system into production, and seeing a lot of pauses as the >>>> new JdbcTemplate(dataSource) >>>>in JdbcHelper causes, every single time JdbcHelper is created, the >>>>exception metadata to be pulled from the DB. >>>> >>>>Now this is code using Spring slightly post RC1. I realize JdbcHelper >>>>has gone away, but the same thing happens of course when you just do a >>>>'new JdbcTemplate(dataSource)' directly. >>>> >>>>I don't know why JdbcAccessor (and hence JdbcTemplate) really needs to >>>>eager init the exception translator. The access method is synchronized, >>>>so there should be no issues letting it lazy init. >>>> >>>>I would like to remove this eager init (in afterPropertiesSet()) of the >>>>exception translator. Please let me know if you have a problem with >>>>this. I was thinking that if somebody wants to still allow it to be >>>>eagerly inited, for the case where JdbcTemplate is coming out of a >>>>beanfactory/context then we can add a 'lazyInitExceptionTranslator' >>>>property, which would default to true. >>>> >>>>Regards, >>>>Colin >>>> >>>> >>>> |