RecupData my class returns a NullPointerException only in the web. I connect to a pgsql db 8.3.7 - the script works well in 'console' syso - but a test web NullPointerException is thrown
Here is the method that throws the exception:
/**
 * 
 */
package com.servlet.pgsql;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
/**
 *
 */
public class RecupData {
    /**
     * Connection connection
     */
    static String SqlSinRef     = "SELECT * FROM \"SINref\""; // view in pgsql - contain only 1 column
    static Connection connection;
    static Statement statement;
    /**
     * cette méthode sert pour toutes les connections de la classe RecupData
     */
    public static Statement state() {
        try{
           connection = UniqueConnection.getInstance();
           statement = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
        }
        catch(Exception e) {    e.printStackTrace();    }
        return statement;
    }
    public static String htmlListeRefDossier() {
        ResultSet resultat;
        String listeHtml    =   "<form>\n" +
                                "\t<select>\n";     
        try {
            resultat = state().executeQuery(SqlSinRef);
            while(resultat.next()) {
                listeHtml = listeHtml+"\t\t<option>"+resultat.getString(1)+"</option>\n";   }
        }
        catch (SQLException e) {
            listeHtml = listeHtml+"sql exception sortie";
            e.printStackTrace();
        }
        catch (NullPointerException e) {
            listeHtml = listeHtml+"null pointer exception -sortie";
            e.printStackTrace();
        }
        listeHtml = listeHtml+"\t</select>\n</form>";
        return listeHtml;
    }
    /*
     * valable just pour le dev
    * method main only for test in console
     */
    public static void main(String[] args) throws SQLException {
        System.out.println(htmlListeRefDossier());
    }
    /*
     * A SUPPRIMER  
     */
} // fin class
this is UniqueConnection :
public class UniqueConnection {
  private volatile static Connection connect;
  public static Connection getInstance(){
    if(connect == null){
      synchronized(Connection.class){
        try {  connect = DriverManager.getConnection(url, user, passwd);  }
        catch(SQLException e) { e.printStackTrace(); }
      }
    }
    return connect; 
  } 
}
could you take a look? Thank you!
 
     
     
    