public int create(User user) { try { Statement stat = conn.createStatement(); ResultSet rs = stat.executeQuery("Select ID FROM USERS "); int i = user.getId(); String n = user.getName(); String pass = user.getPassword(); Date d = user.getDate(); System.out.println("i= " + i); stat.execute( "INSERT INTO USERS VALUES(" + i + ",'" + n + "', '" + pass + "', TO_DATE('" + d + "','YYYY-MM-DD'))"); } catch (SQLException e) { e.printStackTrace(); System.out.println("Alarm in addUser"); } return 1; }
public void add(final User user) throws ClassNotFoundException, SQLException { final String query = "insert into userinfo (id, name, password) values (?,?,?)"; final String[] params = new String[] {user.getId(), user.getName(), user.getPassword()}; getJdbcTemplate().update(query, params); }
public void setUser(User val) { if (val != null) { user = val; user_id = user.getId(); } }