I am trying to connect to a postgresql database and i am not getting it.
I already installed in a linux machine, and now i am using in a windows,the jsp server is the Resin.
I don't see any problem with the code.The database server is working fine. So can anyone help me??
I will show the code here:
<%!
Connection conn;
Statement stmt;
String nome,email,login,senha,privilegios,status = " ";
String SQL;
public void OpenConnection()
{
try
{
Class.forName("org.postgresql.Driver");
}
catch(Exception e)
{
System.out.println(e.toString());
}
try
{
conn = DriverManager.getConnection("jdbc:postgresql://localhost/trf,postgres,postgres");
}
catch(Exception e)
{
System.out.println("Could not load the driver");
}
} // end Openconnection
public void InsertUsers(String nome,String email,String login,String senha,String privilegios,String status)
{
try
{
stmt = conn.createStatement(); //connect the statement to the connection
SQL ="insert into usuarios(nome,email,login,senha,privilegios,status) values('" + nome + "','" + email + "','" + login + "','" + senha + "','" + privilegios + "','" + status + "')";
stmt.executeUpdate(SQL);
}
catch(SQLException ee)
{
System.out.println(ee);
}
} //end InsertUsers
%>
<%
OpenConnection();
nome = request.getParameter("edtNome");
email = request.getParameter("edtEmail");
login = request.getParameter("edtLogin");
senha = request.getParameter("edtSenha");
privilegios = request.getParameter("privilegios");
status = request.getParameter("select");
InsertUsers(nome,email,login,senha,privilegios,status);
out.println(SQL);
conn.close();
stmt.close();
%>
<BODY TOPMARGIN=0 LEFTMARGIN=0 BGCOLOR="FFFFFF" TEXT="FF8000" LINK="FF8000" VLINK="FF8000" ALINK="000080"
BACKGROUND="none">
<br>
<br>
<br><br>
<br><br><br>
<!-- tabela inicial -->
<font face="verdana, tahoma, arial" size="2" color="gray">
<div align="center">
<b>Opera��o realizada com sucesso</b>
<br><br>
Voltar
</div>
<!-- <meta http-equiv="Refresh" content="10; URL=<? echo $link ?>"> -->
</BODY>
</HTML>
In the console i got the message"could not load the driver"
and in the browser i got this:
500 Servlet Exception
java.lang.NullPointerException
at
trf.respostausuario__jsp.InsertUsers(/trf/respostaUsuario.jsp:32)
at
trf.respostausuario__jsp._jspService(/trf/respostaUsuario.jsp:97)
at com.caucho.jsp.JavaPage.service(JavaPage.java:75)
at com.caucho.jsp.Page.subservice(Page.java:497)
at com.caucho.server.http.FilterChainPage.doFilter(FilterChainPage.java:182)
at com.caucho.server.http.Invocation.service(Invocation.java:315)
at com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:135)
at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:246)
at com.caucho.server.http.HttpRequest.handleConnection(HttpRequest.java:164)
at com.caucho.server.TcpConnection.run(TcpConnection.java:139)
at java.lang.Thread.run(Thread.java:536)
Please anyone tell what is the problem, i am already getting crazy.
I already put the jar file in the resin\lib directory :
postgresql.jar
jdbc2_0-stdext.jar