Class KundenBroker

java.lang.Object
  |
  +--KundenBroker

public class KundenBroker
extends java.lang.Object

The KundenBroker class is responsible for reading and writing Kunde objects from and to the database. This class holds a reference to a Database object which represents the database connection. The connection have to be established when instanciating this class, because it uses PreparedStatements. A NotConnectedException will be thrown if the connection is not established.


Constructor Summary
KundenBroker(de.gmx.ndewitt.tools.database.Database db)
          Constructor.
 
Method Summary
 Kunde readKunde(int knr)
          Reads a Kunde object from the database.
 void writeKunde(Kunde kunde)
          Writes a Kunde object to the database.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KundenBroker

public KundenBroker(de.gmx.ndewitt.tools.database.Database db)
             throws java.sql.SQLException,
                    de.gmx.ndewitt.tools.database.NotConnectedException
Constructor. Ensure that the Database connection is established when instanciating this class.
Parameters:
db - The Database object representing the connection.
Method Detail

writeKunde

public void writeKunde(Kunde kunde)
                throws java.sql.SQLException,
                       de.gmx.ndewitt.tools.database.NotConnectedException
Writes a Kunde object to the database. A Kunde object is identified by the Kunde.knr property. The name, strasse, ort property is updated.
Parameters:
kunde - The Kunde object to write to the database.

readKunde

public Kunde readKunde(int knr)
                throws java.sql.SQLException
Reads a Kunde object from the database.
Parameters:
knr - The Knr property of the Kunde to retrieve.
Returns:
The Kunde. null if no Kunde was found.