la string è giusta per determinare il numero di campi introdotti nel db
***********
sqlQuery=("select max(idNotizia) as massimo from ?");
****
***
l'intero metodo
***
public static int massimo(String archivio, String indice) throws ErroreAccessoDatiException{
String sqlQuery=null;
if (dataSource==null){
throw new IllegalStateException ("NotizieDBManager non ha ancora a disposizione un dataSouse valido");
}
sqlQuery=("select max(idNotizia) as massimo from ?");
Connection connection = null;
PreparedStatement pStat = null;
ResultSet rSet = null;
try{
System.out.println("archivio "+archivio+" "+"indice"+indice);
connection=dataSource.getConnection();
pStat=connection.prepareStatement(sqlQuery);
// pStat.setString(1,indice);
pStat.setString(1,archivio);
rSet=pStat.executeQuery();
connection.commit();
int massimo=0;
if (rSet.next()) {
massimo = rSet.getInt("massimo") + 1;
}
else {
massimo = 1;
}
return massimo;
}
catch (SQLException errore) {
throw new ErroreAccessoDatiException(errore.getMessage(),
String.valueOf(errore.getErrorCode()));
}
finally {
try {rSet.close();}catch (Exception e) {}
try {pStat.close();}catch (Exception e) {}
try {connection.close();}catch (Exception e) {}
}
}
***