【问题标题】:Jsp to my sql connection error.jsp到我的sql连接错误。
【发布时间】:2014-05-15 17:16:38
【问题描述】:

这个错误请帮忙:

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");
;

【问题讨论】:

  • 把 localhost 放在引号里 -> "localhost"

标签: java mysql sql jsp jdbc


【解决方案1】:

您需要传递数据库连接 url,而不仅仅是 localhost,如 jdbc:mysql://localhost:3306/

here's a good example

【讨论】:

  • 你的回答是错误的,@mserioli 在他的评论中是对的
  • @Leos 请帮助我理解我的答案是错误的!根据javadocpublic static Connection getConnection(String url, String user, String password)url - a database url of the form jdbc:subprotocol:subname
  • 你对 jdbc 的看法是对的,但是 Apurva 有编译错误,因为他忘记将字符串 localhost 括在双引号中。
  • @LeosLiterak 您的 solution 将使代码能够编译但不能工作。这是一个正确的解决方案。不管怎样,一个更大的问题是 OP 直接在 JSP 中编写 Java 代码。
  • 没有我的解决方案或答案。
猜你喜欢
  • 1970-01-01
  • 2020-05-11
  • 1970-01-01
  • 1970-01-01
  • 2018-11-20
  • 1970-01-01
  • 2014-02-08
  • 2011-12-06
  • 1970-01-01
相关资源
最近更新 更多