public void add(BookInfAdd bookinfadd){ String sqlStr ="insert into booktypeadd values(?,?,?,?,?,?,?,?)"; try (PreparedStatement s =DBconnection.getConnection().prepareStatement(sqlStr)){ s.setString(1,bookinfadd.getType()); s.setString(2,bookinfadd.getBookname()); s.setString(3,bookinfadd.getActor()); s.setString(4,bookinfadd.getChubanshe()); s.setString(5,bookinfadd.getYizhe()); s.setString(6,bookinfadd.getChubanriqi()); s.setString(7,bookinfadd.getDanjia()); s.setInt(8,Integer.parseInt(bookinfadd.getISBN())); s.executeUpdate(); int result =s.executeUpdate(); if(result>0){ System.out.println("添加成功"); } } catch (SQLException ex) { ex.printStackTrace(); } } |