Re: jdbc works in java app, fails in servlet: "no suitable jdbc found"
От | Craig Ringer |
---|---|
Тема | Re: jdbc works in java app, fails in servlet: "no suitable jdbc found" |
Дата | |
Msg-id | 4C074A53.9020004@postnewspapers.com.au обсуждение исходный текст |
Ответ на | Re: jdbc works in java app, fails in servlet: "no suitable jdbc found" (Lew <noone@lewscanon.com>) |
Список | pgsql-jdbc |
On 3/06/2010 6:58 AM, Lew wrote: >> You can use the classloader that loaded the currently running object >> with: >> >> this.getClass().getClassLoader().loadClass('org.postgresql.Driver'); > > The driver should be loaded in a static context, not an instance > context. Furthermore, that code as shown will not compile. Oops, wrong quotes. Point. > Further > furthermore, I see nothing in the documentation for > 'ClassLoader#loadClass()' that promises to initialize the class, unlike > 'Class.forName()'. If the class is not initialized, the driver won't > register with the 'DriverManager'. I think you're selling a pig in a > poke here. Fair call - the beahaviour would depend on the classloader, and probably shouldn't be assumed. > Go with the Tomcat way and forget the kludgey direct uses of Java > reflection. The fact that I haven't done much in servelet environments kinda shows, I suspect. JNDI is certainly the way to go based on what you referred to. -- Craig Ringer
В списке pgsql-jdbc по дате отправления: