This week's book giveaway is in the Java in General forum.
We're giving away four copies of Java by Comparison (eBook) and have Simon Harrer, Jörg Lenhard, Linus Dietz on-line!
See this thread for details.
Win a copy of Java by Comparison (eBook) this week in the Java in General forum!

Dave Tolls

Rancher
+ Follow
since Sep 04, 2013
Cows and Likes
Cows
Total received
38
In last 30 days
0
Total given
0
Likes
Total received
542
Received in last 30 days
4
Total given
19
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Dave Tolls

CodeRanch Book Promotions - This Year's Winners


A big Congratulations to all our winners!

See our BookPromotions2017Winners

DateCoverBookAuthor(s)PublisherWinnersStatus
January 2Architecting Modern Java EE ApplicationsSebastian DaschnerPacktRavi Desigan, Tim Holloway, Charles O'Leary, Esteban SuarezSent in winners 1/21/18; Receieved (1/22/18, Charles O'Leary)
January 9Getting started with Spring Framework: covers Spring 5J Sharma & Ashish SarinCreate SpaceRavi Saluru, J Kilgrow, Ramadan Pajaziti, David SachdevSent in winners 1/21/18
January 23Kubernetes in ActionMarko LuksaManningT Vergilio, Daniel Owen Williams, Jorge Ruiz-Aquino, Tim Holloway  Sent in winners 2/11/18
January 30The Tao of MicroservicesJ Richard RodgerManningDaniel Demesmaecker, Dave Tolls, Ankur R Jain, Brian Burress  Sent in winners 2/11/18; Received (18/4/18, Dave Tolls)
February 6Get Programming with Scala (MEAP only) Daniela SfregolaManningpaul nisset, Alex Khvatov, Will Myers, Thomas Zink  Sent in winner info (3/18/18); Received (Will Myers 18/4/18)
February 13RESTful Service with JAX-RS 2.0 (Lynda three month subscription)Alex TheedomLyndaSatya Priya Sundar, Shantha Dodmane, Pankaj Sonani, Stephan van HulstSent in winner info (3/18/18)
February 27Java SE 9 for the ImpatientCay HorstmannAddison-Wesley ProfessionalJorge Ruiz-Aquino, Aysenur Eroglu, Campbell Ritchie, Andrew McDonald Winner reported received (3/25/18)
March 20Java EE 8 High PerformanceRomain Manni-BucauPacktpaul nisset, Thomas Zink, David Sachdev, Alex ShykhmanWaiting for winner info
March 27 Java EE 8 - Only What's New (e-book)Alex TheedomLean PublishingClaude Moore, R.J. Arzki, Randy Maddocks, Naresh DonipartiWaiting for winner info
April 3Effective JavaJosh BlochAddison-WesleyStephan van Hulst, Rob Spoor, Jorge Ruiz-Aquino, Granit BerishaWaiting for winner info
April 10Murach's HTML5 and CSS3Anne Boehm & Zak RuvalcabaMurach  Charles O'Leary, Bear Bibeault, Thomas Zink, Wex WuffleyWaiting for winners info


Note: All dates in mm/dd/yyyy format.

Go back to the main BookPromotions page.

For questions about this page or to schedule a promotion, contact: bookpromotion AT javaranch DOT com
1 day ago
The static initialiser is only run once, when the class is first loaded.
Is this data supposed to last for the session?
If so, you can store the ArrayList in the session (which you can get from the request object).

Since this is data represents something (maybe a User?) then it would make more sense to create a User class that holds these three pieces of data, and store that in the session.
3 weeks ago
Works both ways.
I know just about enough to be a menace with Explain Plan...give me an Ask Tom column and I think I know it all!
As it is intended for the JSP, the model(s) in this case ought to be based on those pages.

You may be able to merge some together. 

For example, a page displaying a table of Things, but only showing the name/date/id for example, so that the user can select one of them and then display all the detail for the selected Thing.
Well, to me that's a single model object called Thing.  You may only populate some of the fields of the class for the first (table) page, but it's still essentially the same thing.

Not knowing what the app is it's harder t say.  But, expect to have a lot more model classes than anything else.
DBUtil is not a model.
It's a way of getting data from the DB.

That data (well, each "row" of that data") represents something.
That something ought to have a model, ie a Java class associated with it.

The front end (your JSP) should not have to know that index 0 of an Object[] is an id, and index 1 is a name, and so on.
It should simply have the model, which will be self explanatory.

I know coming from a db environment you are used to working with cursors around your queries, and crunching based on that, but the crunching is normally pretty close to the query (at least when I wrote PLSQL packages).
In Java, your display code is a couple of layers away from the query, and so needs something a little less fragile and error prone.  Besides, it's an OO language, so you probably ought to get used to using it as such.
If you're doing MVC then you really ought to have a Model that represents the data in your View.
And no, an  Object[] or List<String> is not really a model.
Essentially what Norm is asking is, what problems are you having with this assignment?

If there's a part of the assignment that you don't understand then you need to point that out and try and explain where you are stuck.
If your code doesn't compile then you need to tell us what compilation issues you have.
If it compiles but doesn't produce the result you expect then you need to tell us what you see when you run the code and what you expected to see.
3 weeks ago
OK, so let's bounce this back to you to see if I have the picture.

Two databases.
Database A with data we want, and Database B where we want to put some processed version of the stuff from A.

Process:
Read in a load of things from A.
Do some work on them.
Write out the now-transformed data to B.

If that's correct, then that essentially needs two models, one for A and one for B, and then a process in the middle that takes A and spits out B.

So which part is causing the brain lock?
3 weeks ago
Is this an ongoing thing, or a one off migration?
3 weeks ago
Sorry, meant to suggest your Java model.

So your Employee is probably OK, and your WorkAddress though you will need to give it some form of identifier.
WorkHistory will have a foreign key on Employee, mapped by work_number.
Also a foreign key on WorkAddress, mapped by whatever identifier you end up using (possibly work_loc).
3 weeks ago
OK, so work_number is more an employee_id?

Those tables look OK, though you might want to put in some sort of unique key for the work table.  Though is it possible that work_number and work_loc are a unique composite?
3 weeks ago
The endsWith() method does not use a regex.  It simply checks if the String ends with those characters ([0..9] in your case).
3 weeks ago
And if it isn't that line then the only other one that can cause a NullPointerException would be p.toString(), but that would still point to the dao.produitParcMC method being the problem.
3 weeks ago
Oracle has always (from what I can remember going back to 7/8) defaulted to needing a commit.
However, I'm surprised that the JPA implementation isn't handling this?  That's sort of the point of it.