How could I like programming ?
When you spend 2 days on one single, pointless line and the only thing you get to see is an ERROR-response. It`s really inhuman and I cant imagine who would want this voluntarily.
Nevertheless, what am I yammering about is following error, that is absolutely god-awful:
<body>
<%@ page import="java.sql.*" %>
<%@ page import="java.io.*" %>
<%@ page language="java" session="true" %>
<%@ include file="basic_login.jsp" %>
<%
java.sql.Connection conn;
java.sql.Statement stmt;
java.sql.ResultSet resDisplay;
java.sql.ResultSet resInsert;
try{
out.println("TRYING......");
Class.forName("org.postgresql.Driver");
conn = DriverManager.getConnection(dburl);
/// variables definition and commands follow
}
catch(Exception e){e.printStackTrace();}
finally{
try{
if(resInsert != null){
resInsert.close();
}
if(stmt !=null){
stmt.close();
}
if(conn != null){
conn.close();
}
}
catch(Exception e2){
out.println("Unable to close connection: "+e2.getMessage());
}
}
%>
SO. I run the html that uses this JSP, fill in the fields, press the submit button and, oh wonder, an error comes along. Well what does this failure says? A simple :
The local variable resInsert may not have been initialized
105: if(resInsert != null){
The f* variable is DEFINITELY INITIALIZED, right at the beginning:
java.sql.ResultSet resInsert; and has been worked with all the way in the <% code %>
and then suddenly at the end, it occurs to the compiler, that the variable is not initialized?
Such things make me very angry. awfully angry.
WHY ?
P.S. I`ve just removed this line and it goes on with the next one saying:
The local variable stmt may not have been initialized
107: if(stmt !=null){
and so on with all three of them
WHY pleas tell me what is wrong here??