为什么不能插入数据?

kkfvjmtd 2009-03-26 04:27:40
数据库是access,也没有抛出异常,但是数据是没有插入进去.

public void insert(Teacher t) {
Connection conn = null;
PreparedStatement pst = null;
String sql = "insert into Teacher (姓名 ,单位 ,部门 ," +
"办公电话 ,家里电话 ,手机 ,地址 ," +
"职位 ,生日 ,爱好 ,email ,QQ ," +
"MSN ,skype ,备注 ,first ,second, " +
"third ,forth ,fifth,编号) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";

try{
conn = DBConnection.getConnection();
pst = conn.prepareStatement(sql);
pst.setString(1, t.getName());
pst.setString(2, t.getCompany());
pst.setString(3, t.getDepartment());
pst.setString(4, t.getOfficePhone());
pst.setString(5, t.getHomePhone());
pst.setString(6, t.getMovePhone());
pst.setString(7, t.getAddress());
pst.setString(8, t.getPosition());
pst.setString(9, t.getBirthday());
pst.setString(10, t.getHobby());
pst.setString(11, t.getEmail());
pst.setString(12, t.getQQ());
pst.setString(13, t.getMSN());
pst.setString(14, t.getSkype());
pst.setString(15, t.getRemark());
pst.setString(16, t.getFirst());
pst.setString(17, t.getSecond());
pst.setString(18, t.getThird());
pst.setString(19, t.getForth());
pst.setString(20, t.getFifth());
pst.setInt(21, t.getId());

pst.execute();
conn.commit();

System.out.println("execute ok");
}catch(Exception e){
e.printStackTrace();
}
}

在线等....
...全文
50 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
网络咖啡 2009-03-26
  • 打赏
  • 举报
回复
发错板块了吧?

13,100

社区成员

发帖
与我相关
我的任务
社区描述
Java J2ME
社区管理员
  • J2ME社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧