你没有写插入数据的方法呀
应该是这样的方法
UpdateQuery();这个方法才对
你那个是查询数据库的方法

解决方案 »

  1.   

    String sql="insert into yyuser values ('..','..')";
    stmt.executeUpdate(sql);
    其他代码都差不多
      

  2.   

    连接access代码:try{
                String strURL =
                    "jdbc:odbc:driver={MicrosoftAccessDriver(*.mdb)};DBQ=MyTest.mdb";
                Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                Integer i = null;
                Connection connAcce = DriverManager.getConnection(strURL);
            }catch(Exception e){
                e.printStackTrace();
            }
      

  3.   

    <%@ page language="java" import="java.io.*,java.sql.*" %>
    <%
    String DBDriver = "sun.jdbc.odbc.JdbcOdbcDriver"; 
    String ConnStr = "jdbc:odbc:userdata"; 
    String strname,strpasswd1,strpasswd2,strmail;   
            boolean regAttempt = false;
            String errorMessage = "";
    Connection conn = null; 
    Statement stmt = null; 
    ResultSet rs = null; 

    try 

    Class.forName(DBDriver); 

    catch(java.lang.ClassNotFoundException e)

    System.err.println("DBconn (): " + e.getMessage()); 
    }
    try

    conn = DriverManager.getConnection(ConnStr,"",""); 
    stmt = conn.createStatement();

    catch(SQLException ex)

    System.err.println("aq.executeQuery: " + ex.getMessage()); 
    }
    strname=request.getParameter("username");
    strpasswd1=request.getParameter("userpassword");
    strpasswd2=request.getParameter("userpasswd");
    strmail=request.getParameter("usermail");

    %>
    <%
    String sql="select * from yyuser where user_name='"+strmail+"'";
    out.println(sql);
    rs=stmt.executeQuery(sql);
    int rowscount=0;
    try
    {
    while(rs.next())
    {
    rowscount++;
    }
    }
    catch(Exception e)
    {
      
    }
    if(rowscount==0)
    {
    regAttempt=true;
    }else response.sendRedirect("regedit.jsp?reg=error");

    if(regAttempt==true)
    {
    String sqlinsert="insert into  yyuser(user_name,user_password,user_mail)values('"+strname+"','"+strpasswd1+"','"+strmail+"')";
    rs=stmt.executeQuery(sqlinsert);

    if (stmt.executeQuery(sqlinsert)==0){
                 
    response.sendRedirect("regisucc.jsp");}
    else{
    }
    %>有点问题,有朋友能帮忙改下
      

  4.   

    要传参数,就要用PrepareStatement,不要用Statement
    conn = DriverManager.getConnection(ConnStr,"",""); 
    stmt = conn.PrepareStatement("select * from table where id=?,name=?");
    stmt.setInt(1,aID);
    stmt.setBytes(2,aName.getBytes("iso-8859-1"));
    rs=stmt.executeQuery();
      

  5.   

    用:String sql="insert into yyuser (列名)values ('..','..')"
    executeUpdate(sql)
    要是用Query(sql)
    你这里会有错,
    用Query必需要有返回值,你此处,用insert不会有值的,
    另外,delete,alter都得用executeUpdate
      

  6.   

    <%@ page language="java" import="java.io.*,java.sql.*" %>
    <%
    String ConnStr = "jdbc:odbc:userdata"; 
    String strname,strpasswd1,strpasswd2,strmail,ysql,sql;   
            boolean regAttempt = false;
            String errorMessage = "";
    Connection conn = null; 
    Statement stmt = null; 
    ResultSet rs = null; 

     Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
     conn = DriverManager.getConnection(ConnStr, "", "");
     stmt = conn.createStatement();
     strname=request.getParameter("username");
     strpasswd1=request.getParameter("userpassword");
     strpasswd2=request.getParameter("userpasswd");
     strmail=request.getParameter("usermail");
     ysql= "select*from yyuser where user_mail='"+strmail+"'";
     sql="insert into yyuser(user_name,user_password,user_mail)values('"+strname+"','"+strpasswd1+"','"+strmail+"')";
     rs=stmt.executeQuery(ysql);
     rs=stmt.executeUpdate(sql); if(rs.next()) { 
     rs.close();
    out.println("you are lost!"); 
     }
     else{
      out.println("you are ok"); 
    }
    %> 在tomcat下显示这个错误incompatible types found:int;requeired:java.sql.ResulrSet .rs=stmt.executeUpdate(sql),在数据库3个字段都是text类型,有朋友能给个提示么?