注册 登录
编程论坛 JAVA论坛

求帮忙看下,为啥怎么都对的就是说有SQL语法错误呢?

xd03122049 发布于 2016-04-10 20:36, 1679 次点击
    Class.forName("com.mysql.jdbc.Driver");
            conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "03122049");
            //String sqlstr = "select * from student where id>?";
            // String name="何神";
             String sqlstr = "insert into student (id,name,age,time) values (?,?,?,?);
            // (9,'" + name + "',25,now())";
            ps = conn.prepareStatement(sqlstr);
            //ps.setInt(1, 2);
             ps.setObject(1, "10");
             ps.setObject(2, "hfg");
             ps.setInt(3, 20);
             ps.setDate(4, new java.sql.Date(System.currentTimeMillis()));
           // set = ps.executeQuery();
0 回复
1