MySQLIntegrityConstraintViolationException ? [RESOLVIDO]  XML
Índice dos Fóruns » Java Avançado
Autor Mensagem
Metaleiro
Virtual Machine Man
[Avatar]

Membro desde: 06/07/2006 10:55:54
Mensagens: 671
Localização: São Bernardo do Campo - SP
Offline

Alguém saberia alguma forma de tratar esse erro em um "try" comum ?



This message was edited 1 time. Last update was at 06/12/2011 20:47:54


"Why, Mr. Anderson? Why do you do it? Why get up? Why keep fighting? Do you believe you're fighting for something? For more than your survival? Can you tell me what it is? Do you even know? Is it freedom? Or truth? Perhaps peace? Yes? No? Could it be for love? Illusions, Mr. Anderson. Vagaries of perception. The temporary constructs of a feeble human intellect trying desperately to justify an existence that is without meaning or purpose. And all of them as artificial as the Matrix itself, although only a human mind could invent something as insipid as love. You must be able to see it, Mr. Anderson. You must know it by now. You can?t win. It?s pointless to keep fighting. Why, Mr. Anderson? Why? Why do you persist?"

Neo :
-Because is my choice

drsmachado
GUJ Expert

Membro desde: 25/09/2010 12:54:06
Mensagens: 3986
Localização: Curitiba / São José dos Pinhais - PR
Offline


Não funciona?

Rumo aos 4000
"Os homens de verdade assumem suas responsabilidades e culpas. Esquivar-se e dar desculpas é atitude dos tolos, que preferem não se comprometer".

Lugar de perguntar é no fórum!
Não respondo via MP
Não respondo por Email
Não respondo por IM
Metaleiro
Virtual Machine Man
[Avatar]

Membro desde: 06/07/2006 10:55:54
Mensagens: 671
Localização: São Bernardo do Campo - SP
Offline

drsmachado wrote:
Não funciona?


"Funciona" , porém preciso de algo assim :



Ele me retorna isso :



Agradeço a resposta !

"Why, Mr. Anderson? Why do you do it? Why get up? Why keep fighting? Do you believe you're fighting for something? For more than your survival? Can you tell me what it is? Do you even know? Is it freedom? Or truth? Perhaps peace? Yes? No? Could it be for love? Illusions, Mr. Anderson. Vagaries of perception. The temporary constructs of a feeble human intellect trying desperately to justify an existence that is without meaning or purpose. And all of them as artificial as the Matrix itself, although only a human mind could invent something as insipid as love. You must be able to see it, Mr. Anderson. You must know it by now. You can?t win. It?s pointless to keep fighting. Why, Mr. Anderson? Why? Why do you persist?"

Neo :
-Because is my choice

drsmachado
GUJ Expert

Membro desde: 25/09/2010 12:54:06
Mensagens: 3986
Localização: Curitiba / São José dos Pinhais - PR
Offline


A exception de integridade não está diretamente associada a um evento do try/catch, visto que, você está trabalhando com os objetos oriundos do java (provável que a Connection, o Statement/PreparedStatement e ResultSet sejam do pacote java.sql e não do com.mysql.jdbc)

Rumo aos 4000
"Os homens de verdade assumem suas responsabilidades e culpas. Esquivar-se e dar desculpas é atitude dos tolos, que preferem não se comprometer".

Lugar de perguntar é no fórum!
Não respondo via MP
Não respondo por Email
Não respondo por IM
Metaleiro
Virtual Machine Man
[Avatar]

Membro desde: 06/07/2006 10:55:54
Mensagens: 671
Localização: São Bernardo do Campo - SP
Offline

Obrigado, sua resposta ajudou bastante, mas fiz algo um pouco diferente.

1 - Fiz um select na base em busca do indice em tabelas com Foreign Key
2 - Retornei o Objeto
3 - Se o objeto não for nulo lanço :



Funcionou, não sei se é a melhor alternativa

"Why, Mr. Anderson? Why do you do it? Why get up? Why keep fighting? Do you believe you're fighting for something? For more than your survival? Can you tell me what it is? Do you even know? Is it freedom? Or truth? Perhaps peace? Yes? No? Could it be for love? Illusions, Mr. Anderson. Vagaries of perception. The temporary constructs of a feeble human intellect trying desperately to justify an existence that is without meaning or purpose. And all of them as artificial as the Matrix itself, although only a human mind could invent something as insipid as love. You must be able to see it, Mr. Anderson. You must know it by now. You can?t win. It?s pointless to keep fighting. Why, Mr. Anderson? Why? Why do you persist?"

Neo :
-Because is my choice

drsmachado
GUJ Expert

Membro desde: 25/09/2010 12:54:06
Mensagens: 3986
Localização: Curitiba / São José dos Pinhais - PR
Offline

Metaleiro wrote:Obrigado, sua resposta ajudou bastante, mas fiz algo um pouco diferente.

1 - Fiz um select na base em busca do indice em tabelas com Foreign Key
2 - Retornei o Objeto
3 - Se o objeto não for nulo lanço :



Funcionou, não sei se é a melhor alternativa


Funcionou = melhor alternativa

Rumo aos 4000
"Os homens de verdade assumem suas responsabilidades e culpas. Esquivar-se e dar desculpas é atitude dos tolos, que preferem não se comprometer".

Lugar de perguntar é no fórum!
Não respondo via MP
Não respondo por Email
Não respondo por IM
 
Índice dos Fóruns » Java Avançado
Ir para:   
Powered by JForum 2.1.8 © JForum Team