Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.help > #1796

Re: Java Enumeration Parse results to Database

From Lew <noone@lewscanon.com>
Newsgroups comp.lang.java.help
Subject Re: Java Enumeration Parse results to Database
Date 2012-05-05 20:47 -0700
Organization albasani.net
Message-ID <jo4s7s$o34$1@news.albasani.net> (permalink)
References <4f9bf94a-d514-494e-9a51-c1ce7cc6dd72@e9g2000yqm.googlegroups.com>

Show all headers | View raw


Joe S wrote:
> I am working on a project and need some major assistance.  Being new
> to Java I have gotten a program to enumerate thru an external site and
> export to a file the results.  My challenge now is that I need to get
> the same results with some parsing done and then send it to a database
> as a record per line. Any thoughts on how best to do this.  Sample
> code would be awesome.

It'd help to have a sample of the code representation of what you mean by "to 
enumerate", but I'll take a stab from general principles.

Any errors in interpretation you'll have to correct by being more specific.

Let's say by "to enumerate", you mean something different from what most Java 
programmers would assume, "to represent as a Java 'enum'".

I'm guessing you mean something off the wall like, "split into relevant chunks 
of meaning (i.e., translate into terminology I care about)".

Otherwise your question makes no sense and you need to do a better job of 
asking questions. (The conclusion can be true even if the assumption doesn't 
hold.)

So that terminology of interest is what we in the programming biz call a 
"model". Let's say you want to model a business customer's operation. Acme 
Wine Cooperative scans the Web for good wine deals and assembles them for 
perusal. They use terms like "case", "bottle", "varietal", "sauvignon", 
"Francis Ford Coppola Winery", etc.

A database these days doesn't have "records". They are based on tables, 
comprising rows and columns. The terminology matters.

You should normalize the database at least to third normal form.

But data models are not object models. The data model is a formal slicing of 
your raw data into minimal consistent, non-anomalous pieces. That isn't the 
same as an object representation of your world.

So let's say you have a type like this:

public interface Wine
{
   enum Color { RED, WHITE, BLUSH, ROSE, ; }
   Map<Grape, Integer> getVarieties();
   Vintner getVintner();
   double getRating();
   ...
}

Obviously no one here can speak to how you cull the data to fill that type, 
absent more details from you.

Presumably you'd find keywords in your data sources and extract the values to 
fill such objects.

Then pushing that to a database is straightforward if you know JDBC and SQL. 
Or are willing to learn it. You can use the JPA (Java Persistence API) library 
to handle boilerplate transformation between the object and relational models. 
Such libraries are called object-to-relational mapping (ORM) frameworks, and 
include EclipseLink and Apache OpenJPA.

You have some studying ahead of you.

-- 
Lew
Honi soit qui mal y pense.
http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg

Back to comp.lang.java.help | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Java Enumeration Parse results to Database Joe S <jstech2010@gmail.com> - 2012-05-05 12:20 -0700
  Re: Java Enumeration Parse results to Database markspace <-@.> - 2012-05-05 12:35 -0700
  Re: Java Enumeration Parse results to Database Lew <noone@lewscanon.com> - 2012-05-05 20:47 -0700
  Re: Java Enumeration Parse results to Database Roedy Green <see_website@mindprod.com.invalid> - 2012-05-07 19:36 -0700

csiph-web