(1) database-driven issues
Log4j:warn No Appenders could is found for logger (org.hibernate.cfg.Environment).
Log4j:warn Initialize the log4j system properly.
Exception in thread ' main ' Org.hibernate.HibernateException:JDBC Driver class not found: Com.microsoft.sqlserver.jdbc.SQLServerDriver
At Org.hibernate.connection.DriverManagerConnectionProvider.configure (Drivermanagerconnectionprovider.java :)
At Org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider (Connectionproviderfactory.java : 137)
At Org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider (Connectionproviderfactory.java : +)
At Org.hibernate.cfg.SettingsFactory.createConnectionProvider (settingsfactory.java:425)
At org.hibernate.cfg.SettingsFactory.buildSettings (settingsfactory.java:89)
At org.hibernate.cfg.Configuration.buildSettingsInternal (configuration.java:2119)
At org.hibernate.cfg.Configuration.buildSettings (configuration.java:2115)
At org.hibernate.cfg.Configuration.buildSessionFactory (configuration.java:1339)
At Com.test.Test.main (test.java:17)
caused By:java.lang.ClassNotFoundException:com.microsoft.sqlserver.jdbc.SQLServerDriver
At Java.net.urlclassloader$1.run (urlclassloader.java:200)
At java.security.AccessController.doPrivileged (Native Method)
At Java.net.URLClassLoader.findClass (urlclassloader.java:188)
At Java.lang.ClassLoader.loadClass (classloader.java:307)
At Sun.misc.launcher$appclassloader.loadclass (launcher.java:301)
At Java.lang.ClassLoader.loadClass (classloader.java:252)
At java.lang.ClassLoader.loadClassInternal (classloader.java:320)
At JAVA.LANG.CLASS.FORNAME0 (Native Method)
At java.lang.Class.forName (class.java:169)
At org.hibernate.util.ReflectHelper.classForName (reflecthelper.java:192)
At Org.hibernate.connection.DriverManagerConnectionProvider.configure (Drivermanagerconnectionprovider.java : +)
... 8 More
Solve:
(1) cannot find this jar package, are you sure you have imported it? If the Web project is put into the Lib folder under Web-inf, the Java project needs add to build path.
(2) you find out if you have any com.microsoft.sqlserver.jdbc.SQLServerDriver in this jar package. If not, the jar package is not correct.
(3) See if the jar package isCom.microsoft.sqlserver.jdbc . SQLServerDriver some jar packages are com.microsoft jdbc . SQL Server
: Click to open link
Two annotationconfiguration problems
Questions: Anannotationconfiguration instance is required to use <mappingclass= "Com.model.TeacherInfo"/>
Learn hibernate recently. An attempt was made to map the Pojo class using XML and annotation two ways, with two classes: Student and teacher. The former uses XML files to map classes and attributes, which use annotation to map classes and attributes and place them under a project. Hibernate configuration file--hibernate.cfg.xml is located under the SRC folder. When the unit is tested, run the following code. will produce an exception.
Configuration cfg = new configuration (); Sessionfactory SF = Cfg.configure (). Buildsessionfactory ();
Exception information is: Org.hibernate.MappingException:An Annotationconfiguration instance are required to use <mapping class= " Com.model.TeacherInfo "/>
Cause Analysis:
Hibernate config file, if with <mapping class= "Com.model.TeacherInfo"/>, then the mapping class. used the annotation way.
When initializing the configuation. Annoationconfiguration should be used, such as the following code:
Configuration cfg = new annoationconfiguration (); Sessionfactory SF = Cfg.configure (). Buildsessionfactory ();
Assume. When you are mapping. If you have not used annotation, use a configuration.
[Hibernate Development Road] (2) Hibernate problem