java - jdbc connection - socket connection -


a few days ago website crashed , showed me error:

java.lang.noclassdeffounderror: not initialize class com.omicc.hibernate.util.hibernateutil

so asked hosting company changes may have made. fixed problem , told me use jdbc connections instead of socket connections. using hibernate , c3p0 mysql , far know use jdbc connections.

<property name="connection.driver_class">com.mysql.jdbc.driver</property> 

so of guys know talking about? :d (and yes not answering now!)

edited>>>>

solved!, here did upgraded hibernate hibernate 3.5.0 3.6.1 , new hibernate required hibernate-jpa-2.0-api-1.0.0.final.jar , slf4j-simple1.6.1 . , problem solved. think hosting company updated hibernate.jar , caused reference problems.

rewrite hibernateutil doesn't instantiate in static block. instead make singleton synchronized getinstance. then

private static sessionfactory cache;  synchronized sessionfactory getinstance() throws sqlexception {  if (cache != null) return cache;  // try/catch , rethrow sqlexception try { class.forname("com.mysql.jdbc"); } exception (e) { throw new sqlexception(e); } // test connection jdbc // create non connection pooled raw connection, try/finally close // throw sql exception if fails testme()  // create sessionfactory .... build configuration object ....  try { sessionfactory me = ....buildsessionfactory } catch (runtimeexception e) { throw new sqlexception(e); } cache = me; return cache;  } 

some comments: people prefer unchecked exception, fine. reason doing raw connection once on startup tends bollix connection pool/hibernate less if sql server happens done. once initialize i've not had recovery issues. that's personal taste thing, , skip testme() well.

point way see exception occurring, , predict implicate connection hosting company :)


Comments