Visualizzazione dei risultati da 1 a 7 su 7
  1. #1

    [java] gestione particolare errore sql

    ok, eseguendo il mio programma mi da di tanto in tanto il seguente errore:
    COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver][DB2/NT] SQL0911N The current transaction has been rolled back because of a deadlock or timeout. Reason code "2". SQLSTATE=40001.
    questo errore per me non ha particolare importanza, anzi é voluto, sicché mi piacerebbe che almeno al verificarsi di questo errore (e solo questo in particolare) io possa decidere che messaggio dare all'utente. Come devo scrivere il mio try/catch?
    Walk fast, chew slowly.
    "We used students as subjects because rats are expensive and you get too attached to them"

  2. #2
    Utente di HTML.it L'avatar di pireda
    Registrato dal
    Jul 2001
    Messaggi
    654
    try
    {
    Le tue operazioni SQL
    }
    catch(SQLException sqle)
    {
    JOptionPane.showMessageDialog(null, "SQL Exception: " + qle.getMessage(), "Tua Applicazione - Errore", JOptionPane.WARNING_MESSAGE);
    }
    Maddalena... Perché proprio Iacchetti!...

  3. #3
    Utente di HTML.it L'avatar di pireda
    Registrato dal
    Jul 2001
    Messaggi
    654
    ...correggo
    [...]+ sqle.getMessage(),[...]
    Maddalena... Perché proprio Iacchetti!...

  4. #4
    thanx, peró volevo sapere se fosse possibile eseguire qualcosa solo se l'errore sql é il SQL0911N
    Walk fast, chew slowly.
    "We used students as subjects because rats are expensive and you get too attached to them"

  5. #5
    Utente di HTML.it L'avatar di pireda
    Registrato dal
    Jul 2001
    Messaggi
    654
    Si può ma non ricordo di preciso quale metodo devi chiamare, dovrai avere un costrutto tipo:

    try
    {
    Le tue operazioni SQL
    }
    catch(SQLException sqle)
    {
    if (sqle.getNumber == "SQL0911N")
    {
    JOptionPane.showMessageDialog(null, "SQL Exception: " + sqle.getMessage(), "Tua Applicazione - Errore", JOptionPane.WARNING_MESSAGE);
    }
    }

    Però non sono sicuro che il metodo sia getNumber()!
    Maddalena... Perché proprio Iacchetti!...

  6. #6
    Utente di HTML.it L'avatar di floyd
    Registrato dal
    Apr 2001
    Messaggi
    3,837
    if (sqle.getMessage().indexOf("SQL0911N") > -1)

  7. #7
    ottimo teamwork ragazzi :metallica :metallica
    Walk fast, chew slowly.
    "We used students as subjects because rats are expensive and you get too attached to them"

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 © 2025 vBulletin Solutions, Inc. All rights reserved.