Visualizzazione dei risultati da 1 a 7 su 7

Discussione: [java ]sintassi giusta

  1. #1
    Utente di HTML.it
    Registrato dal
    Nov 2002
    Messaggi
    388

    [java ]sintassi giusta

    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) {}
    }



    }
    ***

  2. #2
    Utente di HTML.it
    Registrato dal
    Oct 2002
    Messaggi
    2,894
    :master: :master: :master:

  3. #3
    Utente di HTML.it
    Registrato dal
    Aug 2002
    Messaggi
    26

    !!!

    non si capisce cosa vuoi dire!!

    :master: :master: :master: :master: :master: :master:

  4. #4
    numero di campi oppure numero di record?
    se è per il numero di record:
    select count(*) from tabella
    23-08-2005: Udinese in cémpions lìg
    Questa estate l'ho passata a Tallin

  5. #5
    Utente di HTML.it L'avatar di userfra
    Registrato dal
    Jul 2001
    Messaggi
    1,418
    per determinare il numero di campi introdotti nel db basta una semplice Select * from nometabella

    :master:

    -------------------------------------------------
    Il fumo nuoce gravemente alla salute

  6. #6
    Utente di HTML.it
    Registrato dal
    Nov 2002
    Messaggi
    388
    mi serve il numero di record presenti in tabella per fare un inserimento col numero di idnotizia consecutivo

  7. #7
    Utente di HTML.it
    Registrato dal
    Oct 2002
    Messaggi
    2,894
    Ti ha risposto Pippo75

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.