Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.help > #1226
| Newsgroups | comp.lang.java.help |
|---|---|
| From | Linus Flustillbe <admin@nacs.dyndns-office.com> |
| Subject | Re: Can a ResultSet be passed back to a main program |
| References | <4e92594f$0$14660$9a566e8b@news.aliant.net> <4e92909e$0$15519$9a566e8b@news.aliant.net> <5VFkq.4917$j77.4852@newsfe12.iad> |
| Date | 2011-10-10 19:21 +0000 |
| Message-ID | <4e9345bd$0$13642$9a566e8b@news.aliant.net> (permalink) |
On 2011-10-10, Arved Sandstrom <asandstrom3minus1@eastlink.ca> wrote: > > The above that you noted is certainly one improvement to make; it's good > that you remarked upon it. As a rule of thumb, if a variable is internal > to class A, it's a code smell to retrieve it in class B with a getter > method, only to simply supply it as a parameter in another method called > on A by B. > > On this point I think you'll eventually see by looking at > TableConnect.java that you already made the statement available to any > other method in the class, and there was no need for that parameter on > the GetResultSet method. > > General nomenclature notes in Java: method names in Java are also > camel-case, which you've been using elsewhere. > > In a more general sense, when working with JDBC or any other API where > you acquire, use and dispose of connnections, it is fairly common > practise to write up a little utility class that has a few methods to do > these things. You're on the way to doing that with TableConnect. Such a > class would not contain any logic for specific statements or result > sets, usually - that kind of thing is business logic. So I would pull > everything pertaining to Statement and ResultSet out of TableConnect, > and for this small test case keep it in the main class. > > Also, get in the habit of not creating your query strings by > concatenating static strings and supplied variables. Here in this > example it's a non-issue, but for a GUI app or a web app, maybe sooner > or later that variable that is meant to be a table name is a > user-supplied string that contains something else entirely. Word to the > wise. > > AHS As I said, this little "project" is so that I can learn how the jdbc/oracl stuff works in Java. I took a course a few years ago, but it's been so long that I've forgotten it. Once I start working on my GUI, I'll take all of yours (and others) suggestions into consideration. Thanks for all of your excellent suggestions. -- **************************************************************** * Usenet Impovement Project http://nacs.dyndns-office.com/usenet ****************************************************************
Back to comp.lang.java.help | Previous | Next — Previous in thread | Next in thread | Find similar
Can a ResultSet be passed back to a main program Linus Flustillbe <admin@nacs.dyndns-office.com> - 2011-10-10 02:32 +0000
Re: Can a ResultSet be passed back to a main program Linus Flustillbe <admin@nacs.dyndns-office.com> - 2011-10-10 02:37 +0000
Re: Can a ResultSet be passed back to a main program Linus Flustillbe <admin@nacs.dyndns-office.com> - 2011-10-10 06:28 +0000
Re: Can a ResultSet be passed back to a main program Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-10-10 14:26 -0300
Re: Can a ResultSet be passed back to a main program Linus Flustillbe <admin@nacs.dyndns-office.com> - 2011-10-10 19:21 +0000
Re: Can a ResultSet be passed back to a main program markspace <-@.> - 2011-10-10 07:27 -0700
Re: Can a ResultSet be passed back to a main program Linus Flustillbe <admin@nacs.dyndns-office.com> - 2011-10-10 17:06 +0000
Re: Can a ResultSet be passed back to a main program Lew <lewbloch@gmail.com> - 2011-10-10 10:10 -0700
Re: Can a ResultSet be passed back to a main program Linus Flustillbe <admin@nacs.dyndns-office.com> - 2011-10-10 19:23 +0000
Re: Can a ResultSet be passed back to a main program Lew <lewbloch@gmail.com> - 2011-10-10 14:26 -0700
Re: Can a ResultSet be passed back to a main program Linus Flustillbe <admin@nacs.dyndns-office.com> - 2011-10-11 00:43 +0000
Re: Can a ResultSet be passed back to a main program Roedy Green <see_website@mindprod.com.invalid> - 2011-10-12 09:52 -0700
Re: Can a ResultSet be passed back to a main program Lew <lewbloch@gmail.com> - 2011-10-12 10:28 -0700
Re: Can a ResultSet be passed back to a main program Linus Flustillbe <admin@nacs.dyndns-office.com> - 2011-10-13 01:24 +0000
Re: Can a ResultSet be passed back to a main program Lew <lewbloch@gmail.com> - 2011-10-12 18:55 -0700
csiph-web