mercredi 18 novembre 2020

Can not be resolved? I do not understand why [closed]

String id = request.getParameter("gruppeid");
String abteilung=request.getParameter("id");
Statement statement = null;
ResultSet resultSet = null;
Connection con = null;
PreparedStatement ps = null;
try
{
    Class.forName(driverName);
    con = DriverManager.getConnection(url,user,psw);
    statement=con.createStatement();
    String sql2="select * from greuppeintrag where gruppeid like '" + id + "'";
    resultSet = statement.executeQuery(sql2);
    while(resultSet.next()){
        String idabt = resultSet.getString("abteilungid");
        if(id != null && idapt.ecuals(null)) // --------->>>>>HERE
        {
            con = DriverManager.getConnection(url,user,psw);
            String sql="Insert gruppeeintrag set gruppeid=?,abteilungid=?";
            ps = con.prepareStatement(sql);
            ps.setString(1,id);
            ps.setString(2, abteilung);
            int i = ps.executeUpdate();
            if(i > 0)
            {
                response.sendRedirect("close.html");
            }
            else
            {
                out.print("Problem!");
            }
        }
    }
}

catch(SQLException sql)
{
    request.setAttribute("error", sql);
    out.println(sql);
}

idapt can not be resolved? If I try to check if the Entry is there and not null, so if it is null the if loop can go on. So if there is an entry and the idapt is not null than it won't insert the Entry.

Aucun commentaire:

Enregistrer un commentaire