How to treat a sqlexception in jdeveloper?

Forum sobre a ferramenta Oracle JDeveloper, ADF, OAF, etc. (Não é destinado ao aprendeziado da Linguagem Java em geral)
Post Reply
Zida
Rank: Programador Sênior
Rank: Programador Sênior
Posts: 53
Joined: Tue, 08 Jun 2004 2:59 pm
Location: Toledo - PR

Good morning people, everything fine ?

I am having doubts when using SQLEXCEPTION.

For example, I create a Station and ResultSet I put a SELECT.

So far everything is normal, however, I can not do the treatives for or-01403 .

I am doing the following:

Select all

    try 
    { 
      jTextField2.setText(""); 
      Statement stmtUsuario = conn.createStatement (); 
      ResultSet Usuario = stmtUsuario.executeQuery("SELECT NM_USUARIO "+ 
"FROM USUARIO "+ 
"WHERE CD_USUARIO = '"+jTextField1.getText()+"'"); 
      while (Usuario.next()) 
      { 
        jTextField2.setText(Usuario.getString(1)); 
      } 
    } 
    catch(SQLException exemp) 
    { 
      JOptionPane.showMessage(null,"Usuário não cadastrado.!"); 
    }     
What happens is that it is simply appearing no error, and not This falling in sqlexception when the user does not register.

Would anyone know how I can treat this kind of excession?
User avatar
stcoutinho
Moderador
Moderador
Posts: 850
Joined: Wed, 11 May 2011 5:15 pm
Location: são Paulo - SP



I am updating this open open topic, in case other forists come across the same doubt as you.

Please refer to this forum topic: http://en.glufke.net/oracle/viewtopic.php?f=17&t=3473
In this topic, forists talk about how to display error messages when they try to delete the record of a table and which presents records in Daughters Tables (Child Records Found). I think I would take advantage of the code for your situation.

Hugs,

Sergio Coutinho
Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 1 guest