Just a real quick look, but it seems to me that you're closing your connection before you use it....
if( con != null)
{
try { con.close(); } You're closing it here
catch( Exception e2 ) {}
}
try
{
result = stmt.executeQuery(Valquery); IT's HERE THAT I GET THE PROBLEM !!!!!!!
}