Salve a tutti, vi posto il mio codice in cui non riesco a capire perchè il resultset mi rimane sempre false...Il database a cui mi connetto è Postgres e la colonna valoredato è di tipo text. Grazie in anticipo!
codice:public String doRetrieveValueById(int idUtente, Profilo p, String descrizione) throws PersistenceException { DataSource datasource = new DataSource(); Connection connection = null; PreparedStatement statement = null; ResultSet result = null; String valore = "pluto"; try { connection = datasource.getConnection(); String retrieve = "select valoredato from datiprofiloutente where idprofilo=? and idutente=? and datadescription=?"; statement = connection.prepareStatement(retrieve); statement.setInt(1,doRetrieveByIdProfilo(p.getNomeProfilo())); statement.setInt(2,idUtente); statement.setString(3,descrizione); result = statement.executeQuery(); while(result.next()) { System.out.println("entro nel while"); valore= result.getString("valoredato"); }}catch (SQLException e) { throw new PersistenceException(e.getMessage()); }finally { try { if (result != null) result.close(); if (statement != null) statement.close(); if (connection!= null) connection.close(); } catch (SQLException e) { throw new PersistenceException(e.getMessage()); } } return valore; }

Rispondi quotando