• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

UrlYBird - DuplicateKeyException in the create method ?

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi !

I was trying to create a few records for test, and I don�t understand this exception in the create method:



I put the syncrhonized keyword in the signature and I don�t understand how could be possible to catch a DuplicateKeyException. What it�s the key ? The record number ?

If the method is synchronized, only one client can create a record at a given time. Correct ? Do I have to lock the record before write it in the file ? Locking a new record that doesn�t exist?

Please, help me!

Thanks a lot in advance,

M�rcio

(from Brazil)
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi M�rcio,

Just because a method signature declares that a particular exception might be thrown does not mean that you have to throw it. If you cannot find a unique key in the data you have been provided (and from memory you cannot get a unique key in URLyBird) then you may want to just consider it as something intended for future use.

Regards, Andrew
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Marcio Aun Migueis:
Hi !

I was trying to create a few records for test, and I don�t understand this exception in the create method:



I put the syncrhonized keyword in the signature and I don�t understand how could be possible to catch a DuplicateKeyException. What it�s the key ? The record number ?

If the method is synchronized, only one client can create a record at a given time. Correct ? Do I have to lock the record before write it in the file ? Locking a new record that doesn�t exist?

Please, help me!

Thanks a lot in advance,

M�rcio

(from Brazil)

 
reply
    Bookmark Topic Watch Topic
  • New Topic