Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

JSP question

Posted on 2002-07-13
2
Medium Priority
?
224 Views
Last Modified: 2010-03-31
I am accessing a database with JSP.  Depending on the date on the server, I need to display the contents of a certain table within that database, (It will change weekly).  Any suggestions as to how I should approach this.

Thanks,
Mike
0
Comment
Question by:MichaelVB
2 Comments
 
LVL 3

Accepted Solution

by:
gandalf94305 earned 400 total points
ID: 7151654
Michael,
  your question is rather general, so I will try to answer in an equally general way :-).

I assume you have some database tables T1, T2, T3, T4, ... which have the same schema. The easiest way of selecting a table based on the current week would be to use a java.util.Calendar object to obtain the week of year (WEEK_OF_YEAR attribute), then either keep a mapping table to associate table names with weeks of the year, or to name the tables according to the weeks of the year. On the Oracle level, you could also define views, one for each week of the year to map to the actual tables.

The mapping table (either as Java properties, or as a database table) would be used if several weeks map to the same table. The naming convention or the views would be more suitable if there is a rather chaotic mapping, possibly with a new, different view every week.

Now it is up to you: if you prefer a Java solution (to be taken into account when the SQL statements will be built), use a properties-based mapping. If you prefer a database solution, try your luck with views in the database.

Ah, there is a third alternative: when a new week starts, reload the data into the appropriate tables, so the names of the tables will always be the same... but that did seem to be a bit too trivial to suggest.

If you need bits of code, let me know: gandalf94305@yahoo.com

Cheers,
--gandalf.
0
 

Author Comment

by:MichaelVB
ID: 7156416
Thanks for the suggestions.  I'll be in touch if I need some advice or clarification.

Mike
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Suggested Courses

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question