This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes Scan item code and store in the database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Scan item code and store in the database" Watch "Scan item code and store in the database" New topic
Author

Scan item code and store in the database

Justin Howard
Ranch Hand

Joined: Feb 19, 2009
Posts: 162
Hi All,

I have a requirement and I am not sure how to start working on it. Any ideas can help.

The user is going to scan an item. The system has to find the type of item scanned , example the scanned item is bread
and store that in the database. This is the general idea. Is it even possible to do something like this.

Thanks
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Of course, assuming you can interface with the scanner (some are simply serial-based and pretty easy to interact with).
Justin Howard
Ranch Hand

Joined: Feb 19, 2009
Posts: 162
Thanks for the reply.

Assuming I have a scanner, when the item gets scanned where does it store that code.
Also how can I find the item name, for example if bread is scanned I do not want the brand name bread.
Only the item eg it has to return "bread".

If it is web based application, can this stored in a database and then displayed in jsp?

Thanks
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Whether or not it's a web app isn't relevant (although if it's a web app getting scanner input could be more difficult) to how data is stored.
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2491
    
    8

Hi Justin

Assuming I have a scanner, when the item gets scanned where does it store that code
That is scanner dependent. You will have to read the developer guide of your scanner to learn how to interact with it.

Also how can I find the item name, for example if bread is scanned I do not want the brand name bread.
Only the item eg it has to return "bread"
A scanner does not scan this info. It only scans codes.
You will need to store a translation table between these codes and the display label somewhere.

If it is web based application, can this stored in a database and then displayed in jsp?
Sorry, I do not get the link between what you do with the scanner and what your web application should do. Can you please explain the scenario?
But in general: yes. A web based application can display data from a database, and you can store scanned information in a database.

Regards, Jan


OCUP UML fundamental and ITIL foundation
youtube channel
Justin Howard
Ranch Hand

Joined: Feb 19, 2009
Posts: 162
Thanks for the detailed reply. It is very helpful.
The requirement in detail::
The user will login to the web application. For entering the ingredients required for the recipe , the user will scan the items.
The scanned items will be displayed to the user. (eg: bread, butter,pepper etc). The user enters the quantity of each these scanned items.
  You will need to store a translation table between these codes and the display label somewhere. 

Correct if I am wrong. I thought the code for each item is unique ie for example Brand name A Bread has a unique code and Brand name B Bread has a different code.
So will I have to store the item code for each brand name for every ingredient to deduce the ingredient?

Thanks
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41124
    
  45
The user will login to the web application. For entering the ingredients required for the recipe , the user will scan the items. The scanned items will be displayed to the user. (eg: bread, butter,pepper etc). The user enters the quantity of each these scanned items.

So this web app has a client part that interacts with the scanner. That most likely means a signed applet that interacts with the scanner and the various pages of the web app.

I thought the code for each item is unique ie for example Brand name A Bread has a unique code and Brand name B Bread has a different code.

Yes, but do you have the list of all barcodes and their associated brands/product categories? I doubt that you can find that online (just a hunch, but an educated one). If this application is for a chain of markets, or a manufacturer, then you should be able to get that information from them, but otherwise, you're on your own.


Ping & DNS - my free Android networking tools app
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2491
    
    8

There are scanners that act as a keyboard. They enter the scanned code in the active cursor position.
For not so advanced use they are the easiest to implement and integrate. Search wikipedia for "Keyboard wedges".
Justin Howard
Ranch Hand

Joined: Feb 19, 2009
Posts: 162
Thanks for the reply.

My problem is two fold.

1. How can the scanner interact with the web app and enter the scanned values in the database.
That most likely means a signed applet that interacts with the scanner and the various pages of the web app.

Can you please elaborate on how to achieve this?

2. How to convert the bar code to something meaningful.
I do not have a list of codes and associated products.
Recently I had seen an android app, that lets you take a picture of the bar code and the app returns the details of the item.
Not sure how they do it.

Thanks
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2491
    
    8

Recently I had seen an android app, that lets you take a picture of the bar code and the app returns the details of the item.
Not sure how they do it.
They must have used a cross reference in the background. Barcodes don't carry that info.

In the image above (belonging to gs1), the only info captured in the barcode is the number 5412345678908 (the same one as printed below the label). No other information can be retrieved from this code. You will have to find the additional info somewhere else.

Regards, Jan
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Justin Howard wrote:Recently I had seen an android app, that lets you take a picture of the bar code and the app returns the details of the item.
Not sure how they do it.

That's easy--it's relatively easy to decode the bar code. Then they do a simple web search for the resulting code--the URLs used for searches can be changed, too.

If you don't have a list of codes and products, you'll need to do the same thing. As far as extracting metadata regarding the product, like "bread", good luck.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41124
    
  45
Justin Howard wrote:1. How can the scanner interact with the web app and enter the scanned values in the database.
That most likely means a signed applet that interacts with the scanner and the various pages of the web app.

Can you please elaborate on how to achieve this?


An applet can both 1) interface with a scanner through a serial port, and 2) work with the web app, like enter values into a text field, or submit forms to the server, do web lookups etc. For part 1, the applet needs to be signed, because otherwise it can't access peripherals on the client; see HowCanAnAppletReadFilesOnTheLocalFileSystem for more detail on that. In a previous life I've actually worked on a project that used the RXTX library to access a client-side scanner. For part 2, check out the Common DOM API, which allows applets to interact with web page they're embedded in.

Having said that, the approach mentioned by Jan sounds intriguing if your scanner hardware supports it.
Justin Howard
Ranch Hand

Joined: Feb 19, 2009
Posts: 162
Thanks Jan, Ulf and David.

All the information helped me understand better.

Looks like finding the meta data from the bar code seems to be a problem.
Scanning to the web app seems achievable.

I wonder if this is even the correct approach to enter the ingredients required for the recipe.

Thanks

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Ulf Dittmer wrote:Having said that, the approach mentioned by Jan sounds intriguing if your scanner hardware supports it.

Actually I was intrigued by David's suggestion that a simple web search could return information about the product corresponding to a UPC. That sounded dubious to me, so I got my package of transit tickets out of my wallet and keyed the UPC (669721000043) into Google. And lo and behold, the first link that Google returned was to a site called "upcdatabase.com" which did actually know about my transit tickets.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41124
    
  45
upcdatabase.com

I just grabbed a random item out of my fridge, but it's not recognized by that site. It apparently relies on volunteers supplying information, which probably rules out a lot of commercial products. But I guess YMMV.
Justin Howard
Ranch Hand

Joined: Feb 19, 2009
Posts: 162
upcdatabase.com


I checked something random too. Returned exactly what I looking for (eg:036000003178)

But I am not sure if I can write anything relying on only this website.

Found this in the website too.

UPC lookup code
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Of course you can't *rely* on the barcode being present anywhere, and you certainly can't rely on the kind of metadata you're looking for.
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2491
    
    8

In the industry I work in, we as supplier have to feed an independent data pool with product master data.
Our customers subscribe to this pool, and can receive that data (security is involved, we can say which partners get the data).
There are rules on when and how data is provided and changed. Our customers never have goods from us in their shop that they don't know of.
They can *rely* on having the data. The website below can't.

You can find info when you yahoo for "GDSN Certified data pool".
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Jan Cumps wrote:In the industry I work in, we as supplier have to feed an independent data pool with product master data.
Our customers subscribe to this pool, and can receive that data (security is involved, we can say which partners get the data).
There are rules on when and how data is provided and changed. Our customers never have goods from us in their shop that they don't know of.
They can *rely* on having the data. The website below can't.


Likewise in the industry I work in, when we buy a product from one of our suppliers, the supplier tells us what the UPCs for the product are. We wouldn't have any use for a hobby site which contains UPC information of unknown reliability. But we don't know what business Justin Howard is in.
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2491
    
    8

Paul Clapham wrote: But we don't know what business Justin Howard is in.
No. But we know what he has in his cupboard. I just looked up the item represented by 036000003178.
John Bengler
Ranch Hand

Joined: Feb 12, 2009
Posts: 133
Just for information: in Europe we don't use UPC barcodes for goods, we use EAN (European Article Number) barcodes (usually the 8 or 13 digit version).

According to Wikipedia EAN 13 is a superset of the UPC, but I don't know how the EAN 8 numbers fit in.

UPC

EAN



Probably there are more different codes in other parts of the world...
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

John Bengler wrote:Just for information: in Europe we don't use UPC barcodes for goods, we use EAN (European Article Number) barcodes (usually the 8 or 13 digit version).


Yes, and in North America we were all supposed to have converted from UPC to GTIN by 2005. I think that was meant to unify EAN and UPC, and maybe it actually happened, but I know the use of the term "GTIN" is very rare here. People still say "UPC" and we still mostly have the same barcodes on consumer products.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

And metric back in the 70's.
 
wood burning stoves
 
subject: Scan item code and store in the database
 
Similar Threads
scanning items into database for online shopping site
No more Queues
How to handle Transaction IN and OUT in Inventory using Java
Need some advice on designing a scanned document archive system.