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


Groups > comp.lang.java.help > #1794 > unrolled thread

Java Enumeration Parse results to Database

Started byJoe S <jstech2010@gmail.com>
First post2012-05-05 12:20 -0700
Last post2012-05-07 19:36 -0700
Articles 4 — 4 participants

Back to article view | Back to comp.lang.java.help


Contents

  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

#1794 — Java Enumeration Parse results to Database

FromJoe S <jstech2010@gmail.com>
Date2012-05-05 12:20 -0700
SubjectJava Enumeration Parse results to Database
Message-ID<4f9bf94a-d514-494e-9a51-c1ce7cc6dd72@e9g2000yqm.googlegroups.com>
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.

[toc] | [next] | [standalone]


#1795

Frommarkspace <-@.>
Date2012-05-05 12:35 -0700
Message-ID<jo3vdk$fat$1@dont-email.me>
In reply to#1794
On 5/5/2012 12:20 PM, 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.


No thoughts, really.  You need some actual requirements.  What is in the 
file now, and what do you expect the data to look like once in the 
database.  Be specific; "with some parsing" is about as unspecific as 
humanly possible.



[toc] | [prev] | [next] | [standalone]


#1796

FromLew <noone@lewscanon.com>
Date2012-05-05 20:47 -0700
Message-ID<jo4s7s$o34$1@news.albasani.net>
In reply to#1794
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

[toc] | [prev] | [next] | [standalone]


#1797

FromRoedy Green <see_website@mindprod.com.invalid>
Date2012-05-07 19:36 -0700
Message-ID<pi1hq7p0kmhciga8pvpsoebt7b4vq289ro@4ax.com>
In reply to#1794
On Sat, 5 May 2012 12:20:16 -0700 (PDT), Joe S <jstech2010@gmail.com>
wrote, quoted or indirectly quoted someone who said :

>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.

there are a zillion forms the original data may be in.  You need to be
much more specific.  Once you get in into Java variables, writing it
to SQL is fairly easy.  see http://mindprod.com/jgloss/jdbc.html and
http://mindprod.com/jgloss/sql.html

You might read http://mindprod.com/jgloss/screenscraping.html

If you trying to glean data on a website intended for people to read.
-- 
Roedy Green Canadian Mind Products
http://mindprod.com
Programmers love to create simplified replacements for HTML. 
They forget that the simplest language is the one you 
already know. They also forget that their simple little 
markup language will bit by bit become even more convoluted 
and complicated than HTML because of the unplanned way it grows.
.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.help


csiph-web