Page 1 of 2 12 LastLast
Results 1 to 20 of 21
  1. #1
    razmyasdfg is offline Member
    Join Date
    Jul 2008
    Location
    London (Kingsbury)
    Posts
    41
    Rep Power
    0

    Default Java Database Application with Barcode Reader

    Hi again

    I bought a Barcode reader couple of days ago to write an application.

    I have a database table with item information. (barcode, item_name, description , etc)

    what i need to do is..... when i scan a barcode it should check with the database wether the item is in the database if it exist it should show all the details corresponding to the item if not it should say item not found

    what i have done is ......... create a JtextField to scan the barcode and a button..
    i have to scan the barcode and then press the button to check with database..
    its obvious pressing button for every single item

    what i wanted to do is... the details of the item should show as long as the scan is finish

    anybody got a clue ...???

    thank you guys

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,945
    Rep Power
    19

    Default

    So what have you got?
    Just need to see if I can understand your setup.
    Do you have a thread listening on the port the barcode reader is working on?
    When that reads a barcode does it populate the JTextField?
    Then you press the button and some other code goes to the database using this value to get data?

    If so, then which bit isn't working?
    I don't understand what you mean by "as long as the scan is finish"...the scanners I've used will tell you when they've read the barcode, so don't populate the text field until that's happened.

    Of course, without code this is guesswork.

  3. #3
    razmyasdfg is offline Member
    Join Date
    Jul 2008
    Location
    London (Kingsbury)
    Posts
    41
    Rep Power
    0

    Default

    i dont have a thread to listen to the barcode reader. i just set the curser in JtextField . and then when i scan a barcode the code appear in JtextField and then i have to press the button to check with the database.

    what i need to do is. when i scan a barcode it should check with database. i shouldn't press any button to check with database.
    Last edited by razmyasdfg; 06-03-2011 at 10:19 PM.

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,945
    Rep Power
    19

    Default

    OK, so it's fancier than the one I used several years ago...:)
    That could cause problems, if you're not actually doing the reading on the port.
    Can you do the reading? That would allow you to react when a barcode has been read.

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,193
    Rep Power
    19

    Default

    A DocumentListener might do the trick.

    db

  6. #6
    razmyasdfg is offline Member
    Join Date
    Jul 2008
    Location
    London (Kingsbury)
    Posts
    41
    Rep Power
    0

    Default

    Quote Originally Posted by Tolls View Post
    OK, so it's fancier than the one I used several years ago...:)
    That could cause problems, if you're not actually doing the reading on the port.
    Can you do the reading? That would allow you to react when a barcode has been read.
    yeah I can read the Barcode. when i place the curse in JTextField its display the barcode. then
    i have to press the button to get the details from database.

    The details should display without pressing the button....

  7. #7
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,945
    Rep Power
    19

    Default

    Quote Originally Posted by DarrylBurke View Post
    A DocumentListener might do the trick.

    db
    The problem with that is how would it identify between the user entering a value and the reader.
    There maybe something to latch onto, but I can't offhand think what.

    Quote Originally Posted by razmyasdfg View Post
    yeah I can read the Barcode. when i place the curse in JTextField its display the barcode. then
    i have to press the button to get the details from database.

    The details should display without pressing the button....
    No, what I mean is "you" as in "your code".
    I anthropomorphise code...
    Currently you the barcode reader seems to be acting as just another way of inputting into the text field. Can you intercept that?

    Come to think of it, mine wasn't a barcode reader...it was a card reader. Someone else did the barcode one, and it was the way yours is. Scanning populated whatever field was active at the time. But there must be a way to get "see" that before it hits Swing.

  8. #8
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,193
    Rep Power
    19

    Default

    The problem with that is how would it identify between the user entering a value and the reader.
    It wouldn't. Neither would the present arrangement.

    there must be a way to get "see" that before it hits Swing.
    Not 'before' it hits Swing, but maybe a component with an overridden processKeyEvent (assuming the bar code reader sends KeyEvents -- which should be the case judging from the description here) could, well, process the key events and react without requiring a button press.

    So could a DocumentListener.

    db

  9. #9
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,945
    Rep Power
    19

    Default

    Quote Originally Posted by DarrylBurke View Post
    It wouldn't. Neither would the present arrangement.


    Not 'before' it hits Swing, but maybe a component with an overridden processKeyEvent (assuming the bar code reader sends KeyEvents -- which should be the case judging from the description here) could, well, process the key events and react without requiring a button press.

    So could a DocumentListener.

    db
    Then how does it determine the barcode is complete?
    Which is what is needed surely, for it to fire off the event to look up whatevber it is it's supposed to look up.

  10. #10
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,193
    Rep Power
    19

    Default

    If the reader doesn't send any kind of EOS I would wait for a timeout, using a Timer started by the first input and restarted by every subsequent input. A bar code reader isn't going to send the last character several seconds after the second-last one.

    camickr's Global Event Listeners Java Tips Weblog may also be useful.

    db

  11. #11
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,945
    Rep Power
    19

    Default

    I wish I could remember how we got round it.
    I'm sure it popped up the library tape on a barcode scan, and not simply populate a search field.

    But that was nearly 10 years ago, and it wasn't my code anyway...

  12. #12
    razmyasdfg is offline Member
    Join Date
    Jul 2008
    Location
    London (Kingsbury)
    Posts
    41
    Rep Power
    0

    Default

    you can see this kind if system in a supermarket checkout. when you wanna buy something you take them to the checkout. the cashier just scan it. the name of the product and price and the description just come up in the screen. the cashier don't press any button get the details.

  13. #13
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,945
    Rep Power
    19

    Default

    I'll see if I can find the old code this evening.
    It's been years, though, so it's unlikely to be on my laptop...could be lucky. I'm not too good at clearing it out.

  14. #14
    mine0926 is offline Senior Member
    Join Date
    Apr 2010
    Location
    Philippines
    Posts
    580
    Rep Power
    5

    Default

    As I know, barcode readers send ENTER key after scan, if not see barcode reader's manual.
    So barcode reader will send the character representation of the bars plus enter key.

  15. #15
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,193
    Rep Power
    19

    Default

    If that's so, the easiest solution would involve an ActionListener added to a JTextField.

    db

  16. #16
    razmyasdfg is offline Member
    Join Date
    Jul 2008
    Location
    London (Kingsbury)
    Posts
    41
    Rep Power
    0

    Default

    Quote Originally Posted by Tolls View Post
    I'll see if I can find the old code this evening.
    It's been years, though, so it's unlikely to be on my laptop...could be lucky. I'm not too good at clearing it out.
    THANK YOU SOOOO MUCH BUDDY ........appreciated

  17. #17
    razmyasdfg is offline Member
    Join Date
    Jul 2008
    Location
    London (Kingsbury)
    Posts
    41
    Rep Power
    0

    Default

    Quote Originally Posted by DarrylBurke View Post
    If that's so, the easiest solution would involve an ActionListener added to a JTextField.

    db
    yeah i think so... i am gonna try ActionListener

  18. #18
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,945
    Rep Power
    19

    Default

    That would be the best route...

  19. #19
    razmyasdfg is offline Member
    Join Date
    Jul 2008
    Location
    London (Kingsbury)
    Posts
    41
    Rep Power
    0

    Default Solved

    THANK YOU GUYS ActionListener did the trick. thank you so much those who reply to my post

  20. #20
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,945
    Rep Power
    19

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 0
    Last Post: 03-01-2011, 07:57 AM
  2. Java Barcode Program with Oracle database
    By techsing14 in forum Java 2D
    Replies: 4
    Last Post: 02-25-2011, 07:37 AM
  3. Barcode Reader
    By kaotic101 in forum New To Java
    Replies: 3
    Last Post: 01-03-2011, 05:10 PM
  4. Replies: 0
    Last Post: 09-16-2010, 11:54 AM
  5. how do i get input from barcode reader?
    By anthrax in forum Enterprise JavaBeans (EJB)
    Replies: 2
    Last Post: 04-09-2009, 03:48 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •