本人实在不懂JSP连接SQL数据库的URL路径是怎么写的 老是写不对
1个回答
展开全部
String url="jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=mydb"; mydb是你的数据库名 追问: //我出错了 org.apache.jasper.JasperException: An exception occurred processing JSP page /MyJsp2.jsp at line 21 18: String url="jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=MyQQ"; 19: String username="sa"; 20: String password=""; 21: Connection con=DriverManager.getConnection(url,username,password); 22: Statement stmt=con.createStatement(); 23: ResultSet rs=stmt.executeQuery("select * from song"); 24: out.println(rs); 回答: 把错误贴出来! 追问: HTTP Status 500 - type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request. exception org.apache.jasper.JasperException: An exception occurred processing JSP page /MyJsp2.jsp at line 21 18: String url="jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=MyQQ"; 19: String username="sa"; 20: String password=""; 21: Connection con=DriverManager.getConnection(url,username,password); 22: Statement stmt=con.createStatement(); 23: ResultSet rs=stmt.executeQuery("select * from Star"); 24: out.println(rs); Stacktrace: org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:524) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:417) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) root cause javax.servlet.ServletException: java.sql.SQLException: No suitable driver org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:850) org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779) org.apache.jsp.MyJsp2_jsp._jspService(MyJsp2_jsp.java:88) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) root cause java.sql.SQLException: No suitable driver java.sql.DriverManager.getConnection(Unknown Source) java.sql.DriverManager.getConnection(Unknown Source) org.apache.jsp.MyJsp2_jsp._jspService(MyJsp2_jsp.java:75) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) note The full stack trace of the root cause is available in the Apache Tomcat/6.0.13 logs. Apache Tomcat/6.0.13 回答: 服务器 遇到一个内部错误(),它无法实现这一点 追问: 怎么办啊 我只想调用本地的MYSQL 数据库 查查里面的数据 回答: 你查一下mysql驱动 补充: 还没有搞好啊啊 追问: 是啊帮下我啊
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询