是不是类型不对?把那个生成的sql发来看下。还有你的表的字段的类型

解决方案 »

  1.   

    关键字where附近有错的,后面贴一下
      

  2.   

    department.getId(),department.getName()这两个是什么类型的? String吗?你先手动在sql中插入试试:insert into department(id,name) values("1","开发部");
      

  3.   

    对,两个都是String,我已经在sql中插入了,没有问题,但是在用在DButil中就不行
    不知道为什么会提示where附近错误,我根本就没用到where这个语句
      

  4.   

    是不是你的DButil有问题呢。你吧DButil的update方法弄出来看看。
      

  5.   

    我不确定DButils是不是有问题,我是在网上找的,你可以发你的DButils给我吗?
    [email protected]
    我再试试看,谢谢
      

  6.   

    你执行这个试试
    String sql = "insert into department(id,name) values(“12”,“name2”)";
    qr.update(sql);如果没有问题,就是你DButil传参出了问题。
      

  7.   

    哪里下得dbutils??先用jdbc试试
    try { 
                String url = "jdbc:msql://200.210.220.1:1114/Demo"; 
                Connection conn = DriverManager.getConnection(url,"",""); 
                Statement st = conn.createStatement(); 
                st.executeUpdate("INSERT INTO Customers " + 
                    "VALUES (1001, 'Simpson', 'Mr.', 'Springfield', 2001)");             conn.close(); 
            } catch (Exception e) { 
                System.err.println("Got an exception! "); 
                System.err.println(e.getMessage()); 
            } 
      

  8.   

    我猜可能也是DButils有问题,能发一个你的DButils给我吗? [email protected]谢谢!
      

  9.   

    QueryRunner run = new QueryRunner( dataSource );
    try
    {
        // Execute the SQL update statement and return the number of
        // inserts that were made
        int inserts = run.update( "INSERT INTO Person (name,height) VALUES (?,?)",
                                  "John Doe", 1.82 );
        // The line before uses varargs and autoboxing to simplify the code    // Now it's time to rise to the occation...
        int updates = run.update( "UPDATE Person SET height=? WHERE name=?",
                                  2.05, "John Doe" );
        // So does the line above
    }
    catch(SQLException sqle) {
        // Handle it
    }
      

  10.   

    你用的什么版本的dbutils?QueryRunner这个类没有600行吧。