Verifique o Statement que vc colocou no c�digo.
        Vc estah querendo usar um statement sem referencia alguma
("ResultSet results = statement.executeQuery( query );).
 
        Veja na API o m�todo createStatement() da classe Connection.



-----Mensagem original-----
De: Flavio Carvalho [mailto:flavio.rodrigo@;appi.com.br]
Enviada em: Friday, October 18, 2002 11:59 AM
Para: [EMAIL PROTECTED]
Assunto: RES: [enterprise-list] NullPointerException


acho q alguma coisa deve estar tentando acessar algum metodo de alguem q
esta' null...
hehhe
vc ajudaria muito se enviasse o stack trace ....
 
 

-----Mensagem original-----
De: [EMAIL PROTECTED] [mailto:darroio@;hotmail.com]
Enviada em: sexta-feira, 18 de outubro de 2002 11:46
Para: [EMAIL PROTECTED]
Assunto: [enterprise-list] NullPointerException


Bom dia ! 
Pessoal ! Segue abaixo o meu c�digo e estou com um problema ( Null Pointer
Exception ).. 
Se algu�m puder ajudar.. Grato !
 
 
 

import java.util.Date;
import java.io.*;
import java.util.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
 
 
public class ServiceServlet extends HttpServlet
{
    private String usuario;
    private String senha;
    private String query;
   
    private static Connection connection = null;
    private static Statement statement = null;
    private static String url = "jdbc:mysql://192.168.0.2/databov";
    private static String driver = "org.gjt.mm.mysql.Driver";
      
    // Initializes the servlet.     
    public void init( ServletConfig config ) throws ServletException 
    {
        super.init( config );
    
        try
        {
            Class.forName( driver );
            connection =
DriverManager.getConnection(url,"databov","cpbd1543k");
        }
        catch( Exception e )
        {
            e.printStackTrace();
            connection = null;
        }
    }
    
 
    public ResultSet executeQuery(String sql) throws SQLException 
    {
        return statement.executeQuery(sql);
    }
 
    
    public void service(HttpServletRequest request, HttpServletResponse
response)
               throws ServletException, java.io.IOException 
    {
               
      response.setContentType("text/html");
        PrintWriter out = response.getWriter();
      
       // Permite fazer a cria��o do cookie 
        String cookieName = ( usuario );
        Date now = new Date();
        String timestamp = now.toString();
        Cookie cookie = new Cookie (cookieName, timestamp);
        cookie.setDomain ("localhost/databov/nocharpointer");
        cookie.setPath ("/nocharpointer");
        cookie.setMaxAge(7 * 24 * 60 * 60);
        cookie.setVersion ( 0 );
        cookie.setSecure(false);
        cookie.setComment("Cookie de usu�rio");
        response.addCookie (cookie); 
        
        usuario = request.getParameter("user");
        senha = request.getParameter("pass");
        
        //Fazendo a valida��o
        if( usuario.equals( "" ) || senha.equals( "" ) )
        {
            out.println( "<H3> Por favor preencha corretamente o login e
senha</h3>" );
            response.sendRedirect("/erro.jsp");
        }
    
        try
        {
 
            query = "SELECT * from cadastro where username = " + usuario + "
and senha = " + senha + " ";   
            ResultSet results = statement.executeQuery( query );
            statement.close();
            
            if( results.first() ) 
            {  
                response.sendRedirect("/logado.jsp");
             
            }
            else
            {
                response.encodeURL("/erro.jsp");
           
            }
 
        }
        catch( Exception e )
        {
            System.err.println("Error: Problema ao fechar o banco de dados
");
            e.printStackTrace();
         
        
        }
        
    }
        
    // Destroys the servlet
    public void destroy()
    {
        try
        {
           connection.close();
        }
        catch( Exception e )
        {
            System.err.println("Erro n�o foi poss�vel fechar o bando");
        }
  
    }
}


---------------------------------------------------------------------
Para cancelar a subscri��o, envie mensagem para: 
[EMAIL PROTECTED]
Para comandos adicionais, envie mensagem para: [EMAIL PROTECTED]

Responder a