主题:jsp+javaBean+sqlserver出错!
我在用eclipse连接数据库时出错!希望能点拨一下!
JDBC SP3
SQLSERVER SP4
并且也把驱动器下的三个文件放在了tomcat-project下的WEB/INF下的lib下了
package one;
import java.sql.*;
public class BookBean {
private Connection con;
public BookBean(){
String CLASSFORNAME="com.microsoft.jdbc.sqlserver.SQLServerDriver";
String SERVANDDB="jdbc:mirosoft:sqlserver://localhost:1433;Database:mybase";
String USER="sa";
String PWD="fuhui";
try{
Class.forName(CLASSFORNAME).newInstance();
con=DriverManager.getConnection(SERVANDDB,USER,PWD);
}
catch(Exception e){e.printStackTrace();}
}
public ResultSet getBook(int bookid){
try{
Statement stm=con.createStatement();
ResultSet result=stm.executeQuery("select * from book where bookid='"+1+"'");
return result;
}catch(Exception e){
}
return null;
}
}
<%@ page language="java" contentType="text/html; charset=GBK"%>
<%@ page import="java.sql.*,java.io.*" %>
<jsp:useBean id="book" class="one.BookBean" scope="page" />
<jsp:setProerty name="book" property="*" />
<html>
<title>javaBean Test/title>
<center><head>javaBean Test</head></center>
<body bgcolor=#008000>
<center>
<table border="1">
<tr><td>bookid</td><td>书名</td><td>出版社</td><td>价格</td></tr>
<%
try{
ResultSet rst=book.getBook(1);
while(rst.next()){
out.println("<tr>");
out.println("<td>"+rst.getInt("bookid")+"</td>");
out.println("<td>"+rst.getString("bookName")+"</td>");
out.println("<td>"+rst.getString("publisher")+"</td>");
out.println("<td>"+rst.getInt("price")+"</td>");
out.println("</tr>");
}
rst.close();
}catch(Exception e){ }
%>
</table>
</center>
</body>
</html>
出错的提示是:type Status report
message /One/ueseBean.jsp
description The requested resource (/One/ueseBean.jsp) is not available.
JDBC SP3
SQLSERVER SP4
并且也把驱动器下的三个文件放在了tomcat-project下的WEB/INF下的lib下了
package one;
import java.sql.*;
public class BookBean {
private Connection con;
public BookBean(){
String CLASSFORNAME="com.microsoft.jdbc.sqlserver.SQLServerDriver";
String SERVANDDB="jdbc:mirosoft:sqlserver://localhost:1433;Database:mybase";
String USER="sa";
String PWD="fuhui";
try{
Class.forName(CLASSFORNAME).newInstance();
con=DriverManager.getConnection(SERVANDDB,USER,PWD);
}
catch(Exception e){e.printStackTrace();}
}
public ResultSet getBook(int bookid){
try{
Statement stm=con.createStatement();
ResultSet result=stm.executeQuery("select * from book where bookid='"+1+"'");
return result;
}catch(Exception e){
}
return null;
}
}
<%@ page language="java" contentType="text/html; charset=GBK"%>
<%@ page import="java.sql.*,java.io.*" %>
<jsp:useBean id="book" class="one.BookBean" scope="page" />
<jsp:setProerty name="book" property="*" />
<html>
<title>javaBean Test/title>
<center><head>javaBean Test</head></center>
<body bgcolor=#008000>
<center>
<table border="1">
<tr><td>bookid</td><td>书名</td><td>出版社</td><td>价格</td></tr>
<%
try{
ResultSet rst=book.getBook(1);
while(rst.next()){
out.println("<tr>");
out.println("<td>"+rst.getInt("bookid")+"</td>");
out.println("<td>"+rst.getString("bookName")+"</td>");
out.println("<td>"+rst.getString("publisher")+"</td>");
out.println("<td>"+rst.getInt("price")+"</td>");
out.println("</tr>");
}
rst.close();
}catch(Exception e){ }
%>
</table>
</center>
</body>
</html>
出错的提示是:type Status report
message /One/ueseBean.jsp
description The requested resource (/One/ueseBean.jsp) is not available.