[hibernate-issues] [Hibernate-JIRA] Closed: (HHH-7290) The JDBC Driver will not be loaded in some case

Steve Ebersole (JIRA) noreply at atlassian.com
Tue May 1 19:20:50 EDT 2012


     [ https://hibernate.onjira.com/browse/HHH-7290?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Steve Ebersole closed HHH-7290.
-------------------------------

    Resolution: Duplicate

> The JDBC Driver will not be loaded in some case
> -----------------------------------------------
>
>                 Key: HHH-7290
>                 URL: https://hibernate.onjira.com/browse/HHH-7290
>             Project: Hibernate ORM
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 4.1.2
>         Environment: hibernate 4.1.2
> tomcat 7.0.27
> mysql-connector 5.1.19
>            Reporter: chiwei
>
> Before v4.1.2,The method "org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl.configure" use "Class.forName" load JDBC Driver.
> The version 4.1.2, this method use "serviceRegistry.getService(ClassLoaderService.class)" get a instance of org.hibernate.service.classloading.internal.ClassLoaderServiceImpl, and call method "classForName" to load JDBC Driver.
> The method "classForName" use classloader.loadClass load JDBC Driver. There are some different to "Class.forName".
> "classForName" only load class to memory.
> "Class.forName" load class to memory and call the class's static block.
> The JDBC Driver must be register itself to JDBC's DriverManager at the static block. because "classForName" not call static block, JDBC Driver will not register.
> JDBC4.0 has SPM, so sometimes JDBC can find and register driver automatic, but the SPM seek class is different from classloader, so classloader can fina a class, SPM maybe miss.
> If SPM can not find the driver, SPM is not work, and hibernate will not get connection.
> e.g. the JDBC Driver jar put to <tomcat>\lib, SPM will not find the driver(default config of tomcat), so the driver not register. the "classForName" can find and load the driver, but the driver not register too, hibernate can not get a connection.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

       



More information about the hibernate-issues mailing list