Erro http 500

2 respostas
LPJava

olá Pessoal, to fazendo uma aplicacao e ao clicar no botao enviar, to recebendo a mensagem a seguir:
Ja analisei e nao vi nada de errado na config.

//classe conexao

import java.sql.DriverManager;
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.Connection;
import javax.naming.InitialContext;
import  javax.sql.DataSource;

/**
 *
 * @author Camilo
 */
public class ConnectionFactory {

    public static Connection getConnection() throws Exception{
       try{
           
         /*   Class.forName("com.mysql.jdbc.Driver"); 
            return DriverManager.getConnection("jdbc:mysql://localhost/livraria", "camilo", "integrator");
        }*/ 
       InitialContext ctx = new InitialContext();
        DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/livraria");
        return ds.getConnection();}
    
        catch(Exception e){
            throw new Exception(e.getMessage());
        }
    }
    
    public static void closeConnection(Connection conn, Statement stmt, ResultSet rs)throws Exception{
        close(conn,stmt,rs);
    }
    
    public static void closeConnection(Connection conn, Statement stmt)throws Exception{
        close(conn,stmt,null);
    }
    
    public static void closeConnection(Connection conn)throws Exception{
        close(conn,null,null);
    }
    
    private static void close(Connection conn, Statement stmt, ResultSet rs) throws Exception{ 
        try{
            if(rs!=null) rs.close();
            if(stmt!=null)stmt.close();
            if(conn!=null)conn.close();
        }catch(Exception e){ 
            throw new Exception(e.getMessage()); 
        }
    }
}
formulario de envio
<%-- 
    Document   : formInserindoDados
    Created on : 23/03/2009, 10:33:32
    Author     : Camilo
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<!-- pagina para insercao dos dados do autor -->
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
    <form action="ServletAutores?cmd=adc" method="POST">
        <table>
        <tr>
            <td>Nome:</td> <td><input type="text" name="nome"/></td>    
        </tr>
        
        <tr>
            <td>E-mail:</td> <td><input type="text" name="email"/></td>    
        </tr>
        <tr>
        <td>Nascimento:</td><td><input type="text" name="nascimento"/></td>
    </tr>
    <tr>
        <td colspan="2">
            <input type="submit" name="btCadastrar"value="Enviar"/>
        </td>
    </tr>
</table>
</form>
    </body>
</html>
o erro
HTTP Status 500 - 

--------------------------------------------------------------------------------

type Exception report

message

descriptionThe server encountered an internal error () that prevented it from fulfilling this request.

exception 

javax.servlet.ServletException: java.lang.Exception: Erro:
No object bound to name java:comp/env/jdbc/livraria
root cause 

java.lang.Exception: Erro:
No object bound to name java:comp/env/jdbc/livraria

quem puder ajudar, agradeco

2 Respostas

thiago.correa

Cara tenta só jdbc/livraria, e certifique-se que o teu DS esteja com o mesmo nome (jdbc/livraria)

LPJava

o erro agora é esse:


type Exception report

message

descriptionThe server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: java.lang.Exception: Erro:
com.mysql.jdbc.Driver
root cause

java.lang.Exception: Erro:
com.mysql.jdbc.Driver

Criado 23 de março de 2009
Ultima resposta 23 de mar. de 2009
Respostas 2
Participantes 2