Mysql's drive causes problems that Hibernate cannot run properly

xiaoxiao2021-03-06  40

This article is suitable for readingrs: I have seen Hibernate's Chinese documentation and personally try to use in the application, and successful people; at the same time, familiar with people connecting pools in Tomcat.

It turned out that the application of Hibernate was used, then it was used in the application; recently, there was time, continued learning, ready to try in the Web. I personally try it in accordance with Hibernate's Chinese Documentation "with the Cat".

Development Environment: JBuilder X, Tomcat 5.0.16, MySQL 4.0.16,

First, I used mySQL, I know that Mysql's JDBC driver has two kinds, one is a single JAR package (mysql-connector-java-3.1.6-bin.jar), download address: http://dev.mysql.com The "MySQL Connector / J 3.1" in the / downloads / page is recommended. Another is two JAR packages (mysql_comp.jar, mysql_uncomp.jar). The DRIVER_CLASS Writing of these two packages is different. The former is com.mysql.jdbc.driver, the latter is org.gjt.mm.mysql.driver.

I have always used two packages, because it does not have to take parameters after the URL is supported by the Chinese support, insert data, or data from the database. So this trial is also used.

First, according to the help document, it is done step by step. At that time, DB2 7.2 used in the office was configured with Server.xml, hibernate.cfg.xml, Cat.hbm.xml files all normal, run successfully. So I decided to try the MySQL database. The problem is also coming.

Drive two packets, put it under CommON / LIB, re-modify the server.xml file, Driver's writing is "org.gjt.mm.mysql.driver". Restart Tomcat, run the Test.jsp page, an error. Tomcat's console does not have an error message, just in the JSP page:

EXCEPTION

Javax.Servlet.ServletException

Org.apache.jasper.Runtime.pageContextImpl.doHandlepageException (pageContextimpl.java: 867)

Org.apache.jasper.Runtime.pageContextImpl.HandlepageException (pageContextImpl.java: 800)

Org.apache.jsp.test_jsp._jspservice (Test_jsp.java: 69)

Org.apache.jasper.Runtime.httpjspBase.Service (httpjspbase.java: 133)

Javax.servlet.http.httpservlet.service (httpservlet.java: 856)

Org.apache.jasper.Servlet.jspservletWrapper.Service (jspservletwrapper.java: 311)

Org.apache.jasper.servlet.jspservlet.ServiceJspfile (jspservlet.java: 301)

Org.apache.jasper.servlet.jspservlet.Service (jspservlet.java: 248)

Javax.servlet.http.httpservlet.service (httpservlet.java: 856)

Root Cause

Java.lang.exceptioninInitializerrror

Testpkg.hibernateutil. (hibernateutil.java: 16)

Org.apache.jsp.test_jsp._jspservice (Test_jsp.java: 49)

Org.apache.jasper.Runtime.httpjspBase.Service (httpjspbase.java: 133)

Javax.servlet.http.httpservlet.service (httpservlet.java: 856)

Org.apache.jasper.Servlet.jspservletWrapper.Service (jspservletwrapper.java: 311)

Org.apache.jasper.servlet.jspservlet.ServiceJspfile (jspservlet.java: 301)

Org.apache.jasper.servlet.jspservlet.Service (jspservlet.java: 248)

Javax.servlet.http.httpservlet.service (httpservlet.java: 856)

At that time, I re-examined the program, view the configuration file, and the same DB2, there is no big change. Suddenly depressed! ! !

The next few days are troubled by this problem. I use the connection pool directly in the JSP page. I have no such problem. I have used the two packages of the two packages. It is possible to run normally.

Yesterday, I suddenly thought about it, try the driver of a package, so modified the corresponding configuration, everything can be successful. Just can be inserted into Chinese, but it is a question mark when it takes out. So everyone should take parameters behind the URL.

Ok, I hope that the article helps the friends who have encountered the same problem. However, this may be small. If you have a better solution, I hope to provide a reference. 2005-01-28

转载请注明原文地址:https://www.9cbs.com/read-63343.html

New Post(0)