新手请教连接数据库打印表里的数据行

houyichong 2015-09-29 11:29:22
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.util.*" %><%@ page import="java.sql.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>

<body>
<%="easy! easy!" %><br>
<%="<h1>y?y?y?你好</h1>" %>
下面开始访问sqlserver数据库
<%
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection conn=DriverManager.getConnection("jdbc:sqlserver://192.168.1.128:1433;DatabaseName=Cater","sa","Hi123___");
Statement stmt=conn.createStatement();
ResultSet rs=stmt.executeQuery("select t.menuname,t.remark,t.inputuser,t.inputtime from t_menu t");
/*
out.print("<br><table>");
out.print("<tr><td>菜单名</td><td>备注</td><td>录入人</td><td>录入时间</td></tr>");
while(rs.next())
{

out.print("<tr><td>" + rs.getString("menuname"));"</td;><td>" + rs.getString("remark") + "</td><td>" + rs.getString("inputuser") +"</td><td>" + rs.getString("inputtime") + "</td></tr>");

out.print(rs.getString("menuname") + "  " + rs.getString("inputuser") );}
out.print("</table>");
*/
rs.close();
stmt.close();
conn.close();%>
</body></html>
死死的报错,好折腾啊。
我是直接把访问数据的三个jar包:msbase.jar,mssqlserver.jar,msutil.jar网上随意下载的,
放到java_home的lib目录下,没看jar包的版本和x86还是x64的
访问x64下的sql2005
...全文
90 点赞 收藏 4
写回复
4 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
DY1201 2015-09-30
java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver 缺少驱动包,buildpath
回复
从小就很呆 2015-09-30
在项目的build-path配置下,把mysql数据库驱动引入进来
回复
wrong1111 2015-09-30
引用 3 楼 Itsjd 的回复:
java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver 缺少驱动包,buildpath
回复
houyichong 2015-09-29
HTTP Status 500 - An exception occurred processing JSP page /main.jsp at line 16 -------------------------------------------------------------------------------- type Exception report message An exception occurred processing JSP page /main.jsp at line 16 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 /main.jsp at line 16 13: <%="<h1>y?y?y?浣犲ソ</h1>" %> 14: 涓嬮潰寮�濮嬭闂畇qlserver鏁版嵁搴� 15: <% 16: Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); 17: Connection conn=DriverManager.getConnection("jdbc:sqlserver://192.168.1.128:1433;DatabaseName=Cater","sa","Hi123___"); 18: Statement stmt=conn.createStatement(); 19: ResultSet rs=stmt.executeQuery("select t.menuname,t.remark,t.inputuser,t.inputtime from t_menu t"); Stacktrace: org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:575) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:462) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339) javax.servlet.http.HttpServlet.service(HttpServlet.java:731) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) root cause javax.servlet.ServletException: java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:916) org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:845) org.apache.jsp.main_jsp._jspService(main_jsp.java:115) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) javax.servlet.http.HttpServlet.service(HttpServlet.java:731) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:439) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339) javax.servlet.http.HttpServlet.service(HttpServlet.java:731) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) root cause java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1858) org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1709) org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:126) org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:63) java.lang.Class.forName0(Native Method) java.lang.Class.forName(Unknown Source) org.apache.jsp.main_jsp._jspService(main_jsp.java:80) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) javax.servlet.http.HttpServlet.service(HttpServlet.java:731) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:439) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339) javax.servlet.http.HttpServlet.service(HttpServlet.java:731) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2015-09-29 11:29
社区公告
暂无公告