Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Martin Gregorie Newsgroups: comp.lang.java.databases Subject: Re: Local database library Date: Sat, 5 Oct 2013 15:43:43 +0000 (UTC) Organization: A noiseless patient Spider Lines: 32 Message-ID: References: <20131001135230.66af12f9@efreet.linux> <524b40ba$0$304$14726298@news.sunsite.dk> <20131001154157.7f37e588@efreet.linux> <524b6e8d$0$304$14726298@news.sunsite.dk> <20131002100935.0eacf609@efreet.linux> <20131004104829.4bd78e5b@efreet.linux> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Sat, 5 Oct 2013 15:43:43 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="e5160e2be48f1ea550cf61512446f525"; logging-data="4226"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/kDERTH6r/OYxKQqEU1LOBonafW1NRfnA=" User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508 git://git.gnome.org/pan2) Cancel-Lock: sha1:wjfIXJ/ATYLKhuyLxC0So29XMQk= Xref: csiph.com comp.lang.java.databases:630 On Fri, 04 Oct 2013 10:48:29 -0700, Kevin Nathan wrote: > I hadn't thought of that. What I have started to do (and it's not yet > working) is to create a "DBaccess" library under > "net.companyname.connect" and right now I have a "connect.java" file in > that makes the connection to the database and a "transaction.java" that > works with the transaction table. My source file in a different project > is not seeing these, but I think it might be improper setup in NetBeans > since I'm learning *that* too! :-) > The following summarises what I did for a small system that has non- interactive CLI programs as well as a few GUI utilities that do updates and run enquiries on the DB. I ended with a superclass containing the methods connect() and close() to start and stop the database connection plus other methods to handle common requirements such as reporting DB access failures. There's a subclass for each program. The methods in these each encapsulate an SQL transaction. Data is passed as arguments and the return value indicates success or failure. Where a transaction fills a JTable a reference to its Model is passed into the method, which can put all the rows returned by the SQL query into the Model. This is not a particularly OO design choice, but it does a good job of encapsulating the JDBC elements of a program and gives reasonable separation between the logic implementing each transaction type. -- martin@ | Martin Gregorie gregorie. | Essex, UK org |