插入方法这样怎么不行

来源:2-4 JDBC实战---搭建模型层 Ⅱ

慕粉1312236355

2017-06-26 10:49

public void addGoddess(Goddess g) throws SQLException{

Connection con=ww.getConnection();

String sql="insert into ta1 values (?,?,?,?,?,?,?,?,?,?,?,?)";

    

sta=con.prepareStatement(sql);

sta.setInt(1, g.getId());

sta.setString(2, g.getUse_name());

sta.setInt(3, g.getSex());

sta.setInt(4, g.getAge());

sta.setDate(5, new Date(g.getBirthday().getTime()));

sta.setString(6, g.getEmail());

sta.setString(7, g.getMobile());

sta.setString(8, g.getCreate_user());

sta.setDate(9, new Date(g.getCreate_date().getTime()));

sta.setString(10, g.getUpdate_user());

sta.setDate(11, new Date(g.getUpdate_date().getTime()));

sta.setInt(12, g.getIsdel());

sta.executeUpdate(sql);

  

}


写回答 关注

2回答

  • 慕田峪6351718
    2017-06-27 13:00:57

    你有代码吗

  • 慕粉1312236355
    2017-06-26 10:51:44

    这是用报错信息

    Exception in thread "main" java.sql.SQLException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?,?,?,?,?,?,?,?,?,?,?,?)' at line 1

JDBC之 “ 对岸的女孩看过来”

一起领略JDBC的奥秘,为进一步学习集成框架打下良好的基础

99328 学习 · 856 问题

查看课程

相似问题