public void addRssi(String x, String y, APRssi apRssi, String distance) {
String sql = "insert into offline (x,y,ap1,ap2,ap3,ap4,distance) values(?,?,?,?,?,?,?)";
Session session = sessionFactory.openSession();
Transaction ts = session.beginTransaction();
SQLQuery query = session.createSQLQuery(sql);
query.setParameter(0, x);
query.setParameter(1, y);
query.setParameter(2, apRssi.getAp1());
query.setParameter(3, apRssi.getAp2());
query.setParameter(4, apRssi.getAp3());
query.setParameter(5, apRssi.getAp4());
query.setParameter(6, distance);
ts.commit();
session.close();
sessionFactory.close();
}
控制台并未报错,但是数据没有插入到数据库中,经检查需添加 query.executeUpdate();