Topic: 请高手看看(编译不过啊 总说我的语句非法!)

  Print this page

1.请高手看看(编译不过啊 总说我的语句非法!) Copy to clipboard
Posted by: c00lzhang
Posted on: 2005-11-14 16:26

package xx;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import java.util.*;
import java.io.*;

public class Xieru
extends HttpServlet
  {
public Xieru()
    {
}

String ID, Name, Sex, Age, bumen, url, sql;
public void setID(String ID)
    {
this.ID = ID;
}

public String getID()
    {
return ID;
}

public void setName(String Name)
    {
this.Name = Name;
}

public String getName()
    {
return Name;
}

public void setSex(String Sex)
    {
this.Sex = Sex;
}

public String getSex()
    {
return Sex;
}

public void setAge(String Age)
    {
this.Age = Age;
}

public String getAge()
    {
return Age;
}

public void setbumen(String bumen)
    {
this.bumen = bumen;
}

public String getbumen()
    {
return bumen;
}

public void XIE()
    {
public void doPost(HttpServletRequest request,HttpServletResponse response)
try
      {
       response.setContentType("tet/html;charset=gb2312");
   PrintWriter out=response.getWriter();
   request.setCharacterEncoding("gb2312");
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
url ="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=gongsi";
conn = DriverManager.getConnection(url, "sa", "1017");
stmt = conn.createStatement();
sql = "select * from renyuan where ID='" + ID + "'";
rs = stmt.executeQuery(sql);

sql = "insert into renyuan(ID,Name,Sex,Age,bumen)";
sql = sql + "values('" + ID + "','" + Name + "','" + Sex + "','" +
Age + "','" + bumen + "')";
stmt.executeUpdate(sql);
PrintWriter pw = response.getWriter();
pw.print("<font size=3 color=bule>ϵͳÕýÔÚ¸üУ¬ÇëÉÔºó......</font><meta http-equiv-'refresh' content='2;url=list.jsp'>");
pw.close();


rs.close();
stmt.close();
conn.close();
}
catch (Exception e)
      {
System.out.println(e.toString());
      }
}
}

2.Re:请高手看看(编译不过啊 总说我的语句非法!) [Re: c00lzhang] Copy to clipboard
Posted by: YuLimin
Posted on: 2005-11-16 11:22

你显示的代码怎么都是乱码呢?以附件的形式上传一下看看。

3.Re:请高手看看(编译不过啊 总说我的语句非法!) [Re: c00lzhang] Copy to clipboard
Posted by: chengbd
Posted on: 2005-11-16 17:04

感觉看别人的代码很辛苦!
麻烦楼主详细说明错误提示吧!

4.Re:请高手看看(编译不过啊 总说我的语句非法!) [Re: c00lzhang] Copy to clipboard
Posted by: ntshenwh
Posted on: 2005-11-16 18:21

在 doPost(HttpServletRequest request,HttpServletResponse response) 是否要加上 throws IOException, ServletException


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923