6 messages in com.mysql.lists.javaRe: Newbie: easiest way to wrap Java ...
FromSent OnAttachments
Philippe de Rochambeau14 May 2004 01:58 
Stefan14 May 2004 04:59 
Kieran Kelleher14 May 2004 06:45 
john redden14 May 2004 12:58 
Matthew Hunter14 May 2004 14:29 
Will Glass-Husain14 May 2004 18:35 
Subject:Re: Newbie: easiest way to wrap Java classes around SQL statements
From:Kieran Kelleher (kier@tampabay.rr.com)
Date:05/14/2004 06:45:52 AM
List:com.mysql.lists.java

I use WebObjects which is well worth looking at ...... established technology ...... automatically abstracts database models to customizable Java classes and much more ....... costs a few hundred dollars though..... but pays for itself hundreds of times over in terms of developer productivity alone, not to mention the unlimited deployment licence that is included.

www.webobjects.com

-Kieran

On May 14, 2004, at 4:58 AM, Philippe de Rochambeau wrote:

Hello,

I would like to write Java classes that query a MySQL database. I plan to use Tomcat as application server.

What is the easiest way to make access to the MySQL database as object-oriented as possible? Is there some kind of pattern for this?

My initial guess is that I should create a Java class for each table and manager classes with static methods to insert, delete, etc. rows into the database tables. For instance,

public class Customer { private String name; private String telephone; ... public String getName() { return name; } publid void setName( String newName ) { name = newName; } .... }

public class CustomerManager { public static createCustomer(String name) { String sqlstatement = new String("INSERT INTO COSTUMER (NAME) VALUES (' " + name + .... ... }

But since I have a manager class, what is the point of creating a Customer class?

Any help on this matter would be much appreciated.

Best regards,