What is the problem with this query of my JSP?

Asked

Viewed 50 times

2

This is an excerpt from a JSP page that lists the log-in user’s commitments.I don’t use JSP nor do I usually select this type but I need to use it this way.

 <%

        try {
            Class.forName("com.mysql.jdbc.Driver");
            Connection conn
                    = DriverManager.getConnection("jdbc:mysql://localhost/agendaLogin", "root", "root");
            Statement stmt = conn.createStatement();
            ResultSet rs = stmt.executeQuery("SELECT * FROM compromisso where usuario = '" + usuario + "'");
    %>
    <table width="100%" border="1" class="centralizarDireita">   
        <tr>
            <td><b>Titulo</b></td>
            <td><b>Tipo</b></td>
            <td><b>Data</b></td>     
            <td><b>Local</b></td>
            <td><b>Observacao</b></td>

        </tr>

Giving error in + user + from select * from compromise. I don’t know what could be wrong.

  • Which error is displayed?

  • Escape the simple quotes with \

  • The error is : "Cannot find Symbol variable user"

1 answer

1

Check that your user variable is set. Debug and see its value. It should be set to String, not null.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.