Use JSP to connect to the MySQL database

Source: Internet
Author: User

How to use JSP to connect to the MySQL database

Author: Jackie

 

I downloaded the message 1.0 on this site, but it was always unsuccessful to connect to the database (I used tomcat5.5.9, MySQL Server 5.0, jdk1.5.0 _ 06, these three items can be used normally .)
Type exception report

Message

Description the server encountered an internal error () that prevented it from fulfilling this request.

Exception

Org. Apache. Jasper. jasperexception:/ly. jsp (34,0) the value for the usebean class attribute Wu. JDBC is invalid.
Org. Apache. Jasper. compiler. defaulterrorhandler. jsperror (defaulterrorhandler. Java: 39)
Org. Apache. Jasper. compiler. errordispatcher. Dispatch (errordispatcher. Java: 405)
Org. Apache. Jasper. compiler. errordispatcher. jsperror (errordispatcher. Java: 146)
Org. Apache. Jasper. compiler. Generator $ generatevisitor. Visit (generator. Java: 1223)
Org. Apache. Jasper. compiler. node $ usebean. Accept (node. Java: 1116)
Org. Apache. Jasper. compiler. node $ nodes. Visit (node. Java: 2163)
Org. Apache. Jasper. compiler. node $ vismonitor. visitbody (node. Java: 2213)
Org. Apache. Jasper. compiler. node $ visitor. Visit (node. Java: 2219)
Org. Apache. Jasper. compiler. node $ root. Accept (node. Java: 456)
Org. Apache. Jasper. compiler. node $ nodes. Visit (node. Java: 2163)
Org. Apache. Jasper. compiler. generator. Generate (generator. Java: 3270)
Org. Apache. Jasper. compiler. compiler. generatejava (compiler. Java: 189)
Org. Apache. Jasper. compiler. compiler. Compiler (compiler. Java: 286)
Org. Apache. Jasper. compiler. compiler. Compiler (compiler. Java: 267)
Org. Apache. Jasper. compiler. compiler. Compiler (compiler. Java: 255)
Org. Apache. Jasper. jspcompilationcontext. Compile (jspcompilationcontext. Java: 556)
Org. Apache. Jasper. servlet. jspservletwrapper. Service (jspservletwrapper. Java: 293)
Org. Apache. Jasper. servlet. jspservlet. servicejspfile (jspservlet. Java: 291)
Org. Apache. Jasper. servlet. jspservlet. Service (jspservlet. Java: 241)
Javax. servlet. http. httpservlet. Service (httpservlet. Java: 802)

Note the full stack trace of the root cause is available in the Apache Tomcat/5.5.9 logs.

Date: 2005-12-05
→ Comments from netizens:
(Webmaster)
Usebean class attribute Wu. JDBC is invalid.

Maybe your class is not in the correct place, right?
You compile JDBC. Java into JDBC. Class
And put it under Web-INF/class?

(Jackie 2005-12-05)
The compilation is completed, but the database IP address does not know how to set it.
Is it placed under Web-INF/class or under Web-INF/class/Wu?
(Webmaster)
The IP address is the IP address of the machine where the database is installed.
It should be placed under Web-INF/class/Wu.
(Jackie 2005-12-06)
Type exception report

Message

Description the server encountered an internal error () that prevented it from fulfilling this request.

Exception

Org. Apache. Jasper. jasperexception
Org. Apache. Jasper. servlet. jspservletwrapper. Service (jspservletwrapper. Java: 370)
Org. Apache. Jasper. servlet. jspservlet. servicejspfile (jspservlet. Java: 291)
Org. Apache. Jasper. servlet. jspservlet. Service (jspservlet. Java: 241)
Javax. servlet. http. httpservlet. Service (httpservlet. Java: 802)

Root Cause

Java. Lang. nullpointerexception
Org. Apache. jsp. ly_jsp. _ jspservice (Org. Apache. jsp. ly_jsp: 90)
Org. Apache. Jasper. runtime. httpjspbase. Service (httpjspbase. Java: 97)
Javax. servlet. http. httpservlet. Service (httpservlet. Java: 802)
Org. Apache. Jasper. servlet. jspservletwrapper. Service (jspservletwrapper. Java: 322)
Org. Apache. Jasper. servlet. jspservlet. servicejspfile (jspservlet. Java: 291)
Org. Apache. Jasper. servlet. jspservlet. Service (jspservlet. Java: 241)
Javax. servlet. http. httpservlet. Service (httpservlet. Java: 802)

Note the full stack trace of the root cause is available in the Apache Tomcat/5.5.9 logs.

-------------------------------------------------------------------------------- What is going on here?

Or the database connection fails. (Webmaster)
I don't know what error is reported in the Tomcat background?
For example, there is no JDBC driver.
Wrong Database User Password?
Or the table does not contain these errors.
(Jackie 2005-12-06)
Dizzy, The JDBC driver is down, and the environment variables are set. The database user name and password are certainly correct. This error occurs again today. Let me see it.
HTTP status 500-

--------------------------------------------------------------------------------

Type exception report

Message

Description the server encountered an internal error () that prevented it from fulfilling this request.

Exception

Javax. servlet. servletexception: communication link failure: Java. Io. ioexception, underlying cause: unexpected end of input stream

** Begin nested exception **

Java. Io. ioexception
Message: unexpected end of input stream

Stacktrace:

Java. Io. ioexception: unexpected end of input stream
At com. MySQL. JDBC. mysqlio. readpacket (mysqlio. Java: 1096)
At com. MySQL. JDBC. mysqlio. dohandshake (mysqlio. Java: 626)
At com. MySQL. JDBC. Connection. createnewio (connection. Java: 1562)
At com. MySQL. JDBC. Connection. <init> (connection. Java: 491)
At com. MySQL. JDBC. nonregisteringdriver. Connect (nonregisteringdriver. Java: 346)
At java. SQL. drivermanager. getconnection (drivermanager. Java: 525)
At java. SQL. drivermanager. getconnection (drivermanager. Java: 171)
At org. Apache. jsp. _ 06_005f03_jsp. _ jspservice (Org. Apache. jsp. _ 06_005f03_jsp: 65)
At org. Apache. Jasper. runtime. httpjspbase. Service (httpjspbase. Java: 97)
At javax. servlet. http. httpservlet. Service (httpservlet. Java: 802)
At org. Apache. Jasper. servlet. jspservletwrapper. Service (jspservletwrapper. Java: 322)
At org. Apache. Jasper. servlet. jspservlet. servicejspfile (jspservlet. Java: 291)
At org. Apache. Jasper. servlet. jspservlet. Service (jspservlet. Java: 241)
At javax. servlet. http. httpservlet. Service (httpservlet. Java: 802)
At org. Apache. Catalina. Core. applicationfilterchain. internaldofilter (applicationfilterchain. Java: 252)
At org. Apache. Catalina. Core. applicationfilterchain. dofilter (applicationfilterchain. Java: 173)
At org. Apache. Catalina. Core. standardwrappervalve. Invoke (standardwrappervalve. Java: 213)
At org. Apache. Catalina. Core. standardcontextvalve. Invoke (standardcontextvalve. Java: 178)
At org. Apache. Catalina. Core. standardhostvalve. Invoke (standardhostvalve. Java: 126)
At org. Apache. Catalina. Valves. errorreportvalve. Invoke (errorreportvalve. Java: 105)
At org. Apache. Catalina. Core. standardenginevalve. Invoke (standardenginevalve. Java: 107)
At org. Apache. Catalina. connector. coyoteadapter. Service (coyoteadapter. Java: 148)
At org. Apache. Coyote. http11.http11processor. Process (http11processor. Java: 856)
At org. Apache. Coyote. http11.http11protocol $ http11connectionhandler. processconnection (http11protocol. Java: 744)
At org.apache.tomcat.util.net. pooltcpendpoint. processsocket (pooltcpendpoint. Java: 527)
At org.apache.tomcat.util.net. leaderfollowerworkerthread. Runit (leaderfollowerworkerthread. Java: 80)
At org. Apache. tomcat. util. threads. threadpool $ controlrunnable. Run (threadpool. Java: 684)
At java. Lang. thread. Run (thread. Java: 595)

** End nested exception **

Org. Apache. Jasper. runtime. pagecontextimpl. dohandlepageexception (pagecontextimpl. Java: 848)
Org. Apache. Jasper. runtime. pagecontextimpl. handlepageexception (pagecontextimpl. Java: 781)
Org. Apache. jsp. _ 06_005f03_jsp. _ jspservice (Org. Apache. jsp. _ 06_005f03_jsp: 100)
Org. Apache. Jasper. runtime. httpjspbase. Service (httpjspbase. Java: 97)
Javax. servlet. http. httpservlet. Service (httpservlet. Java: 802)
Org. Apache. Jasper. servlet. jspservletwrapper. Service (jspservletwrapper. Java: 322)
Org. Apache. Jasper. servlet. jspservlet. servicejspfile (jspservlet. Java: 291)
Org. Apache. Jasper. servlet. jspservlet. Service (jspservlet. Java: 241)
Javax. servlet. http. httpservlet. Service (httpservlet. Java: 802)

Root Cause

Java. SQL. sqlexception: communication link failure: Java. Io. ioexception, underlying cause: unexpected end of input stream

** Begin nested exception **

Java. Io. ioexception
Message: unexpected end of input stream

Stacktrace:

Java. Io. ioexception: unexpected end of input stream
At com. MySQL. JDBC. mysqlio. readpacket (mysqlio. Java: 1096)
At com. MySQL. JDBC. mysqlio. dohandshake (mysqlio. Java: 626)
At com. MySQL. JDBC. Connection. createnewio (connection. Java: 1562)
At com. MySQL. JDBC. Connection. <init> (connection. Java: 491)
At com. MySQL. JDBC. nonregisteringdriver. Connect (nonregisteringdriver. Java: 346)
At java. SQL. drivermanager. getconnection (drivermanager. Java: 525)
At java. SQL. drivermanager. getconnection (drivermanager. Java: 171)
At org. Apache. jsp. _ 06_005f03_jsp. _ jspservice (Org. Apache. jsp. _ 06_005f03_jsp: 65)
At org. Apache. Jasper. runtime. httpjspbase. Service (httpjspbase. Java: 97)
At javax. servlet. http. httpservlet. Service (httpservlet. Java: 802)
At org. Apache. Jasper. servlet. jspservletwrapper. Service (jspservletwrapper. Java: 322)
At org. Apache. Jasper. servlet. jspservlet. servicejspfile (jspservlet. Java: 291)
At org. Apache. Jasper. servlet. jspservlet. Service (jspservlet. Java: 241)
At javax. servlet. http. httpservlet. Service (httpservlet. Java: 802)
At org. Apache. Catalina. Core. applicationfilterchain. internaldofilter (applicationfilterchain. Java: 252)
At org. Apache. Catalina. Core. applicationfilterchain. dofilter (applicationfilterchain. Java: 173)
At org. Apache. Catalina. Core. standardwrappervalve. Invoke (standardwrappervalve. Java: 213)
At org. Apache. Catalina. Core. standardcontextvalve. Invoke (standardcontextvalve. Java: 178)
At org. Apache. Catalina. Core. standardhostvalve. Invoke (standardhostvalve. Java: 126)
At org. Apache. Catalina. Valves. errorreportvalve. Invoke (errorreportvalve. Java: 105)
At org. Apache. Catalina. Core. standardenginevalve. Invoke (standardenginevalve. Java: 107)
At org. Apache. Catalina. connector. coyoteadapter. Service (coyoteadapter. Java: 148)
At org. Apache. Coyote. http11.http11processor. Process (http11processor. Java: 856)
At org. Apache. Coyote. http11.http11protocol $ http11connectionhandler. processconnection (http11protocol. Java: 744)
At org.apache.tomcat.util.net. pooltcpendpoint. processsocket (pooltcpendpoint. Java: 527)
At org.apache.tomcat.util.net. leaderfollowerworkerthread. Runit (leaderfollowerworkerthread. Java: 80)
At org. Apache. tomcat. util. threads. threadpool $ controlrunnable. Run (threadpool. Java: 684)
At java. Lang. thread. Run (thread. Java: 595)

** End nested exception **

Com. MySQL. JDBC. mysqlio. dohandshake (mysqlio. Java: 699)
Com. MySQL. JDBC. Connection. createnewio (connection. Java: 1562)
Com. mysql. JDBC. Connection. <init> (connection. Java: 491)
Com. MySQL. JDBC. nonregisteringdriver. Connect (nonregisteringdriver. Java: 346)
Java. SQL. drivermanager. getconnection (drivermanager. Java: 525)
Java. SQL. drivermanager. getconnection (drivermanager. Java: 171)
Org. Apache. jsp. _ 06_005f03_jsp. _ jspservice (Org. Apache. jsp. _ 06_005f03_jsp: 65)
Org. Apache. Jasper. runtime. httpjspbase. Service (httpjspbase. Java: 97)
Javax. servlet. http. httpservlet. Service (httpservlet. Java: 802)
Org. Apache. Jasper. servlet. jspservletwrapper. Service (jspservletwrapper. Java: 322)
Org. Apache. Jasper. servlet. jspservlet. servicejspfile (jspservlet. Java: 291)
Org. Apache. Jasper. servlet. jspservlet. Service (jspservlet. Java: 241)
Javax. servlet. http. httpservlet. Service (httpservlet. Java: 802)

Note the full stack trace of the root cause is available in the Apache Tomcat/5.5.9 logs.

Still get database connection Error (Webmaster)
Is there a firewall?
Or does MySQL give the user no permission to access other IP addresses?
It can be seen that an error is reported when the MySQL JDBC driver obtains getconnection ().
I guess it's a problem with your machine's firewall, right? (Webmaster)
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.