What's wrong with this query from my JSP?

2

This is an excerpt from a JSP page that lists logged-in user commitments. I do not use JSP nor do I usually do this kind of select but I need to use it that 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>

This is giving an error in + user + from the select * from appointment. I do not know what could be wrong.

    
asked by anonymous 09.05.2016 / 03:23

1 answer

1

Make sure your 'user' variable is set. Debug and see the value of it. It should be as String, not as null.

    
10.05.2016 / 02:40