What I see....

your are losing the real message of the error:

              catch (SQLException sqle) {
                 error = "Update failed, possible duplicate entry";
                 throw new SQLException( error );
              }


Better you should do:


              catch (SQLException sqle) {
                       System.out.println(sqle.getMessage()); //get the message from 
the exception
                 // do something here to return the error upside
              }



jsp wrote:

Here is another beginner question of sorts I imagine.
I receive this error.
java.sql.SQLException: Update failed, possible duplicate entry



I've got this code in a .jsp page.

<% String ref=request.getHeader("Referer");%>
<BR>
<% count.addInfo( ref );
%>


count is calling the method addInfo
in a java bean...


public void addInfo( String Referer )
throws SQLException, Exception {
if (con != null) {
try{
PreparedStatement updateInfo;
updateInfo = con.prepareStatement(
"insert into info(?);");
updateInfo.setString(1,Referer);
updateInfo.execute();
}
catch (SQLException sqle) {
error = "Update failed, possible duplicate entry";
throw new SQLException( error );
}
} else {
error = "Connection with database was lost.";
throw new Exception( error );
}
}


Can anyone see the mistake I am making here. My database has one table
now called info with one String field which is the primary key also.

Thanks if anyone can help or point me to a webpage or something.

-wiley



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]








--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to