Java Jsp到我的sql连接错误。
此错误请帮助:Java Jsp到我的sql连接错误。,java,mysql,sql,jsp,jdbc,Java,Mysql,Sql,Jsp,Jdbc,此错误请帮助: HTTP Status 500 - type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request. 例外情况 org.apache.jasper.JasperException: Unable to compile class for JSP: An error oc
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
例外情况
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 14 in the jsp file: /select.jsp
localhost cannot be resolved
14: connection = DriverManager.getConnection(localhost, "root", "apurva");
;
您需要传递数据库连接url,而不仅仅是
localhost
,比如jdbc:mysql://localhost:3306/
将localhost放在引号中->“localhost”您的答案是错误的,@mserioli的回答是正确的comment@Leos请帮助我理解我的答案是怎么错的!根据
publicstaticconnection getConnection(字符串url、字符串用户、字符串密码)
whereurl-jdbc:subtocol:subname格式的数据库url
您对jdbc的看法是正确的,但是Apurva有编译错误,因为他忘了将字符串localhost括在双引号中。@LeosLiterak您的解决方案将使代码能够编译,但无法工作。这是一个正确的解决方案。无论如何,一个更大的问题是直接在JSP中编写Java代码。