QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1231|回复: 1

请高手看看我这servlet 有没有问题

[复制链接]
发表于 2005-4-19 19:14:56 | 显示全部楼层 |阅读模式
public class addTextToMysql extends HttpServlet {

        protected void doGet(HttpServletRequest request,
                        HttpServletResponse response) throws ServletException, IOException {
                //TODO Method stub generated by Lomboz
                response.setContentType("text/html;charset=gb2312");
                PrintWriter outToClient=response.getWriter();
                Connection conn=null;
                ResultSet rs=null;
                try{
                        dbConn myconn=new dbConn();
                        conn=myconn.getConn();
                        PreparedStatement pstmt=conn.prepareStatement("insert into table_1 values(?,?.?)");
                        pstmt.setInt(1,007);
                        pstmt.setString(2,"zhongbin");
                        pstmt.setString(3,"student");
                        int update=pstmt.executeUpdate();
                        outToClient.println("<html><head><title>操作成功</title></head>");
                        outToClient.println("<body><font size=15>谢谢</font></body></html>");
                }catch(Exception e){
                        outToClient.println("<html><head><title>操作失败</title></head>");
                        outToClient.println("<body><font size=15>sorry!!</font></body></html>");
                }
        }
发表于 2005-4-20 09:31:26 | 显示全部楼层
这个继承HttpServlet的addTextToMysql类写得看不懂

很明显插入(007,zhongbin,student)到表table_1应该是pstmt.executeInsert()吧(我是凭ADODB的API的感觉)怎么是pstmt.executeUpdate();更新操作呢?

请楼主使用[code:1][/code:1] BBCODE来发代码贴
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-4-26 22:07 , Processed in 0.099397 second(s), 15 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表