|
On 11/16/2001 at 11:30:14 AM, java400-l-admin@midrange.com wrote: Sorry, but I do not agree with you, your solution is not portable. If the DB is created on another RDB the columns position may change and the "encapsulated" object will return the wrong data... --- end of excerpt --- Everything is always a compromise, and you can always do anything more than one way. Good design represents both portability and performance. That said, I think this solution is both portable and higher performing. I think the main points of Rich's posts are: 1) You pay extra expense from using column names in the ResultSet, that you can portably eliminate using encapsulation. 2) You should encapsulate your application from the format of your DATA. This usually means encapsulating it from the column positions (AS WELL AS) the column names, the tables, the schemas, and the JDBC objects used to access them. Using an appropriate level of abstraction prevents app changes due to data model from effecting your application. 3) #1 and #2 can also help in the fact that if you "select *" and don't use EVERY single column, you are then wasting storage, CPU cycles, and Java object. This doesn't mean you can't rely on the names in some places and still get the benefits of the name == portability idea. I believe this was Rich's point also. class DataGetter { public static int COL_FLOG = 1; public static int COL_A = 2; public static int COL_DEAD = 3; public static int COL_HORSE = 4; ResultSet rs; public String getData() { ... // Note, construct the query so that regardless of // table layout/format/DB, we get the columns back // in an architected/portable order (i.e. PUBLIC // interfaces (including the column numbers above don't change) rs = executeQuery("SELECT FLOG, A, DEAD, HORSE FROM BLAH"); } .. Other methods left out ... public getFlog() { return rs.getString(COL_FLOG); } public getA() { return rs.getString(COL_A); } public getDead() { return rs.getString(COL_DEAD); } public getHorse() { return rs.getString(COL_HORSE); } } In every single ethnic, religious or racial group, there are a very few truly evil people. For each of those people there are many, many, many good people. Assuming anything (evilness or capability for evil) about the particular group is bigotry and idiocy. Don't do it. -- Me Fred A. Kulack - AS/400e Java and Java DB2 access, Jdbc, JTA, etc... IBM in Rochester, MN (Phone: 507.253.5982 T/L 553-5982) mailto:kulack@us.ibm.com Personal: mailto:kulack@magnaspeed.net AOL Instant Messenger: Home:FKulack Work:FKulackWrk
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.