| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1814 人关注过本帖
标题:严重异常问题??急!!!!
只看楼主 加入收藏
Javapet
Rank: 1
等 级:禁止访问
帖 子:80
专家分:0
注 册:2008-1-5
结帖率:50%
收藏
 问题点数:0 回复次数:9 
严重异常问题??急!!!!
请问这个是什么异常啊??
javax.servlet.ServletException: com.microsoft.jdbc.sqlserver.SQLServerConnection.prepareStatement(Ljava/lang/String;I)Ljava/sql/PreparedStatement;
    org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
    org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
    org.apache.jsp.post_jsp._jspService(post_jsp.java:118)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

java.lang.AbstractMethodError: com.microsoft.jdbc.sqlserver.SQLServerConnection.prepareStatement(Ljava/lang/String;I)Ljava/sql/PreparedStatement;
    org.apache.jsp.post_jsp._jspService(post_jsp.java:63)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)



代码1:(post.jsp)
<%@ page contentType="text/html;charset=GB2312"%>
<%@ page import="java.sql.*"%>

<%
    request.setCharacterEncoding("GB2312");
    try
    {
            String action=request.getParameter("action");
            if("post".equals(action))
            {           
                        String title=request.getParameter("title");
                        String cont=request.getParameter("cont");
                        cont=cont.replaceAll("\n","<br>");
                        
                        String DBDRIVER="com.microsoft.jdbc.sqlserver.SQLServerDriver";
                    String DBURL="jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=Javapet;SelectMethod=cursor";
                        String sql="insert into lunTan(pid,rootid,title,cont,pdate,isleaf) values(0,?,?,?,'2008',0)";
                        Class.forName(DBDRIVER);
                        Connection conn=DriverManager.getConnection(DBURL,"sa","123456");
                        conn.setAutoCommit(false);
                    PreparedStatement ps=conn.prepareStatement(sql,Statement.RETURN_GENERATED_KEYS);
                    Statement stm=conn.createStatement();
                    
                    ps.setInt(1,-1);
                    ps.setString(2,title);
                    ps.setString(3,cont);
                ps.executeUpdate();
              
                ResultSet rsKey=ps.getGeneratedKeys();
                rsKey.next();
                int Key=rsKey.getInt(1);
                rsKey.close();
                
                stm.executeUpdate("update lunTan set rootid="+Key+"where id="+Key);
                
                ();
                conn.setAutoCommit(true);
                
                stm.close();
                ps.close();
                conn.close();
                response.sendRedirect("show.jsp");
                }
        }
        catch(Exception e)
        {
                e.printStackTrace();
        }
%>
<html>
    <body>
        <center>
        <form action="post.jsp" method="post">
            <input type="hidden" name="action" value="post">
            <table border=1>
                <tr>
                    <td align="center"><input type="text" name="title" size="81"</td>
                </tr>
                <tr>
                    <td><textArea cols=80 rows=15 name="cont"></textArea></td>
                </tr>
                <tr>
                    <td align="center"><input type="submit" value="提交"></td>
                </tr>
            </table>
        </form>
      </center>
    </body>
</html>


代码2:(show.jsp)
<%@ page contentType="text/html;charset=GB2312"%>
<%@ page import="java.sql.*"%>

<%    
    String DBDRIVER="com.microsoft.jdbc.sqlserver.SQLServerDriver";
    String DBURL="jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=Javapet";
        Class.forName(DBDRIVER);
        Connection conn=DriverManager.getConnection(DBURL,"sa","123456");
        PreparedStatement ps=conn.prepareStatement("select * from lunTan where pid=0");
    ResultSet rs=ps.executeQuery();   
%>
<html>
    <body>
        <a href="post.jsp">发表新帖</a>
        <table border=1>
<%
              while(rs.next())
              {
%>
            <tr>
              <td><%=rs.getInt("id")%></td>
                <td><%=rs.getString("cont")%></td>
            </tr>
<%              
              }
                rs.close();
        ps.close();
        conn.close();
%>
        </table>
    </body>
</html>

[[it] 本帖最后由 Javapet 于 2008-5-8 01:22 编辑 [/it]]
搜索更多相关主题的帖子: 异常 sql 
2008-05-07 00:27
Starlove
Rank: 1
等 级:新手上路
帖 子:169
专家分:0
注 册:2007-4-26
收藏
得分:0 
PreparedStatement的用法似乎是
至少有有一个 ? 占位号
2008-05-07 13:29
Javapet
Rank: 1
等 级:禁止访问
帖 子:80
专家分:0
注 册:2008-1-5
收藏
得分:0 
怎么样解决?请指教!
2008-05-07 15:07
天使坠落的眼泪
Rank: 2
等 级:新手上路
威 望:5
帖 子:204
专家分:0
注 册:2006-5-16
收藏
得分:0 
包版本问题

樹欲靜而風不止... http://blog./seablue_xj
2008-05-08 23:11
ltdtfking
Rank: 1
等 级:新手上路
帖 子:31
专家分:0
注 册:2007-10-7
收藏
得分:0 
你试试换一个数据驱动,我也遇到过这种问题换了驱动就好了
2008-05-16 11:19
弑杀耶稣
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2008-5-20
收藏
得分:0 
驱动文件!
2008-05-21 13:20
saberasurada
该用户已被删除
收藏
得分:0 
提示: 作者被禁止或删除 内容自动屏蔽
2008-06-01 00:04
Ethip
Rank: 5Rank: 5
等 级:贵宾
威 望:15
帖 子:771
专家分:0
注 册:2008-1-18
收藏
得分:0 
回复 7# saberasurada 的帖子
有点深奥哦...
2008-06-01 09:38
Javapet
Rank: 1
等 级:禁止访问
帖 子:80
专家分:0
注 册:2008-1-5
收藏
得分:0 
可能是用数据驱动问题,但我还没有换,我用另一种方式去实现了,谢谢大家的意见!
2008-06-01 12:47
saberasurada
该用户已被删除
收藏
得分:0 
回复 8# Ethip 的帖子
提示: 作者被禁止或删除 内容自动屏蔽
2008-06-04 22:45
快速回复:严重异常问题??急!!!!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.022664 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved