我在http://www.microsoft.com/downloads/results.aspx?pocId=3&freetext=jdbc&DisplayLang=en上下载的sql server driver for jdbc sp3,
不知是不是2.0,但装上后还是[Microsoft][SQLServer 2000 Driver for JDBC]Unsupported method: ResultSet.isAfterLast.是不是我download错了
请指教.谁能告我下载地址,或传给我一个.
不知是不是2.0,但装上后还是[Microsoft][SQLServer 2000 Driver for JDBC]Unsupported method: ResultSet.isAfterLast.是不是我download错了
请指教.谁能告我下载地址,或传给我一个.
你的"java程序"中classpah导入的jdbc driver包 和 web-inf/lib/下的jdbc driver包是否一致?
at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
at com.microsoft.jdbc.base.BaseResultSet.validateScrollable(Unknown Source)
at com.microsoft.jdbc.base.BaseResultSet.isAfterLast(Unknown Source)
at StudentLoginSvlt.backadd(StudentLoginSvlt.java:308)
at StudentLoginSvlt.textadd(StudentLoginSvlt.java:286)
at StudentLoginSvlt.doGet(StudentLoginSvlt.java:207)
at StudentLoginSvlt.doPost(StudentLoginSvlt.java:416)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:738)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:526)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
还是不行啊
import java.sql.*;
public class temp {
public static void main(String args[]) { try {
String url = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
try {
Class.forName(url);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
Connection conn = DriverManager
.getConnection("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=CT","login","110110126");
Statement stmt = conn.createStatement(
ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
ResultSet rs = stmt
.executeQuery("select * from 学生");
rs.next();
System.out.println(rs.getString(1));
rs.last();
System.out.println(rs.getString(1));
System.out.println(rs.isLast());
System.out.println(rs.isAfterLast());
System.out.println(rs.getRow());
rs.previous();
System.out.println(rs.getString(1));
rs.absolute(6);
System.out.println(rs.getString(1));
rs.close();
stmt.close();
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
import java.sql.*;import javax.servlet.*;
import javax.servlet.http.*;
import temp.checkEnrol;
public class StudentLoginSvlt extends HttpServlet{
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
req.setCharacterEncoding("gbk");
String stu_id = req.getParameter("stu_id");
String Train_id=req.getParameter("Train_id"); String pw1=null;
String pw2=null;
String e_mail=null;
String tel=null;
String action = req.getParameter("action");
ResultSet rs=null;
if ("update".equalsIgnoreCase(action)) {//处理更改信息函数 stu_id =req.getParameter("id");
pw1=req.getParameter("password1");
pw2=req.getParameter("password2");
if(pw1.equals("") || pw2.equals("") || pw1==null || pw2==null)
doError(req,res,"密码不能为空!");
e_mail=req.getParameter("e_mail");
tel=req.getParameter("tel");
doUpdate(req,res,pw1,pw2,e_mail,tel,stu_id);
res.sendRedirect("/test/student.jsp");
}
if ("bookmore".equalsIgnoreCase(action)) {
/*String 车站名称=null;
String 日期 =null;
String 停车时刻=null;
String 开车时刻=null;
String 里程=null;
String 硬卧上铺 =null;
String 硬卧中铺 =null;
String 硬卧下铺 =null;
String 非空调硬座 =null;
String 空调硬座=null;*/ checkEnrol check=new checkEnrol();
try {
rs=check.bookmore(Train_id);
} catch (SQLException e) {
System.out.print("booemore has problem");
e.printStackTrace();
}
req.setAttribute("rs", rs);
req.setAttribute("Train_id", Train_id);
req.setAttribute("stu_id", stu_id);
String BookType=req.getParameter("BookType");if(BookType.equalsIgnoreCase("i")){
RequestDispatcher rd = getServletContext().getRequestDispatcher("/BookI.jsp");
rd.forward(req, res);
}
if(BookType.equalsIgnoreCase("g")){
RequestDispatcher rd = getServletContext().getRequestDispatcher("/WriteBook2.jsp");
rd.forward(req, res);
}
}
if ("bookg".equalsIgnoreCase(action)) {
String begstr=req.getParameter("begstr");
String endstr=req.getParameter("endstr");
String begintime=req.getParameter("begintime");
String tickettype=req.getParameter("tickettype");
String 团体个数=req.getParameter("团体个数");
int num = Integer.valueOf(团体个数).intValue();
String member=null;
String temp=null;
String password=null;
String[] c=new String[num];
String[] p=new String[num];
String message=null;
for(int i=1;i<num;i++){
member="成员"+i;
password="密码"+i;
c[i]=req.getParameter(member);
p[i]=req.getParameter(password);
login_confirm lc=new login_confirm();
temp=lc.getPassword(req, res,c[i],"student");
if(!(p[i].equals(temp)))
{
message=c[i]+"用户名或密码有误!";
doError(req,res,message) ;
}
//System.out.println(""+i+c[i]);
//System.out.println(""+i+p[i])
}
/*checkEnrol check=new checkEnrol();
sqlBean db = new sqlBean(); num=check.book(stu_id,Train_id,begstr,endstr,begintime,tickettype);
if(num==0) doError(req,res,"订购失败");
else doError(req,res,"您已成功订购!");*/
textadd( c, num, Train_id);
} }
public int textadd(String[] stu_id,int num, String Train_id){
checkEnrol check=new checkEnrol();
ResultSet rs=null;
String message;
for(int i=1;i<num;i++){
try {
rs=check.getId(stu_id[i]);
} catch (SQLException e) {
System.out.print("查询有问题");
e.printStackTrace();
}
if(!(backadd(rs,Train_id))){
return i;
}
}
return 0;
}public boolean backadd(ResultSet rs, String Train_id){
String histra=null;
try {
while(rs.next()){
histra=rs.getString("名称");
if(Train_id.equalsIgnoreCase(histra))break;
}//while
} catch (SQLException e) {
System.out.print("遍历集合出错");
e.printStackTrace();
}//catch
try {
if(rs.isAfterLast()){
return false;
}
} catch (SQLException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
return true;
}//end backadd
public void doUpdate(HttpServletRequest req, HttpServletResponse res,
String pw1,String pw2,String e_mail,String tel,String id)
throws ServletException, IOException{
int num=0;
if(!pw1.equals(pw2))
doError(req,res,"密码不一致,请重输!");
checkEnrol check=new checkEnrol();
sqlBean db = new sqlBean();
num= check.updatestu(pw1,id,e_mail,tel);
if(num==0) doError(req,res,"更新失败");
}
public void doError(HttpServletRequest req,
HttpServletResponse res,
String str)
throws ServletException, IOException {
req.setAttribute("problem", str);
RequestDispatcher rd = getServletContext().getRequestDispatcher("/errorPage.jsp");
rd.forward(req, res);
}
public void sendResultSet(HttpServletRequest req, HttpServletResponse res,
java.sql.ResultSet rs, String target)
throws ServletException, IOException {
req.setAttribute("rs", rs);
RequestDispatcher rd = getServletContext().getRequestDispatcher(target);
rd.forward(req, res);
}
public void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException { doGet(req, res); }
}
public int textadd(String[] stu_id,int num, String Train_id){
checkEnrol check=new checkEnrol();
ResultSet rs=null;
... rs=check.getId(stu_id[i]); ...
}
这个 checkEnrol 的代码中是否和你的测试类 temp 中一样建立Statement?另: 类名中各单词的首字母用大写,如 CheckEnrol; 只有变量名和方法名中第一个单词的首字母小写,其后的单词首字母大写,如 checkValid(), String strName;其中,变量名除静态常量变量外,一般建议不使用下划线。
请保持一定的缩进量:一般为4个空格,不建议使用Tab进行缩进。