package num;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import java.sql.*;
public class Servlet2 extends HttpServlet {
private static final String CONTENT_TYPE = "text/html; charset=GBK";
//Initialize global variables
public void init() throws ServletException {
}
//Process the HTTP Post request
public void doPost(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
response.setContentType(CONTENT_TYPE);
PrintWriter out = response.getWriter();
String name=request.getParameter("name1");
String paw=request.getParameter("paw1");
String name1;
String paw1;
boolean test=false;
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");//加载桥驱动
}catch(ClassNotFoundException e){
out.println("错误");
}
try{
String url = "jdbc:odbc:text";
String sql="insert into hello(name,paw)values('" + name +"'','" + paw + "')";
out.println("3");
Connection conn = DriverManager.getConnection(url, "sa", "");
out.println("2");
Statement s = conn.createStatement();
out.println("1");
int count=s.executeUpdate(sql);
out.println("word");
}catch(SQLException ex){
out.println("连接失败");
}
}
//Clean up resources
public void destroy() {
}
}