Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/315.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Jsp到我的sql连接错误。_Java_Mysql_Sql_Jsp_Jdbc - Fatal编程技术网

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、字符串用户、字符串密码)
where
url-jdbc:subtocol:subname格式的数据库url
您对jdbc的看法是正确的,但是Apurva有编译错误,因为他忘了将字符串localhost括在双引号中。@LeosLiterak您的解决方案将使代码能够编译,但无法工作。这是一个正确的解决方案。无论如何,一个更大的问题是直接在JSP中编写Java代码。