19-05-2008
JGoodies binding - RiverLayout
A working example: JGoodies binding - RiverLayout1: Registration.java package formbeans; import java.awt.Container; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.beans.PropertyChangeListener; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JSplitPane; import javax.swing.JTextArea; import javax.swing.JTextField; import javax.swing.border.EmptyBorder; import se.datadosen.component.RiverLayout; import com.jgoodies.binding.adapter.BasicComponentFactory; import com.jgoodies.binding.beans.BeanAdapter; import com.jgoodies.binding.beans.ExtendedPropertyChangeSupport; import com.jgoodies.binding.value.ValueModel; import com.jgoodies.forms.factories.Borders; public class Registration { String username, age, comment; private String CMD_OK = "cmd.ok"/* NOI18N */; private JButton okButton, ok1Button, ok2Button; private ExtendedPropertyChangeSupport changeSupport = new ExtendedPropertyChangeSupport( this); public String getUsername() { return username; } public void setUsername(String username) { String oldValue = username; this.username = username; changeSupport.firePropertyChange("stringValue", oldValue, username); System.out.println(username); } public String getAge() { return age; } public void setAge(String age) { String oldValue = age; this.age = age; changeSupport.firePropertyChange("stringValue", oldValue, age); System.out.println(age); } public String getComment() { return comment; } public void setComment(String comment) { String oldValue = comment; this.comment = comment; changeSupport.firePropertyChange("stringValue", oldValue, comment); System.out.println(comment); } public void addPropertyChangeListener(PropertyChangeListener x) { changeSupport.addPropertyChangeListener(x); } public void removePropertyChangeListener(PropertyChangeListener x) { changeSupport.removePropertyChangeListener(x); } public Container formRiverLayout(JFrame f) { okButton = new JButton(); okButton.setText("ok"); okButton.setActionCommand(CMD_OK); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { // windowAction(event); System.out.println("ACTION : BUTTON OK WAS CLICKED"); System.out.println(okButton.getActionCommand()); } }); ok1Button = new JButton(); ok1Button.setText("ok 1"); ok1Button.setActionCommand(CMD_OK); ok1Button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { // windowAction(event); System.out.println("ACTION : BUTTON 1 OK WAS CLICKED"); System.out.println(ok1Button.getActionCommand()); } }); ok2Button = new JButton(); // we'll need this soon ok2Button.setText("ok 2"); ok2Button.setActionCommand(CMD_OK); ok2Button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { // windowAction(event); System.out.println("ACTION : BUTTON 2 OK WAS CLICKED"); System.out.println(ok2Button.getActionCommand()); } }); Registration bean = new Registration(); BeanAdapter adapter = new BeanAdapter(bean, true); ValueModel nameModel = adapter.getValueModel("username"); ValueModel ageModel = adapter.getValueModel("age"); ValueModel commentModel = adapter.getValueModel("comment"); JTextField userinput = BasicComponentFactory.createTextField(nameModel); JTextField ageinput = BasicComponentFactory.createTextField(ageModel); JTextArea commentinput = BasicComponentFactory .createTextArea(commentModel); ValueModel nameModel01 = adapter.getValueModel("username"); ValueModel ageModel01 = adapter.getValueModel("age"); ValueModel commentModel01 = adapter.getValueModel("comment"); JTextField userinput01 = BasicComponentFactory .createTextField(nameModel01); JTextField ageinput01 = BasicComponentFactory .createTextField(ageModel01); JTextArea commentinput01 = BasicComponentFactory .createTextArea(commentModel01); ValueModel nameModel02 = adapter.getValueModel("username"); ValueModel ageModel02 = adapter.getValueModel("age"); ValueModel commentModel02 = adapter.getValueModel("comment"); JTextField userinput02 = BasicComponentFactory .createTextField(nameModel02); JTextField ageinput02 = BasicComponentFactory .createTextField(ageModel02); JTextArea commentinput02 = BasicComponentFactory .createTextArea(commentModel02); // Panel 1 = left + center // left JPanel left = new JPanel(); left.setLayout(new RiverLayout()); left.add("right", new JLabel("Registration form left")); left.add("p left", new JLabel("Name")); left.add("tab hfill", userinput); left.add("br", new JLabel("Age")); ageinput.setColumns(5); left.add("tab", ageinput); left.add("br vtop", new JLabel("Comment")); commentinput.setRows(3); left.add("tab hfill vfill", new JScrollPane(commentinput)); left.add("p right", okButton); // added to level the content of the 3 panels left.setBorder(Borders.DIALOG_BORDER); // center JPanel center = new JPanel(); center.setLayout(new RiverLayout()); center.add("right", new JLabel("Registration form center")); center.add("p left", new JLabel("Name-center")); center.add("tab hfill", userinput01); center.add("br", new JLabel("Age-center")); ageinput01.setColumns(2); center.add("tab", ageinput01); center.add("br vtop", new JLabel("Comment-center")); center.add("tab hfill vfill", new JScrollPane(commentinput01)); center.add("p right", ok1Button); center.add(left); // added to level the content of the 3 panels center.setBorder(Borders.DIALOG_BORDER); JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, left, center); JPanel panel1 = new JPanel(); panel1.setLayout(new RiverLayout()); splitPane.setBorder(new EmptyBorder(-10, -5, -20, -8)); //splitPane.setDividerLocation(150); //splitPane.setOneTouchExpandable(true); splitPane.setDividerSize(3); panel1.add("hfill vfill", splitPane); JPanel right = new JPanel(); right.setLayout(new RiverLayout()); right.add("right", new JLabel("Registration form right")); right.add("p left", new JLabel("Name-right")); right.add("tab hfill", userinput02); right.add("br", new JLabel("Age-right")); ageinput02.setColumns(3); right.add("tab", ageinput02); right.add("br vtop", new JLabel("Comment-right")); right.add("tab hfill vfill", new JScrollPane(commentinput02)); right.add("p right", ok2Button); // added to level the content of the 3 panels right.setBorder(new EmptyBorder(6, 0, 6, 0)); JSplitPane splitPane0 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, panel1, right); splitPane0.setBorder(new EmptyBorder(-4, 0, -10, 0)); splitPane0.setDividerSize(3); Container c = f.getContentPane(); c.add(splitPane0); // to add a gray border change the code to : // c.setBackground(Color.GRAY); // c.setLayout(new RiverLayout()); // c.add("hfill vfill",splitPane0); return c; } }
2.BuildRegistration.java package formbuilding; import javax.swing.JFrame; import formbeans.Registration; public class BuildRegistration { public BuildRegistration(String title) { JFrame f = new JFrame(title); Registration r = new Registration(); f.setLocation(200, 200); r.formRiverLayout(f); f.pack(); f.setVisible(true); } public static void main(String[] args) { BuildRegistration br = new BuildRegistration("Registration"); } } <hr> <pre><font face="Arial">Tags : RiverLaout , sample , java , example , jgoodies , valuemodel</font></pre><hr>
19-05-2008 om 00:00 geschreven door de makers
18-05-2008
JGoodies binding and RiverLayout
How to define the length of a JTextField by using the RiverLayout - a simple and flexible Java Layout Manager- and the JGoodies binding sample: imports : import java.awt.Container; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.beans.PropertyChangeListener; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JScrollPane; import javax.swing.JTextArea; import javax.swing.JTextField; import com.jgoodies.binding.adapter.BasicComponentFactory; import com.jgoodies.binding.beans.BeanAdapter; import com.jgoodies.binding.beans.ExtendedPropertyChangeSupport; import com.jgoodies.binding.value.ValueModel; import se.datadosen.component.RiverLayout; ...
public Container formRiverLayout(JFrame f) { okButton = new JButton(); okButton.setText("ok"); okButton.setActionCommand(CMD_OK); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { // windowAction(event); System.out.println("ACTION : BUTTON OK WAS CLICKED"); System.out.println(okButton.getActionCommand()); } }); Registration bean = new Registration(); BeanAdapter adapter = new BeanAdapter(bean, true); ValueModel nameModel = adapter.getValueModel("username"); ValueModel ageModel = adapter.getValueModel("age"); ValueModel commentModel = adapter.getValueModel("comment"); JTextField userinput = BasicComponentFactory.createTextField(nameModel); JTextField ageinput = BasicComponentFactory.createTextField(ageModel); ageinput.setColumns(3); // When this configuration isn't done the BasicComponentFactory //will not configure the width and the JTextField will be redused to //a few millimeter. JTextArea commentinput = BasicComponentFactory .createTextArea(commentModel); Container c = f.getContentPane(); c.setLayout(new RiverLayout()); c.add("right", new JLabel("Registration form")); c.add("p left", new JLabel("Name")); c.add("tab hfill", userinput); c.add("br", new JLabel("Age")); c.add("tab", ageinput); c.add("br vtop", new JLabel("Comment")); c.add("tab hfill vfill", new JScrollPane(commentinput)); c.add("p center", okButton); return c; }
18-05-2008 om 00:00 geschreven door de makers
02-02-2008
Enkele JAVA gebonden afkortingen
JAVA gebonden afkortingen
ORM
JSP
JSF
MVC
J2EE
J2SE
POJO
Object-Relational mapping
JavaServer Pages
JavaServer Faces
Model-view-controller
Java 2 Platform Enterprise
Edition
Java 2 Platform, Standard
Edition
Plain Old Java Object
JTA
EJB
API
AOP
JDBC
Java Transaction API
Enterprise JavaBeans
Application programming interface
Aspect-oriented programming
Java Database Connectivity
SQL
HQL
JDO
DAO
Structured Query Language
Hibernate Query Language
Java Data Objects
Data Access Object
iBATIS
is a persistence framework which enables mapping SQL
queries to POJOs
Apache Struts
is an open-source web application framework for
developing Java EE web applications.
WebWork
is a Java-based web application framework developed
by OpenSymphony.
Tapestry
is an open-source framework for creating dynamic,
robust, highly scalable web applications in Java.
TopLink
is an object-relational mapping package for Java
developers.
Hibernate
is an object-relational mapping (ORM) library for the
Java language, providing a framework for mapping an object-oriented
domain model to a traditional relational database.
Spring
Spring is a layered Java/J2EE application framework,
based on code published in Expert One-on-One J2EE Design and Development
by Rod Johnson (Wrox, 2002).
02-02-2008 om 15:59 geschreven door de makers
21-11-2007
Java Persistence with Hibernate
Java Persistence with Hibernate
Schermbreed weergeven : klik voorlaatste ikoon van toolbalk
21-11-2007 om 21:50 geschreven door de makers
12-11-2007
Exel : Woorden vervangen in tekst m.b..v een macro
Macro voor excel om een lijst woorden in één
keer te vervangen in een tekst.
De code voor Visual Basic macro "Vervang"
De lijst woorden die men wenst te vervangen bevindt zich in dit voorbeeld in de kolom C4 tot C13.De wisselwoorden in de kolom daarnaast [ Offset(0, 1)].
Sub Vervang()
'author piet :: pwProTech
For Each c In Worksheets(1).Range("C4:C13")
Sheets("Blad2").Cells.Replace What:=c.Value, Replacement:=c.Offset(0, 1).Value,
LookAt:=xlPart _
, SearchOrder:=xlByRows, MatchCase:=True, SearchFormat:=False, _
ReplaceFormat:=False
Next c
End Sub
De inhoud van excel Blad1
Range C4 tot C13 :
Hier plaats je de woorden die je wil vervangen en de veervangtekst
Vb.:Blad1:
Op dit blad kan je ook de knop [VERVANG] (die de macro "Vervang" start)
aanbrengen.:
A
B
C
D
...
1
2
3
Te vervangen:
met:
4
Event
DB_action
5
event
db_action
...
...
...
De inhoud van excel Blad2
Op Blad2 plaats je de tekst die bewerkt moet worden.
Je plakt best de hele tekst in één enkele cel zodat je hem weer gemakelijk kan copiëren Hoe : dubbele klik in de cel die je verkiest en plakken
Noot: Je kan ook een knop voorzien om de woorden op "Blad1" te verwijderen met de macro "Reset"
Code:
Sub Reset() 'author piet :: pwProTech For Each c In Worksheets(1).Range("C4:C13") c.Value = "" c.Offset(0, 1).Value = "" Next c End Sub
12-11-2007 om 21:21 geschreven door de makers
20-10-2007
Systray : verwijderen tags taakbalk. Wijzigingen start programma's
Systray : verwijderen tags ( icoon ) taakbalk . Wijzigingen start programma's enz. 1Ga naar start2.Klik op "Uitvoeren" [run] in het geopend menu. 3.Type in de ingavebalk : msconfig 4.Klik ok Het venster "Hulpprogramma voor systeemconfiguratie" wordt geopend .5.In het gegeven venster kan je nu de nodige veranderingen doorvoeren. Tip :Programma's met "onbekend" als leverancier of "" (prog's die geen indentificartie hebben) zijn dikwijls dubieus tenzij je natuurlijk het programma kent of het zelf geinstalleerd hebt.Noot -icoons taakbalk bevinden zich onder de tab "Opstarten" -wat bvb. het icoon van het gevaarlijke "antivirusgear" betreft : het bevat in de tab "opstarten" geen gegevens.Het kan wel via deze weg verwijderd worden doch het programma zelf moet apart verwijderd worden.
20-10-2007 om 00:00 geschreven door de makers
27-08-2007
Scholier kraakt pornofilter van 50 miljoen euro
Scholier kraakt pornofilter van 50 miljoen euro De Morgen :: KLIK HIER en LEES MEER
27-08-2007 om 14:55 geschreven door de makers
24-08-2007
Minimumindeling van het algemeen rekeningstelsel
Minimumindeling van het algemeen rekeningstelsel MAR Databasetabel voor MySQL -- phpMyAdmin SQL Dump -- version 2.6.1-pl3 -- http://www.phpmyadmin.net -- -- Host: localhost -- Generatie Tijd: 25 Aug 2007 om 14:28 -- Server versie: 5.0.24 -- PHP Versie: 5.0.3 -- -- Database: `boekhouding` -- -- -------------------------------------------------------- -- -- Tabel structuur voor tabel `rekeningstelsel` -- CREATE TABLE `rekeningstelsel` ( `id` int(11) NOT NULL auto_increment, `rekening` varchar(8) NOT NULL, `beschrijving` varchar(255) default NULL, `code1` varchar(8) default NULL, `code` varchar(25) default NULL, `APR` char(1) NOT NULL, `bedrag` double NOT NULL, `info` tinytext NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=942 ; -- -- Gegevens worden uitgevoerd voor tabel `rekeningstelsel` -- INSERT INTO `rekeningstelsel` VALUES (1, '1. ', 'Eigen vermogen, voorzieningen voor risicos en kosten en schulden op meer dan één jaar', '', '', '', 0, ''); INSERT INTO `rekeningstelsel` VALUES (2, '10.', 'Kapitaal', '', 'I.', 'P', 0, ''); INSERT INTO `rekeningstelsel` VALUES (3, '100', 'Geplaatst kapitaal', '', 'I.A.', 'P', 0, ''); INSERT INTO `rekeningstelsel` VALUES (4, '101', 'Niet-opgevraagd kapitaal (-)', '', 'I.B.', 'P', 0, ''); INSERT INTO `rekeningstelsel` VALUES (5, '102', 'Afgeschreven kapitaal', '', 'I.A.', 'P', 0, ''); INSERT INTO `rekeningstelsel` VALUES (6, '109', 'Rekening van de uitbater', '', 'I.A.', 'P', 0, ''); INSERT INTO `rekeningstelsel` VALUES (7, '11.', 'Uitgiftepremies', '', 'II.', 'P', 0, ''); INSERT INTO `rekeningstelsel` VALUES (8, '12.', 'Herwaarderingsmeerwaarden', '', 'III.', 'P', 0, ''); INSERT INTO `rekeningstelsel` VALUES (9, '120', 'Herwaarderingsmeerwaarden op immateriële vaste activa', '', '', '', 0, ''); .... Voor de volledige code : klik hier (Code te groot voor tekstvak )
24-08-2007 om 00:00 geschreven door de makers
16-08-2007
Java :: eclipse :: Voorbeeld DAO [sample DAO (klant,user database mysql)
Elipse :: java »» Project DAO
:: voorbeeld (sample user , klant : database mysql).
Structuur :
[-]prjdao (project)
| |
| [-]config (map)
| |
klant.hbm.xml
| |
user.hbm.xml
| |
| [-]src (package)
| |
main.java
| |
Klant.java
| |
User.java
| |
KlantDao.java
| |
UserDao.java
| |
HibernateFactory.java
| |
ConstructDao.java
| |
DataAccessError.java
| [+] JRE System Library
| [+] xerces-2.6.2.jar
| [+] ant-antlr-1.6.3.jar
| [+] antlr-2.7.5H3.jar
| [+] asm.jar
| [+] asm-attrs.jar
| [+] cglib-2.1.jar
| [+] commons-collections-2.1.1.jar
| [+] commons-logging-1.0.4.jar
| [+] dom4j-1.6.jar
| [+] ehache-1.1.jar
| [+] hibernate3.jar
| [+] hsqldb.jar
| [+] jta.jar
| [+] log4j-1.2.9.jar
| [+] mysql-connector-java-3.1.6-bin.jar
|
hibernate.cfg.xml
log4j.properties
1.--- begin main .java ------
package src;
import java.util.Date;
public class Main {
public static void main(String[] args) {
Date now = new Date ();
/*
* User toevoegen aan de database
*/
System.out.println("user toegevoegd voor");
UserDao userDao = new UserDao();
User user = new User();
userDao.create(user);
user.setNaam("De Gavere");
user.setWachtwoord("gaverzicht");
user.setAansluiting(now);
userDao.update(user);
System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>user
toegevoegd");
userDao.findAll();
/*
* Klant toevoegen aan de database
*/
KlantDao klantDao = new KlantDao();
Klant klant = new Klant();
klantDao.create(klant);
klant.setVoornaam("Kere-gerom");
klant.setAchternaam("Reuzegom");
klant.setStraat("Lange Wapperstraat");
klant.setHuisnr("12");
klant.setPostnr("8640");
klant.setGemeente("Papoptvier");
klantDao.update(klant);
System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>klant
toegevoegd");
klantDao.findAll();
System.out.println("Einde main");
}
}
--- einde Main java ------ top
2.--- begin Klant .java ------
package src;
public class Klant {//implements Serializable {
private Long id;
private String voonaam;
private String achternaam;
private String straat;
private String huisnr;
private String postnr;
private String gemeente;
public Long getId() {return id;}
public void setId(Long id) {this.id = id;}
public String getVoornaam() {return voonaam;}
public void setVoornaam(String voonaam) {this.voonaam = voonaam;}
public String getAchternaam() {return achternaam;}
public void setAchternaam(String achternaam) {this.achternaam = achternaam;}
public String getStraat() {return straat;}
public void setStraat(String straat) {this.straat = straat;}
public String getHuisnr() {return huisnr;}
public void setHuisnr(String huisnr) {this.huisnr = huisnr;}
public String getPostnr() {return postnr;}
public void setPostnr(String postnr) {this.postnr = postnr;}
public String getGemeente() {return gemeente;}
public void setGemeente(String gemeente) {this.gemeente = gemeente;}
}
--- einde Klant.java ------
top
3.--- begin User .java ------
package src;
import java.util.Date;
public class User {
private Long id;
private int werkniveau;
private String naam;
private String wachtwoord;
private Date aansluiting;
public Long getId() {return id;}
public void setId(Long id) {this.id = id;}
public String getNaam() {return naam;}
public void setNaam(String naam) {System.out.println("in klant :naam");this.naam
= naam;}
public String getWachtwoord() {return wachtwoord;}
public void setWachtwoord(String wachtwoord) {this.wachtwoord = wachtwoord;}
public Date getAansluiting() {return aansluiting;}
public void setAansluiting(Date aansluiting) {this.aansluiting = aansluiting;}
public int getwerkniveau() {return werkniveau;}
public void setwerkniveau(int werkniveau) {this.werkniveau = werkniveau;}
}
--- einde User.java ------
top
4.--- begin HibernateFactory .java
------
package src;
import org.hibernate.*;
import org.hibernate.cfg.Configuration;
import org.apache.commons.logging.*;
public class HibernateFactory {
private static SessionFactory sessionFactory;
private static Log log = LogFactory.getLog(HibernateFactory.class);
/*
* Maakt een nieuwe Singleton SessionFactory aan
*/
public static SessionFactory buildSessionFactory() throws
HibernateException {
System.out.println("sessionfact build");
if (sessionFactory != null) {
closeFactory();
}
return configureSessionFactory();
}
/*
* Maakt een nieuwe Singleton SessionFactory aan indien nodig.
*/
public static SessionFactory buildIfNeeded() throws
DataAccessError{
if (sessionFactory != null) {
return sessionFactory;
}
try {
return
configureSessionFactory();
} catch (HibernateException err) {
throw new DataAccessError("build if
needed mislukt >> "+err);
}
}
public static SessionFactory getSessionFactory() {
return sessionFactory;
}
public static Session openSession() throws HibernateException {
buildIfNeeded();
return sessionFactory.openSession();
}
public static void closeFactory() {
if (sessionFactory != null) {
try {
sessionFactory.close();
} catch (HibernateException ignored)
{
log.error("SessionFactory
kon niet afgesloten worden", ignored);
}
}
}
public static void close(Session session) {
if (session != null) {
try {
session.close();
} catch (HibernateException ignored)
{
log.error("Session kon niet
afgesloten worden", ignored);
}
}
}
public static void rollback(Transaction trans) {
try {
if (trans != null) {
trans.rollback();
System.out.println("Terugschroeven");
}
} catch (HibernateException ignored) {
log.error("Transaction-terugschroeven
(rollback) is mislukt", ignored);
}
}
/*
* Configuratie SessionFactory
*/
private static SessionFactory configureSessionFactory() throws
HibernateException {
Configuration configuration = new Configuration();
configuration.configure();
sessionFactory = configuration.buildSessionFactory();
return sessionFactory;
}
}
--- einde HibernateFactory.java ------
top
5 .--- begin
ConstructDao .java -----
package src;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.Query;
import java.util.List;
public abstract class ConstructDao {
private Session session;
private Transaction trans;
public ConstructDao() {
System.out.println("maak indien nodig");
HibernateFactory.buildIfNeeded();
}
protected void saveOrUpdate(Object obj) {
try {
System.out.println("saveOrUpdate");
openSessionTrans();
session.saveOrUpdate(obj);
trans.commit();
} catch (HibernateException err) {
handleException(err);
} finally {
HibernateFactory.rollback(trans);
HibernateFactory.close(session);
}
}
protected void delete(Object object) {
try {
openSessionTrans();
session.delete(object);
trans.commit();
} catch (HibernateException err) {
handleException(err);
} finally {
HibernateFactory.close(session);
}
}
protected Object find(Class clazz, Long id) {
Object object = null;
try {
openSessionTrans();
object = session.load(clazz, id);
trans.commit();
} catch (HibernateException err) {
handleException(err);
} finally {
HibernateFactory.close(session);
}
return object;
}
protected List findAll(Class clazz) {
List objects = null;
try {
openSessionTrans();
Query query = session.createQuery("from
" + clazz.getName());
objects = query.list();
trans.commit();
} catch (HibernateException err) {
handleException(err);
} finally {
HibernateFactory.close(session);
}
return objects;
}
protected void handleException(HibernateException err) throws DataAccessError {
HibernateFactory.rollback(trans);
throw new DataAccessError(err);
}
protected void openSessionTrans() throws HibernateException {
System.out.println("openSessionTrans");
session = HibernateFactory.openSession();
trans = session.beginTransaction();
}
}
--- einde ConstructDao.java ------
top
6.--- begin KlantDao. java
------
package src;
import java.util.List;
public class KlantDao extends ConstructDao {
public KlantDao() {
super();
}
/*
* Nieuwe Klant toevoegen aan database.
*/
public void create(Klant klant) throws DataAccessError {
super.saveOrUpdate(klant);
}
/*
* Een Klant verwijderen van de database.
*/
public void delete(Klant klant) throws DataAccessError {
super.delete(klant);
}
/*
* Een Klant vinden met de primary key.
*/
public Klant find(Long id) throws DataAccessError {
System.out.print("klant update");
return (Klant) super.find(Klant.class, id);
}
/*
* Klant toevoegen aan - of wijzigen in de database.
*/
public void update(Klant klant) throws DataAccessError {
System.out.print("klant update");
super.saveOrUpdate(klant);
}
/**
* Zoek alle klanten in de database.
*/
public List findAll() throws DataAccessError{
return super.findAll(Klant.class);
}
}
--- einde klantDao.java ------
top
7.--- begin UserDao .java ------
package src;
import java.util.List;
public class UserDao extends ConstructDao {
public UserDao() {
super();
}
/*
* Een User toevoegen aan - wijzigen in de database.
*/
public void create(User user) throws DataAccessError {
super.saveOrUpdate(user);
}
/*
* Een User verwijderen uit de database.
*/
public void delete(User user) throws DataAccessError {
super.delete(user);
}
/**
* Find an Event by its primary key.
* @param id
* @return
*/
public User find(Long id) throws DataAccessError {
return (User) super.find(User.class, id);
}
/*
* User toevoegen aan - of wijzigen in de database.
*/
public void update(User user) throws DataAccessError {
System.out.println(">>>>> user update");
super.saveOrUpdate(user);
}
/*
* Haal alle users op uit de database.
*/
public List findAll() throws DataAccessError{
return super.findAll(User.class);
}
}
--- einde UserDao.java ------
top
8.--- begin DataAccesError .java ------
package src;
/*
* Exceptions opgeworpen door de Data Access Layer.
*/
public class DataAccessError extends RuntimeException {
public DataAccessError() {
}
public DataAccessError(String message) {
super(message);
}
public DataAccessError(Throwable cause) {
super(cause);
}
public DataAccessError(String message, Throwable cause) {
super(message, cause);
}
}
--- einde DataAccesError.java ------
top
map config
klant.hbm.xml
user.hbm.xml
1.--- begin klant.hbm .xml
------
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping >
<class name="src.Klant" table="klanten">
<id name="id" column="id"
type="long">
<generator class="increment"/>
</id>
<property name="voornaam" type="string"/>
<property name="achternaam" type="string"/>
<property name="straat" type="string"/>
<property name="huisnr" type="string"/>
<property name="postnr" type="string"/>
<property name="gemeente" type="string"/>
</class>
</hibernate-mapping>
--- einde klant.hbm.xml ------
top
2.--- begin user.hbm .xml ------
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping >
<class name="src.User" table="users">
<id name="id" column="id"
type="long">
<generator class="increment"/>
</id>
<property name="naam" type="string"/>
<property name="wachtwoord" type="string"/>
<property name="aansluiting"
type="date"/>
<property name="werkniveau"
type="integer"/>
</class>
</hibernate-mapping>
--- einde user.hbm.xml ------
top
project prjdao
hibernate.cfg.xml
log4j.properties
1.--- begin hibernate.cfg .xml
------
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- Database connection settings -->
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost/mysqltest</property>
<property name="connection.username">db-usernaam</property>
<property name="connection.password">uwpaswoord</property>
<!-- JDBC connection pool (use the
built-in) -->
<property name="connection.pool_size">1</property>
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.HSQLDialect</property>
<!-- Echo all executed SQL to stdout
-->
<property name="show_sql">true</property>
<mapping resource="config/User.hbm.xml"/>
<mapping resource="config/Klant.hbm.xml"/>
</session-factory>
</hibernate-configuration>
--- einde hibernate.cfg.xml ------
top
2.--- begin log4j .properties ------
log4j.rootLogger=DEBUG, A1
log4j.appender.A1=
org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=
org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=
%-4r [%t] %-5p %c %x - %m%n
--- einde log4j.properties ------
top
Tables mysql database "mysqltest" -- phpMyAdmin SQL Dump -- version 2.6.1-pl3 -- http://www.phpmyadmin.net -- -- Host: localhost -- Generatie Tijd: 17 Aug 2007 om 17:40 -- Server versie: 5.0.24 -- PHP Versie: 5.0.3 -- -- Database: `mysqltest` -- -- -------------------------------------------------------- -- -- Tabel structuur voor tabel `klanten` -- CREATE TABLE `klanten` ( `id` bigint(20) NOT NULL auto_increment, `voornaam` varchar(30) default NULL, `achternaam` varchar(15) default NULL, `straat` varchar(30) default NULL, `huisnr` varchar(10) default NULL, `postnr` varchar(4) default NULL, `gemeente` varchar(30) default NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=36 ; -- -- Gegevens worden uitgevoerd voor tabel `klanten` -- INSERT INTO `klanten` VALUES (1, 'Reuzegom', 'Kere-gerom', 'Smallestraat', '12', '8640', 'Tzalbeteren'); INSERT INTO `klanten` VALUES (2, 'Kere-gerom', 'Reuzegom', 'Wapperstraat', '12', '8640', 'Tzalbeteren'); INSERT INTO `klanten` VALUES (3, 'Kere-gerom', 'Reuzegom', 'Wapperstraat', '12', '8640', 'Tzalbeteren'); INSERT INTO `klanten` VALUES (4, 'Kere-gerom', 'Reuzegom', 'Wapperstraat', '12', '8640', 'Tzalbeteren'); INSERT INTO `klanten` VALUES (5, 'Kere-gerom', 'Reuzegom', 'Wapperstraat', '12', '8640', 'Tzalbeteren'); INSERT INTO `klanten` VALUES (6, 'Kere-gerom', 'Reuzegom', 'Wapperstraat', '12', '8640', 'Papoptvier'); INSERT INTO `klanten` VALUES (7, 'Kere-gerom', 'Reuzegom', 'Wapperstraat', '12', '8640', 'Papoptvier'); INSERT INTO `klanten` VALUES (8, 'Kere-gerom', 'Reuzegom', 'Wapperstraat', '12', '8640', 'Papoptvier'); INSERT INTO `klanten` VALUES (9, 'Kere-gerom', 'Reuzegom', 'Wapperstraat', '12', '8640', 'Papoptvier'); INSERT INTO `klanten` VALUES (10, 'Kere-gerom', 'Reuzegom', 'Wapperstraat', '12', '8640', 'Papoptvier'); INSERT INTO `klanten` VALUES (11, 'Kere-gerom', 'Reuzegom', 'Wapperstraat', '12', '8640', 'Papoptvier'); INSERT INTO `klanten` VALUES (12, 'Kere-gerom', 'Reuzegom', 'Wapperstraat', '12', '8640', 'Papoptvier'); INSERT INTO `klanten` VALUES (13, 'Kere-gerom', 'Reuzegom', 'Wapperstraat', '12', '8640', 'Papoptvier'); INSERT INTO `klanten` VALUES (14, 'Kere-gerom', 'Reuzegom', 'Wapperstraat', '12', '8640', 'Papoptvier'); INSERT INTO `klanten` VALUES (15, 'Kere-gerom', 'Reuzegom', 'Wapperstraat', '12', '8640', 'Papoptvier'); INSERT INTO `klanten` VALUES (16, 'Kere-gerom', 'Reuzegom', 'Wapperstraat', '12', '8640', 'Papoptvier'); INSERT INTO `klanten` VALUES (17, 'Kere-gerom', 'Reuzegom', 'Wapperstraat', '12', '8640', 'Papoptvier'); INSERT INTO `klanten` VALUES (18, 'Kere-gerom', 'Reuzegom', 'Wapperstraat', '12', '8640', 'Papoptvier'); INSERT INTO `klanten` VALUES (19, 'Kere-gerom', 'Reuzegom', 'Wapperstraat', '12', '8640', 'Papoptvier'); INSERT INTO `klanten` VALUES (20, 'Kere-gerom', 'Reuzegom', 'Wapperstraat', '12', '8640', 'Papoptvier'); INSERT INTO `klanten` VALUES (21, 'Kere-gerom', 'Reuzegom', 'Wapperstraat', '12', '8640', 'Papoptvier'); INSERT INTO `klanten` VALUES (22, 'Kere-gerom', 'Reuzegom', 'Wapperstraat', '12', '8640', 'Papoptvier'); INSERT INTO `klanten` VALUES (23, 'Kere-gerom', 'Reuzegom', 'Wapperstraat', '12', '8640', 'Papoptvier'); INSERT INTO `klanten` VALUES (24, 'Kere-gerom', 'Reuzegom', 'Wapperstraat', '12', '8640', 'Papoptvier'); INSERT INTO `klanten` VALUES (25, 'Kere-gerom', 'Reuzegom', 'Wapperstraat', '12', '8640', 'Papoptvier'); INSERT INTO `klanten` VALUES (26, 'Kere-gerom', 'Reuzegom', 'Wapperstraat', '12', '8640', 'Papoptvier'); INSERT INTO `klanten` VALUES (27, 'Kere-gerom', 'Reuzegom', 'Wapperstraat', '12', '8640', 'Papoptvier'); INSERT INTO `klanten` VALUES (28, 'Kere-gerom', 'Reuzegom', 'Lange Wapperstraat', '12', '8640', 'Papoptvier'); INSERT INTO `klanten` VALUES (29, 'Kere-gerom', 'Reuzegom', 'Lange Wapperstraat', '12', '8640', 'Papoptvier'); INSERT INTO `klanten` VALUES (30, 'Kere-gerom', 'Reuzegom', 'Lange Wapperstraat', '12', '8640', 'Papoptvier'); INSERT INTO `klanten` VALUES (31, 'Kere-gerom', 'Reuzegom', 'Lange Wapperstraat', '12', '8640', 'Papoptvier'); INSERT INTO `klanten` VALUES (32, 'Kere-gerom', 'Reuzegom', 'Lange Wapperstraat', '12', '8640', 'Papoptvier'); INSERT INTO `klanten` VALUES (33, 'Kere-gerom', 'Reuzegom', 'Lange Wapperstraat', '12', '8640', 'Papoptvier'); INSERT INTO `klanten` VALUES (34, 'Kere-gerom', 'Reuzegom', 'Lange Wapperstraat', '12', '8640', 'Papoptvier'); INSERT INTO `klanten` VALUES (35, 'Kere-gerom', 'Reuzegom', 'Lange Wapperstraat', '12', '8640', 'Papoptvier'); -- phpMyAdmin SQL Dump -- version 2.6.1-pl3 -- http://www.phpmyadmin.net -- -- Host: localhost -- Generatie Tijd: 17 Aug 2007 om 17:41 -- Server versie: 5.0.24 -- PHP Versie: 5.0.3 -- -- Database: `mysqltest` -- -- -------------------------------------------------------- -- -- Tabel structuur voor tabel `users` -- CREATE TABLE `users` ( `id` bigint(20) NOT NULL auto_increment, `naam` varchar(30) default NULL, `wachtwoord` varchar(10) default NULL, `aansluiting` date default NULL, `werkniveau` int(11) default NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=13 ; -- -- Gegevens worden uitgevoerd voor tabel `users` -- INSERT INTO `users` VALUES (1, 'dillems', 'blabla', '2007-07-29', 1); INSERT INTO `users` VALUES (2, 'De Vlucht', 'Wachtwoord', '2007-08-08', 0); INSERT INTO `users` VALUES (3, 'De Vlucht', 'Wachtwoord', '2007-08-08', 0); INSERT INTO `users` VALUES (4, 'De Gavere', 'gaverzicht', '2007-08-08', 0); INSERT INTO `users` VALUES (5, 'De Gavere', 'gaverzicht', '2007-08-08', 0); INSERT INTO `users` VALUES (6, 'De Gavere', 'gaverzicht', '2007-08-09', 0); INSERT INTO `users` VALUES (7, 'De Gavere', 'gaverzicht', '2007-08-09', 0); INSERT INTO `users` VALUES (8, 'De Gavere', 'gaverzicht', '2007-08-09', 0); INSERT INTO `users` VALUES (9, 'De Gavere', 'gaverzicht', '2007-08-09', 0); INSERT INTO `users` VALUES (10, NULL, NULL, NULL, 0); INSERT INTO `users` VALUES (11, 'De Gavere', 'gaverzicht', '2007-08-17', 0); INSERT INTO `users` VALUES (12, 'De Gavere', 'gaverzicht', '2007-08-17', 0);
Resultaat prjdao
16-08-2007 om 00:00 geschreven door de makers
15-08-2007
Resultaat eclipse project DAO :: jrjdao
Resultaat prjdao na vervangen User en KlantDao door dbDao: 0 [main] INFO org.hibernate.cfg.Environment - Hibernate 3.0rc1 0 [main] INFO org.hibernate.cfg.Environment - hibernate.properties not found 0 [main] INFO org.hibernate.cfg.Environment - using CGLIB reflection optimizer 0 [main] INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling 0 [main] INFO org.hibernate.cfg.Configuration - configuring from resource: /hibernate.cfg.xml 0 [main] INFO org.hibernate.cfg.Configuration - Configuration resource: /hibernate.cfg.xml 313 [main] DEBUG org.hibernate.util.DTDEntityResolver - trying to locate http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd in classpath under org/hibernate/ 313 [main] DEBUG org.hibernate.util.DTDEntityResolver - found http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd in classpath 360 [main] DEBUG org.hibernate.cfg.Configuration - connection.driver_class=com.mysql.jdbc.Driver 360 [main] DEBUG org.hibernate.cfg.Configuration - connection.url=jdbc:mysql://localhost/mysqltest 375 [main] DEBUG org.hibernate.cfg.Configuration - connection.username=xxxxx 375 [main] DEBUG org.hibernate.cfg.Configuration - connection.password=xxxxxx 375 [main] DEBUG org.hibernate.cfg.Configuration - connection.pool_size=1 375 [main] DEBUG org.hibernate.cfg.Configuration - dialect=org.hibernate.dialect.HSQLDialect 375 [main] DEBUG org.hibernate.cfg.Configuration - show_sql=true 375 [main] DEBUG org.hibernate.cfg.Configuration - null<-org.dom4j.tree.DefaultAttribute@c3c749 [Attribute: name resource value "config/User.hbm.xml"] 375 [main] INFO org.hibernate.cfg.Configuration - Mapping resource: config/User.hbm.xml 375 [main] DEBUG org.hibernate.util.DTDEntityResolver - trying to locate http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd in classpath under org/hibernate/ 375 [main] DEBUG org.hibernate.util.DTDEntityResolver - found http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd in classpath 500 [main] INFO org.hibernate.cfg.HbmBinder - Mapping class: src.User -> users 500 [main] DEBUG org.hibernate.cfg.HbmBinder - Mapped property: id -> id 516 [main] DEBUG org.hibernate.cfg.HbmBinder - Mapped property: naam -> naam 516 [main] DEBUG org.hibernate.cfg.HbmBinder - Mapped property: wachtwoord -> wachtwoord 516 [main] DEBUG org.hibernate.cfg.HbmBinder - Mapped property: aansluiting -> aansluiting 516 [main] DEBUG org.hibernate.cfg.HbmBinder - Mapped property: werkniveau -> werkniveau 516 [main] DEBUG org.hibernate.cfg.Configuration - null<-org.dom4j.tree.DefaultAttribute@56a499 [Attribute: name resource value "config/Klant.hbm.xml"] 516 [main] INFO org.hibernate.cfg.Configuration - Mapping resource: config/Klant.hbm.xml 516 [main] DEBUG org.hibernate.util.DTDEntityResolver - trying to locate http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd in classpath under org/hibernate/ 516 [main] DEBUG org.hibernate.util.DTDEntityResolver - found http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd in classpath 563 [main] INFO org.hibernate.cfg.HbmBinder - Mapping class: src.Klant -> klanten 563 [main] DEBUG org.hibernate.cfg.HbmBinder - Mapped property: id -> id 563 [main] DEBUG org.hibernate.cfg.HbmBinder - Mapped property: voornaam -> voornaam 563 [main] DEBUG org.hibernate.cfg.HbmBinder - Mapped property: achternaam -> achternaam 563 [main] DEBUG org.hibernate.cfg.HbmBinder - Mapped property: straat -> straat 563 [main] DEBUG org.hibernate.cfg.HbmBinder - Mapped property: huisnr -> huisnr 563 [main] DEBUG org.hibernate.cfg.HbmBinder - Mapped property: postnr -> postnr 563 [main] DEBUG org.hibernate.cfg.HbmBinder - Mapped property: gemeente -> gemeente 563 [main] INFO org.hibernate.cfg.Configuration - Configured SessionFactory: null 579 [main] DEBUG org.hibernate.cfg.Configuration - properties: 579 [main] DEBUG org.hibernate.cfg.Configuration - Preparing to build session factory with filters : {} 579 [main] INFO org.hibernate.cfg.Configuration - processing extends queue 579 [main] INFO org.hibernate.cfg.Configuration - processing collection mappings 579 [main] INFO org.hibernate.cfg.Configuration - processing association property references 579 [main] INFO org.hibernate.cfg.Configuration - processing foreign key constraints 672 [main] INFO org.hibernate.dialect.Dialect - Using dialect: org.hibernate.dialect.HSQLDialect 672 [main] DEBUG org.hibernate.exception.SQLExceptionConverterFactory - Using dialect defined converter 688 [main] INFO org.hibernate.cfg.SettingsFactory - Default batch fetch size: 1 688 [main] INFO org.hibernate.cfg.SettingsFactory - Generate SQL with comments: disabled 688 [main] INFO org.hibernate.cfg.SettingsFactory - Order SQL updates by primary key: disabled 688 [main] INFO org.hibernate.cfg.SettingsFactory - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory 688 [main] INFO org.hibernate.hql.ast.ASTQueryTranslatorFactory - Using ASTQueryTranslatorFactory 688 [main] INFO org.hibernate.cfg.SettingsFactory - Query language substitutions: {} 688 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - Using Hibernate built-in connection pool (not for production use!) 688 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - Hibernate connection pool size: 1 688 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - autocommit mode: false 704 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost/mysqltest 704 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - connection properties: {user=user, password=passwoord} 704 [main] DEBUG org.hibernate.connection.DriverManagerConnectionProvider - total checked-out connections: 0 704 [main] DEBUG org.hibernate.connection.DriverManagerConnectionProvider - opening new JDBC connection 891 [main] DEBUG org.hibernate.connection.DriverManagerConnectionProvider - created connection to: jdbc:mysql://localhost/mysqltest, Isolation Level: 4 891 [main] DEBUG org.hibernate.connection.DriverManagerConnectionProvider - returning connection to pool, pool size: 1 891 [main] INFO org.hibernate.cfg.SettingsFactory - JDBC batch size: 15 891 [main] INFO org.hibernate.cfg.SettingsFactory - JDBC batch updates for versioned data: disabled 891 [main] INFO org.hibernate.cfg.SettingsFactory - Scrollable result sets: enabled 891 [main] DEBUG org.hibernate.cfg.SettingsFactory - Wrap result sets: disabled 891 [main] INFO org.hibernate.cfg.SettingsFactory - JDBC3 getGeneratedKeys(): enabled 891 [main] INFO org.hibernate.transaction.TransactionFactoryFactory - Using default transaction strategy (direct JDBC transactions) 891 [main] INFO org.hibernate.transaction.TransactionManagerLookupFactory - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended) 907 [main] INFO org.hibernate.cfg.SettingsFactory - Automatic flush during beforeCompletion(): disabled 907 [main] INFO org.hibernate.cfg.SettingsFactory - Automatic session close at end of transaction: disabled 907 [main] INFO org.hibernate.cfg.SettingsFactory - Cache provider: org.hibernate.cache.EhCacheProvider 907 [main] INFO org.hibernate.cfg.SettingsFactory - Second-level cache: enabled 907 [main] INFO org.hibernate.cfg.SettingsFactory - Optimize cache for minimal puts: disabled 907 [main] INFO org.hibernate.cfg.SettingsFactory - Structured second-level cache entries: enabled 907 [main] INFO org.hibernate.cfg.SettingsFactory - Query cache: disabled 907 [main] INFO org.hibernate.cfg.SettingsFactory - Echoing all SQL to stdout 907 [main] INFO org.hibernate.cfg.SettingsFactory - Statistics: disabled 907 [main] INFO org.hibernate.cfg.SettingsFactory - Deleted entity synthetic identifier rollback: disabled 907 [main] INFO org.hibernate.cfg.SettingsFactory - Default entity-mode: pojo 1063 [main] INFO org.hibernate.impl.SessionFactoryImpl - building session factory 1063 [main] DEBUG org.hibernate.impl.SessionFactoryImpl - Session factory constructed with filter configurations : {} 1063 [main] DEBUG org.hibernate.impl.SessionFactoryImpl - instantiating session factory with properties: 1063 [main] DEBUG net.sf.ehcache.CacheManager - Creating new CacheManager with default config 1063 [main] DEBUG net.sf.ehcache.CacheManager - Configuring ehcache from classpath. 1063 [main] WARN net.sf.ehcache.config.Configurator - No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/J:/eclipse/jars_plugins/jars/ibernate3-extra/ehcache-1.1.jar!/ehcache-failsafe.xml 1079 [main] DEBUG net.sf.ehcache.config.Configuration$DiskStore - Disk Store Path: C:DOCUME~1EigenaarLOCALS~1Temp in klant :naam 1360 [main] DEBUG org.hibernate.persister.entity.BasicEntityPersister - Static SQL for entity: src.User 1360 [main] DEBUG org.hibernate.persister.entity.BasicEntityPersister - Version select: select id from users where id =? 1360 [main] DEBUG org.hibernate.persister.entity.BasicEntityPersister - Snapshot select: select user_.id, user_.naam as naam0_, user_.wachtwoord as wachtwoord0_, user_.aansluiting as aansluit4_0_, user_.werkniveau as werkniveau0_ from users user_ where user_.id=? 1360 [main] DEBUG org.hibernate.persister.entity.BasicEntityPersister - Insert 0: insert into users (naam, wachtwoord, aansluiting, werkniveau, id) values (?, ?, ?, ?, ?) 1360 [main] DEBUG org.hibernate.persister.entity.BasicEntityPersister - Update 0: update users set naam=?, wachtwoord=?, aansluiting=?, werkniveau=? where id=? 1360 [main] DEBUG org.hibernate.persister.entity.BasicEntityPersister - Delete 0: delete from users where id=? 1454 [main] DEBUG org.hibernate.persister.entity.BasicEntityPersister - Static SQL for entity: src.Klant 1454 [main] DEBUG org.hibernate.persister.entity.BasicEntityPersister - Version select: select id from klanten where id =? 1454 [main] DEBUG org.hibernate.persister.entity.BasicEntityPersister - Snapshot select: select klant_.id, klant_.voornaam as voornaam1_, klant_.achternaam as achternaam1_, klant_.straat as straat1_, klant_.huisnr as huisnr1_, klant_.postnr as postnr1_, klant_.gemeente as gemeente1_ from klanten klant_ where klant_.id=? 1454 [main] DEBUG org.hibernate.persister.entity.BasicEntityPersister - Insert 0: insert into klanten (voornaam, achternaam, straat, huisnr, postnr, gemeente, id) values (?, ?, ?, ?, ?, ?, ?) 1454 [main] DEBUG org.hibernate.persister.entity.BasicEntityPersister - Update 0: update klanten set voornaam=?, achternaam=?, straat=?, huisnr=?, postnr=?, gemeente=? where id=? 1454 [main] DEBUG org.hibernate.persister.entity.BasicEntityPersister - Delete 0: delete from klanten where id=? 1485 [main] DEBUG org.hibernate.loader.entity.EntityLoader - Static select for entity src.User: select user0_.id as id0_, user0_.naam as naam0_0_, user0_.wachtwoord as wachtwoord0_0_, user0_.aansluiting as aansluit4_0_0_, user0_.werkniveau as werkniveau0_0_ from users user0_ where user0_.id=? 1485 [main] DEBUG org.hibernate.loader.entity.EntityLoader - Static select for entity src.User: select user0_.id as id0_, user0_.naam as naam0_0_, user0_.wachtwoord as wachtwoord0_0_, user0_.aansluiting as aansluit4_0_0_, user0_.werkniveau as werkniveau0_0_ from users user0_ where user0_.id=? 1485 [main] DEBUG org.hibernate.loader.entity.EntityLoader - Static select for entity src.User: select user0_.id as id0_, user0_.naam as naam0_0_, user0_.wachtwoord as wachtwoord0_0_, user0_.aansluiting as aansluit4_0_0_, user0_.werkniveau as werkniveau0_0_ from users user0_ where user0_.id=? 1485 [main] DEBUG org.hibernate.loader.entity.EntityLoader - Static select for entity src.User: select user0_.id as id0_, user0_.naam as naam0_0_, user0_.wachtwoord as wachtwoord0_0_, user0_.aansluiting as aansluit4_0_0_, user0_.werkniveau as werkniveau0_0_ from users user0_ where user0_.id=? 1485 [main] DEBUG org.hibernate.loader.entity.EntityLoader - Static select for entity src.Klant: select klant0_.id as id0_, klant0_.voornaam as voornaam1_0_, klant0_.achternaam as achternaam1_0_, klant0_.straat as straat1_0_, klant0_.huisnr as huisnr1_0_, klant0_.postnr as postnr1_0_, klant0_.gemeente as gemeente1_0_ from klanten klant0_ where klant0_.id=? 1485 [main] DEBUG org.hibernate.loader.entity.EntityLoader - Static select for entity src.Klant: select klant0_.id as id0_, klant0_.voornaam as voornaam1_0_, klant0_.achternaam as achternaam1_0_, klant0_.straat as straat1_0_, klant0_.huisnr as huisnr1_0_, klant0_.postnr as postnr1_0_, klant0_.gemeente as gemeente1_0_ from klanten klant0_ where klant0_.id=? 1485 [main] DEBUG org.hibernate.loader.entity.EntityLoader - Static select for entity src.Klant: select klant0_.id as id0_, klant0_.voornaam as voornaam1_0_, klant0_.achternaam as achternaam1_0_, klant0_.straat as straat1_0_, klant0_.huisnr as huisnr1_0_, klant0_.postnr as postnr1_0_, klant0_.gemeente as gemeente1_0_ from klanten klant0_ where klant0_.id=? 1485 [main] DEBUG org.hibernate.loader.entity.EntityLoader - Static select for entity src.Klant: select klant0_.id as id0_, klant0_.voornaam as voornaam1_0_, klant0_.achternaam as achternaam1_0_, klant0_.straat as straat1_0_, klant0_.huisnr as huisnr1_0_, klant0_.postnr as postnr1_0_, klant0_.gemeente as gemeente1_0_ from klanten klant0_ where klant0_.id=? 1485 [main] DEBUG org.hibernate.impl.SessionFactoryObjectFactory - initializing class SessionFactoryObjectFactory 1500 [main] DEBUG org.hibernate.impl.SessionFactoryObjectFactory - registered: 402881e6147cdcb601147cdcb85d0000 (unnamed) 1500 [main] INFO org.hibernate.impl.SessionFactoryObjectFactory - Not binding factory to JNDI, no JNDI name configured 1500 [main] DEBUG org.hibernate.impl.SessionFactoryImpl - instantiated session factory 1500 [main] INFO org.hibernate.impl.SessionFactoryImpl - Checking 0 named queries >>>>> user update saveOrUpdate openSessionTrans sessionfactorg.hibernate.impl.SessionFactoryImpl@fbb7cb 1532 [main] DEBUG org.hibernate.impl.SessionImpl - opened session 1532 [main] DEBUG org.hibernate.transaction.JDBCTransaction - begin 1532 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - opening JDBC connection 1532 [main] DEBUG org.hibernate.connection.DriverManagerConnectionProvider - total checked-out connections: 0 1532 [main] DEBUG org.hibernate.connection.DriverManagerConnectionProvider - using pooled JDBC connection, pool size: 0 1532 [main] DEBUG org.hibernate.transaction.JDBCTransaction - current autocommit status: false 1532 [main] DEBUG org.hibernate.event.def.AbstractSaveEventListener - transient instance of: src.User 1532 [main] DEBUG org.hibernate.event.def.DefaultSaveOrUpdateEventListener - saving transient instance 1532 [main] DEBUG org.hibernate.id.IncrementGenerator - fetching initial value: select max(id) from users 1547 [main] DEBUG org.hibernate.id.IncrementGenerator - first free id: 2 1547 [main] DEBUG org.hibernate.event.def.AbstractSaveEventListener - generated identifier: 2, using strategy: org.hibernate.id.IncrementGenerator 1547 [main] DEBUG org.hibernate.event.def.AbstractSaveEventListener - saving [src.User#2] 1563 [main] DEBUG org.hibernate.transaction.JDBCTransaction - commit 1563 [main] DEBUG org.hibernate.impl.SessionImpl - automatically flushing session 1563 [main] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - flushing session 1563 [main] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - processing flush-time cascades 1563 [main] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - dirty checking collections 1563 [main] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Flushing entities and processing referenced collections 1563 [main] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Processing unreferenced collections 1563 [main] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Scheduling collection removes/(re)creates/updates 1563 [main] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Flushed: 1 insertions, 0 updates, 0 deletions to 1 objects 1563 [main] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections 1563 [main] DEBUG org.hibernate.pretty.Printer - listing entities: 1579 [main] DEBUG org.hibernate.pretty.Printer - src.User{aansluiting=19 augustus 2007, naam=De Koster, wachtwoord=kost, id=2, werkniveau=0} 1579 [main] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - executing flush 1579 [main] DEBUG org.hibernate.persister.entity.BasicEntityPersister - Inserting entity: [src.User#2] 1579 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - about to open PreparedStatement (open PreparedStatements: 0, globally: 0) 1579 [main] DEBUG org.hibernate.SQL - insert into users (naam, wachtwoord, aansluiting, werkniveau, id) values (?, ?, ?, ?, ?) Hibernate: insert into users (naam, wachtwoord, aansluiting, werkniveau, id) values (?, ?, ?, ?, ?) 1579 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - preparing statement 1579 [main] DEBUG org.hibernate.persister.entity.BasicEntityPersister - Dehydrating entity: [src.User#2] 1579 [main] DEBUG org.hibernate.type.StringType - binding 'De Koster' to parameter: 1 1579 [main] DEBUG org.hibernate.type.StringType - binding 'kost' to parameter: 2 1579 [main] DEBUG org.hibernate.type.DateType - binding '19 augustus 2007' to parameter: 3 1579 [main] DEBUG org.hibernate.type.IntegerType - binding '0' to parameter: 4 1579 [main] DEBUG org.hibernate.type.LongType - binding '2' to parameter: 5 1579 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - Adding to batch 1579 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - Executing batch size: 1 1579 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - about to close PreparedStatement (open PreparedStatements: 1, globally: 1) 1579 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - closing statement 1579 [main] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - post flush 1579 [main] DEBUG org.hibernate.jdbc.JDBCContext - before transaction completion 1579 [main] DEBUG org.hibernate.impl.SessionImpl - before transaction completion 1610 [main] DEBUG org.hibernate.transaction.JDBCTransaction - committed JDBC Connection 1610 [main] DEBUG org.hibernate.jdbc.JDBCContext - after transaction completion 1610 [main] DEBUG org.hibernate.impl.SessionImpl - after transaction completion 1610 [main] DEBUG org.hibernate.transaction.JDBCTransaction - rollback 1610 [main] DEBUG org.hibernate.jdbc.JDBCContext - before transaction completion 1610 [main] DEBUG org.hibernate.impl.SessionImpl - before transaction completion 1610 [main] DEBUG org.hibernate.transaction.JDBCTransaction - rolled back JDBC Connection 1610 [main] DEBUG org.hibernate.jdbc.JDBCContext - after transaction completion 1610 [main] DEBUG org.hibernate.impl.SessionImpl - after transaction completion Terugschroeven 1610 [main] DEBUG org.hibernate.impl.SessionImpl - closing session 1610 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - closing JDBC connection (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0) 1610 [main] DEBUG org.hibernate.connection.DriverManagerConnectionProvider - returning connection to pool, pool size: 1 1610 [main] DEBUG org.hibernate.jdbc.JDBCContext - after transaction completion 1610 [main] DEBUG org.hibernate.impl.SessionImpl - after transaction completion >>>>>>>>>>>>>>>>>>>>>>>>>>user toegevoegd openSessionTrans sessionfactorg.hibernate.impl.SessionFactoryImpl@fbb7cb 1610 [main] DEBUG org.hibernate.impl.SessionImpl - opened session 1610 [main] DEBUG org.hibernate.transaction.JDBCTransaction - begin 1610 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - opening JDBC connection 1610 [main] DEBUG org.hibernate.connection.DriverManagerConnectionProvider - total checked-out connections: 0 1610 [main] DEBUG org.hibernate.connection.DriverManagerConnectionProvider - using pooled JDBC connection, pool size: 0 1610 [main] DEBUG org.hibernate.transaction.JDBCTransaction - current autocommit status: false 1610 [main] DEBUG org.hibernate.impl.SessionImpl - find: from src.User 1610 [main] DEBUG org.hibernate.engine.QueryParameters - named parameters: {} 1625 [Finalizer] DEBUG org.hibernate.jdbc.JDBCContext - running Session.finalize() 1688 [main] DEBUG org.hibernate.hql.ast.QueryTranslatorImpl - parse() - HQL: from src.User 1704 [main] DEBUG org.hibernate.hql.AST - --- HQL AST --- -[QUERY] CommonAST: 'query' -[SELECT_FROM] CommonAST: 'SELECT_FROM' -[FROM] CommonAST: 'from' -[DOT] CommonAST: '.' +-[IDENT] CommonAST: 'src' -[IDENT] CommonAST: 'User' 1704 [main] DEBUG hql.parser - throwQueryException() : no errors 1735 [main] DEBUG org.hibernate.hql.antlr.HqlSqlBaseWalker - query() << begin, level = 1 1766 [main] DEBUG org.hibernate.hql.ast.FromElement - src.User (no alias) -> user0_ 1766 [main] DEBUG org.hibernate.hql.antlr.HqlSqlBaseWalker - query() : finishing up... 1766 [main] DEBUG org.hibernate.hql.ast.HqlSqlWalker - Derived SELECT clause created. 1782 [main] DEBUG org.hibernate.hql.ast.JoinProcessor - Using FROM fragment [users user0_] 1782 [main] DEBUG org.hibernate.hql.antlr.HqlSqlBaseWalker - query() >> end, level = 1 1782 [main] DEBUG org.hibernate.hql.AST - --- SQL AST --- -[SELECT] QueryNode: 'SELECT' querySpaces (users) +-[SELECT_CLAUSE] SelectClause: '{derived select clause}' | +-[SELECT_EXPR] SelectExpressionImpl: 'user0_.id as id' {FromElement{explicit,not a collection join,classAlias=null,role=null,tableName=users,tableAlias=user0_,colums={,className=src.User}}} | -[SQL_TOKEN] SqlFragment: 'user0_.naam as naam0_, user0_.wachtwoord as wachtwoord0_, user0_.aansluiting as aansluit4_0_, user0_.werkniveau as werkniveau0_' -[FROM] FromClause: 'from' FromClause{from} -[FROM_FRAGMENT] FromElement: 'users user0_' FromElement{explicit,not a collection join,classAlias=null,role=null,tableName=users,tableAlias=user0_,colums={,className=src.User}} 1782 [main] DEBUG hql.parser - throwQueryException() : no errors 1797 [main] DEBUG org.hibernate.hql.ast.QueryTranslatorImpl - HQL: from src.User 1797 [main] DEBUG org.hibernate.hql.ast.QueryTranslatorImpl - SQL: select user0_.id as id, user0_.naam as naam0_, user0_.wachtwoord as wachtwoord0_, user0_.aansluiting as aansluit4_0_, user0_.werkniveau as werkniveau0_ from users user0_ 1797 [main] DEBUG hql.parser - throwQueryException() : no errors 1797 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - about to open PreparedStatement (open PreparedStatements: 0, globally: 0) 1797 [main] DEBUG org.hibernate.SQL - select user0_.id as id, user0_.naam as naam0_, user0_.wachtwoord as wachtwoord0_, user0_.aansluiting as aansluit4_0_, user0_.werkniveau as werkniveau0_ from users user0_ Hibernate: select user0_.id as id, user0_.naam as naam0_, user0_.wachtwoord as wachtwoord0_, user0_.aansluiting as aansluit4_0_, user0_.werkniveau as werkniveau0_ from users user0_ 1797 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - preparing statement 1797 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - about to open ResultSet (open ResultSets: 0, globally: 0) 1797 [main] DEBUG org.hibernate.loader.Loader - processing result set 1797 [main] DEBUG org.hibernate.loader.Loader - result set row: 0 1797 [main] DEBUG org.hibernate.type.LongType - returning '1' as column: id 1797 [main] DEBUG org.hibernate.loader.Loader - result row: EntityKey[src.User#1] 1797 [main] DEBUG org.hibernate.loader.Loader - Initializing object from ResultSet: [src.User#1] 1797 [main] DEBUG org.hibernate.persister.entity.BasicEntityPersister - Hydrating entity: [src.User#1] 1797 [main] DEBUG org.hibernate.type.StringType - returning 'De Koster' as column: naam0_ 1797 [main] DEBUG org.hibernate.type.StringType - returning 'kost' as column: wachtwoord0_ 1813 [main] DEBUG org.hibernate.type.DateType - returning '19 augustus 2007' as column: aansluit4_0_ 1813 [main] DEBUG org.hibernate.type.IntegerType - returning '0' as column: werkniveau0_ 1813 [main] DEBUG org.hibernate.loader.Loader - result set row: 1 1813 [main] DEBUG org.hibernate.type.LongType - returning '2' as column: id 1813 [main] DEBUG org.hibernate.loader.Loader - result row: EntityKey[src.User#2] 1813 [main] DEBUG org.hibernate.loader.Loader - Initializing object from ResultSet: [src.User#2] 1813 [main] DEBUG org.hibernate.persister.entity.BasicEntityPersister - Hydrating entity: [src.User#2] 1813 [main] DEBUG org.hibernate.type.StringType - returning 'De Koster' as column: naam0_ 1813 [main] DEBUG org.hibernate.type.StringType - returning 'kost' as column: wachtwoord0_ 1813 [main] DEBUG org.hibernate.type.DateType - returning '19 augustus 2007' as column: aansluit4_0_ 1813 [main] DEBUG org.hibernate.type.IntegerType - returning '0' as column: werkniveau0_ 1813 [main] DEBUG org.hibernate.loader.Loader - done processing result set (2 rows) 1813 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - about to close ResultSet (open ResultSets: 1, globally: 1) 1813 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - about to close PreparedStatement (open PreparedStatements: 1, globally: 1) 1813 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - closing statement 1813 [main] DEBUG org.hibernate.loader.Loader - total objects hydrated: 2 1813 [main] DEBUG org.hibernate.engine.TwoPhaseLoad - resolving associations for [src.User#1] in klant :naam 1813 [main] DEBUG org.hibernate.engine.TwoPhaseLoad - done materializing entity [src.User#1] 1813 [main] DEBUG org.hibernate.engine.TwoPhaseLoad - resolving associations for [src.User#2] in klant :naam 1813 [main] DEBUG org.hibernate.engine.TwoPhaseLoad - done materializing entity [src.User#2] 1813 [main] DEBUG org.hibernate.engine.PersistenceContext - initializing non-lazy collections 1813 [main] DEBUG org.hibernate.transaction.JDBCTransaction - commit 1813 [main] DEBUG org.hibernate.impl.SessionImpl - automatically flushing session 1813 [main] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - flushing session 1813 [main] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - processing flush-time cascades 1813 [main] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - dirty checking collections 1813 [main] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Flushing entities and processing referenced collections 1813 [main] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Processing unreferenced collections 1813 [main] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Scheduling collection removes/(re)creates/updates 1813 [main] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Flushed: 0 insertions, 0 updates, 0 deletions to 2 objects 1813 [main] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections 1813 [main] DEBUG org.hibernate.pretty.Printer - listing entities: 1813 [main] DEBUG org.hibernate.pretty.Printer - src.User{aansluiting=19 augustus 2007, naam=De Koster, wachtwoord=kost, id=2, werkniveau=0} 1813 [main] DEBUG org.hibernate.pretty.Printer - src.User{aansluiting=19 augustus 2007, naam=De Koster, wachtwoord=kost, id=1, werkniveau=0} 1813 [main] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - executing flush 1813 [main] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - post flush 1813 [main] DEBUG org.hibernate.jdbc.JDBCContext - before transaction completion 1813 [main] DEBUG org.hibernate.impl.SessionImpl - before transaction completion 1813 [main] DEBUG org.hibernate.transaction.JDBCTransaction - committed JDBC Connection 1813 [main] DEBUG org.hibernate.jdbc.JDBCContext - after transaction completion 1813 [main] DEBUG org.hibernate.impl.SessionImpl - after transaction completion 1813 [main] DEBUG org.hibernate.impl.SessionImpl - closing session 1813 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - closing JDBC connection (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0) 1813 [main] DEBUG org.hibernate.connection.DriverManagerConnectionProvider - returning connection to pool, pool size: 1 1813 [main] DEBUG org.hibernate.jdbc.JDBCContext - after transaction completion 1813 [main] DEBUG org.hibernate.impl.SessionImpl - after transaction completion maak indien nodig sessionfactorg.hibernate.impl.SessionFactoryImpl@fbb7cb >>>>> user update saveOrUpdate openSessionTrans sessionfactorg.hibernate.impl.SessionFactoryImpl@fbb7cb 1813 [main] DEBUG org.hibernate.impl.SessionImpl - opened session 1813 [main] DEBUG org.hibernate.transaction.JDBCTransaction - begin 1813 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - opening JDBC connection 1813 [main] DEBUG org.hibernate.connection.DriverManagerConnectionProvider - total checked-out connections: 0 1813 [main] DEBUG org.hibernate.connection.DriverManagerConnectionProvider - using pooled JDBC connection, pool size: 0 1813 [main] DEBUG org.hibernate.transaction.JDBCTransaction - current autocommit status: false 1813 [main] DEBUG org.hibernate.event.def.AbstractSaveEventListener - transient instance of: src.Klant 1813 [main] DEBUG org.hibernate.event.def.DefaultSaveOrUpdateEventListener - saving transient instance 1813 [main] DEBUG org.hibernate.id.IncrementGenerator - fetching initial value: select max(id) from klanten 1813 [main] DEBUG org.hibernate.id.IncrementGenerator - first free id: 2 1813 [main] DEBUG org.hibernate.event.def.AbstractSaveEventListener - generated identifier: 2, using strategy: org.hibernate.id.IncrementGenerator 1813 [main] DEBUG org.hibernate.event.def.AbstractSaveEventListener - saving [src.Klant#2] 1813 [main] DEBUG org.hibernate.transaction.JDBCTransaction - commit 1813 [main] DEBUG org.hibernate.impl.SessionImpl - automatically flushing session 1813 [main] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - flushing session 1813 [main] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - processing flush-time cascades 1813 [main] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - dirty checking collections 1813 [main] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Flushing entities and processing referenced collections 1813 [main] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Processing unreferenced collections 1813 [main] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Scheduling collection removes/(re)creates/updates 1813 [main] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Flushed: 1 insertions, 0 updates, 0 deletions to 1 objects 1813 [main] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections 1813 [main] DEBUG org.hibernate.pretty.Printer - listing entities: 1813 [main] DEBUG org.hibernate.pretty.Printer - src.Klant{postnr=4578, straat=Klantenstraat, voornaam=Andre, gemeente=Winkelen, huisnr=15, achternaam=De Client, id=2} 1813 [main] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - executing flush 1813 [main] DEBUG org.hibernate.persister.entity.BasicEntityPersister - Inserting entity: [src.Klant#2] 1813 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - about to open PreparedStatement (open PreparedStatements: 0, globally: 0) 1813 [main] DEBUG org.hibernate.SQL - insert into klanten (voornaam, achternaam, straat, huisnr, postnr, gemeente, id) values (?, ?, ?, ?, ?, ?, ?) Hibernate: insert into klanten (voornaam, achternaam, straat, huisnr, postnr, gemeente, id) values (?, ?, ?, ?, ?, ?, ?) 1813 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - preparing statement 1813 [main] DEBUG org.hibernate.persister.entity.BasicEntityPersister - Dehydrating entity: [src.Klant#2] 1813 [main] DEBUG org.hibernate.type.StringType - binding 'Andre' to parameter: 1 1813 [main] DEBUG org.hibernate.type.StringType - binding 'De Client' to parameter: 2 1813 [main] DEBUG org.hibernate.type.StringType - binding 'Klantenstraat' to parameter: 3 1813 [main] DEBUG org.hibernate.type.StringType - binding '15' to parameter: 4 1813 [main] DEBUG org.hibernate.type.StringType - binding '4578' to parameter: 5 1813 [main] DEBUG org.hibernate.type.StringType - binding 'Winkelen' to parameter: 6 1813 [main] DEBUG org.hibernate.type.LongType - binding '2' to parameter: 7 1813 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - Adding to batch 1813 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - Executing batch size: 1 1813 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - about to close PreparedStatement (open PreparedStatements: 1, globally: 1) 1813 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - closing statement 1813 [main] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - post flush 1813 [main] DEBUG org.hibernate.jdbc.JDBCContext - before transaction completion 1813 [main] DEBUG org.hibernate.impl.SessionImpl - before transaction completion 1844 [main] DEBUG org.hibernate.transaction.JDBCTransaction - committed JDBC Connection 1844 [main] DEBUG org.hibernate.jdbc.JDBCContext - after transaction completion 1844 [main] DEBUG org.hibernate.impl.SessionImpl - after transaction completion 1844 [main] DEBUG org.hibernate.transaction.JDBCTransaction - rollback 1844 [main] DEBUG org.hibernate.jdbc.JDBCContext - before transaction completion 1844 [main] DEBUG org.hibernate.impl.SessionImpl - before transaction completion 1844 [main] DEBUG org.hibernate.transaction.JDBCTransaction - rolled back JDBC Connection 1844 [main] DEBUG org.hibernate.jdbc.JDBCContext - after transaction completion 1844 [main] DEBUG org.hibernate.impl.SessionImpl - after transaction completion Terugschroeven 1844 [main] DEBUG org.hibernate.impl.SessionImpl - closing session 1844 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - closing JDBC connection (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0) 1844 [main] DEBUG org.hibernate.connection.DriverManagerConnectionProvider - returning connection to pool, pool size: 1 1844 [main] DEBUG org.hibernate.jdbc.JDBCContext - after transaction completion 1844 [main] DEBUG org.hibernate.impl.SessionImpl - after transaction completion >>>>>>>>>>>>>>>>>>>>>>>>>>klant toegevoegd openSessionTrans sessionfactorg.hibernate.impl.SessionFactoryImpl@fbb7cb 1844 [main] DEBUG org.hibernate.impl.SessionImpl - opened session 1844 [main] DEBUG org.hibernate.transaction.JDBCTransaction - begin 1844 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - opening JDBC connection 1844 [main] DEBUG org.hibernate.connection.DriverManagerConnectionProvider - total checked-out connections: 0 1844 [main] DEBUG org.hibernate.connection.DriverManagerConnectionProvider - using pooled JDBC connection, pool size: 0 1844 [main] DEBUG org.hibernate.transaction.JDBCTransaction - current autocommit status: false 1844 [main] DEBUG org.hibernate.impl.SessionImpl - find: from src.Klant 1844 [main] DEBUG org.hibernate.engine.QueryParameters - named parameters: {} 1844 [main] DEBUG org.hibernate.hql.ast.QueryTranslatorImpl - parse() - HQL: from src.Klant 1860 [main] DEBUG org.hibernate.hql.AST - --- HQL AST --- -[QUERY] CommonAST: 'query' -[SELECT_FROM] CommonAST: 'SELECT_FROM' -[FROM] CommonAST: 'from' -[DOT] CommonAST: '.' +-[IDENT] CommonAST: 'src' -[IDENT] CommonAST: 'Klant' 1860 [main] DEBUG hql.parser - throwQueryException() : no errors 1860 [main] DEBUG org.hibernate.hql.antlr.HqlSqlBaseWalker - query() << begin, level = 1 1860 [main] DEBUG org.hibernate.hql.ast.FromElement - src.Klant (no alias) -> klant0_ 1860 [main] DEBUG org.hibernate.hql.antlr.HqlSqlBaseWalker - query() : finishing up... 1860 [main] DEBUG org.hibernate.hql.ast.HqlSqlWalker - Derived SELECT clause created. 1860 [main] DEBUG org.hibernate.hql.ast.JoinProcessor - Using FROM fragment [klanten klant0_] 1860 [main] DEBUG org.hibernate.hql.antlr.HqlSqlBaseWalker - query() >> end, level = 1 1860 [main] DEBUG org.hibernate.hql.AST - --- SQL AST --- -[SELECT] QueryNode: 'SELECT' querySpaces (klanten) +-[SELECT_CLAUSE] SelectClause: '{derived select clause}' | +-[SELECT_EXPR] SelectExpressionImpl: 'klant0_.id as id' {FromElement{explicit,not a collection join,classAlias=null,role=null,tableName=klanten,tableAlias=klant0_,colums={,className=src.Klant}}} | -[SQL_TOKEN] SqlFragment: 'klant0_.voornaam as voornaam1_, klant0_.achternaam as achternaam1_, klant0_.straat as straat1_, klant0_.huisnr as huisnr1_, klant0_.postnr as postnr1_, klant0_.gemeente as gemeente1_' -[FROM] FromClause: 'from' FromClause{from} -[FROM_FRAGMENT] FromElement: 'klanten klant0_' FromElement{explicit,not a collection join,classAlias=null,role=null,tableName=klanten,tableAlias=klant0_,colums={,className=src.Klant}} 1860 [main] DEBUG hql.parser - throwQueryException() : no errors 1860 [main] DEBUG org.hibernate.hql.ast.QueryTranslatorImpl - HQL: from src.Klant 1860 [main] DEBUG org.hibernate.hql.ast.QueryTranslatorImpl - SQL: select klant0_.id as id, klant0_.voornaam as voornaam1_, klant0_.achternaam as achternaam1_, klant0_.straat as straat1_, klant0_.huisnr as huisnr1_, klant0_.postnr as postnr1_, klant0_.gemeente as gemeente1_ from klanten klant0_ 1860 [main] DEBUG hql.parser - throwQueryException() : no errors 1860 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - about to open PreparedStatement (open PreparedStatements: 0, globally: 0) 1860 [main] DEBUG org.hibernate.SQL - select klant0_.id as id, klant0_.voornaam as voornaam1_, klant0_.achternaam as achternaam1_, klant0_.straat as straat1_, klant0_.huisnr as huisnr1_, klant0_.postnr as postnr1_, klant0_.gemeente as gemeente1_ from klanten klant0_ Hibernate: select klant0_.id as id, klant0_.voornaam as voornaam1_, klant0_.achternaam as achternaam1_, klant0_.straat as straat1_, klant0_.huisnr as huisnr1_, klant0_.postnr as postnr1_, klant0_.gemeente as gemeente1_ from klanten klant0_ 1860 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - preparing statement 1860 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - about to open ResultSet (open ResultSets: 0, globally: 0) 1860 [main] DEBUG org.hibernate.loader.Loader - processing result set 1860 [main] DEBUG org.hibernate.loader.Loader - result set row: 0 1860 [main] DEBUG org.hibernate.type.LongType - returning '1' as column: id 1860 [main] DEBUG org.hibernate.loader.Loader - result row: EntityKey[src.Klant#1] 1860 [main] DEBUG org.hibernate.loader.Loader - Initializing object from ResultSet: [src.Klant#1] 1860 [main] DEBUG org.hibernate.persister.entity.BasicEntityPersister - Hydrating entity: [src.Klant#1] 1860 [main] DEBUG org.hibernate.type.StringType - returning 'Andre' as column: voornaam1_ 1860 [main] DEBUG org.hibernate.type.StringType - returning 'De Client' as column: achternaam1_ 1860 [main] DEBUG org.hibernate.type.StringType - returning 'Klantenstraat' as column: straat1_ 1860 [main] DEBUG org.hibernate.type.StringType - returning '15' as column: huisnr1_ 1860 [main] DEBUG org.hibernate.type.StringType - returning '4578' as column: postnr1_ 1860 [main] DEBUG org.hibernate.type.StringType - returning 'Winkelen' as column: gemeente1_ 1860 [main] DEBUG org.hibernate.loader.Loader - result set row: 1 1860 [main] DEBUG org.hibernate.type.LongType - returning '2' as column: id 1860 [main] DEBUG org.hibernate.loader.Loader - result row: EntityKey[src.Klant#2] 1860 [main] DEBUG org.hibernate.loader.Loader - Initializing object from ResultSet: [src.Klant#2] 1860 [main] DEBUG org.hibernate.persister.entity.BasicEntityPersister - Hydrating entity: [src.Klant#2] 1860 [main] DEBUG org.hibernate.type.StringType - returning 'Andre' as column: voornaam1_ 1860 [main] DEBUG org.hibernate.type.StringType - returning 'De Client' as column: achternaam1_ 1860 [main] DEBUG org.hibernate.type.StringType - returning 'Klantenstraat' as column: straat1_ 1860 [main] DEBUG org.hibernate.type.StringType - returning '15' as column: huisnr1_ 1860 [main] DEBUG org.hibernate.type.StringType - returning '4578' as column: postnr1_ 1860 [main] DEBUG org.hibernate.type.StringType - returning 'Winkelen' as column: gemeente1_ 1860 [main] DEBUG org.hibernate.loader.Loader - done processing result set (2 rows) 1860 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - about to close ResultSet (open ResultSets: 1, globally: 1) 1860 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - about to close PreparedStatement (open PreparedStatements: 1, globally: 1) 1860 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - closing statement 1860 [main] DEBUG org.hibernate.loader.Loader - total objects hydrated: 2 1860 [main] DEBUG org.hibernate.engine.TwoPhaseLoad - resolving associations for [src.Klant#1] 1860 [main] DEBUG org.hibernate.engine.TwoPhaseLoad - done materializing entity [src.Klant#1] 1860 [main] DEBUG org.hibernate.engine.TwoPhaseLoad - resolving associations for [src.Klant#2] 1860 [main] DEBUG org.hibernate.engine.TwoPhaseLoad - done materializing entity [src.Klant#2] 1860 [main] DEBUG org.hibernate.engine.PersistenceContext - initializing non-lazy collections 1860 [main] DEBUG org.hibernate.transaction.JDBCTransaction - commit 1860 [main] DEBUG org.hibernate.impl.SessionImpl - automatically flushing session 1860 [main] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - flushing session 1860 [main] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - processing flush-time cascades 1860 [main] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - dirty checking collections 1860 [main] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Flushing entities and processing referenced collections 1860 [main] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Processing unreferenced collections 1860 [main] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Scheduling collection removes/(re)creates/updates 1860 [main] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Flushed: 0 insertions, 0 updates, 0 deletions to 2 objects 1860 [main] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections 1860 [main] DEBUG org.hibernate.pretty.Printer - listing entities: 1860 [main] DEBUG org.hibernate.pretty.Printer - src.Klant{postnr=4578, straat=Klantenstraat, voornaam=Andre, gemeente=Winkelen, huisnr=15, achternaam=De Client, id=2} 1860 [main] DEBUG org.hibernate.pretty.Printer - src.Klant{postnr=4578, straat=Klantenstraat, voornaam=Andre, gemeente=Winkelen, huisnr=15, achternaam=De Client, id=1} 1860 [main] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - executing flush 1860 [main] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - post flush 1860 [main] DEBUG org.hibernate.jdbc.JDBCContext - before transaction completion 1860 [main] DEBUG org.hibernate.impl.SessionImpl - before transaction completion 1860 [main] DEBUG org.hibernate.transaction.JDBCTransaction - committed JDBC Connection 1860 [main] DEBUG org.hibernate.jdbc.JDBCContext - after transaction completion 1860 [main] DEBUG org.hibernate.impl.SessionImpl - after transaction completion 1860 [main] DEBUG org.hibernate.impl.SessionImpl - closing session 1860 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - closing JDBC connection (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0) 1860 [main] DEBUG org.hibernate.connection.DriverManagerConnectionProvider - returning connection to pool, pool size: 1 1875 [main] DEBUG org.hibernate.jdbc.JDBCContext - after transaction completion 1875 [main] DEBUG org.hibernate.impl.SessionImpl - after transaction completion Einde main
15-08-2007 om 00:00 geschreven door de makers
14-08-2007
KlantDao.java en UserDao.java vervangen door dbDao.java
Vervangen van KlantDao.java en
UserDao.java door 1 enkel bestand : dbDao.java
1.Nieuwe code voor
Main.java
2.Code voor dbDao [Nieuwe
code voor User-KlantDao]
» Naar Menu
1. Nieuwe code
voor Main.java
--- begin Main.java ------
package src;
import java.util.Date;
public class Main {
public static void main(String[] args) {
Date now = new Date ();
/*
* User toevoegen aan de database
*/
User user = new User();
user.setNaam("De Koster");
user.setWachtwoord("kost");
user.setAansluiting(now);
dbDao dbuser = new dbDao();
dbuser.update(user);
System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>user
toegevoegd");
dbuser.findAll(User.class);
/*
* Klant toevoegen aan de database
*/
Klant klant = new Klant();
klant.setAchternaam("De Client");
klant.setVoornaam("Andre");
klant.setStraat("Klantenstraat");
klant.setHuisnr("15");
klant.setPostnr("4578");
klant.setGemeente("Winkelen");
dbDao dbklant = new dbDao();
dbklant.update(klant);
System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>klant
toegevoegd");
dbklant.findAll(Klant.class);
System.out.println("Einde main");
}
}
--- einde Main.java ------
2. Vervangen van de 2 codebestanden
userDao.java en KlantDao.java door dbDao.java te gebruiken voor klant and user
--- begin dbDao.java ------
package src;
import java.util.List;
public class dbDao extends ConstructDao {
public dbDao() {
super();
}
/*
* Een Oject toevoegen aan - wijzigen in de database.
*/
public void create(Object obj) throws DataAccessError {
super.saveOrUpdate(obj);
}
/*
* Een Oject verwijderen uit de database.
*/
public void delete(Object obj) throws DataAccessError {
super.delete(obj);
}
/**
* Zoeken met primary key.
* @param id
* @return
*/
public Object find(Long id) throws DataAccessError {
return (Object) super.find(Object.class,
id);
}
/*
* Oject toevoegen aan - of wijzigen in de database.
*/
public void update(Object obj) throws DataAccessError {
super.saveOrUpdate(obj);
}
/*
* Haal Oject op uit de database.
*/
public List findAll() throws DataAccessError{
return super.findAll(Object.class);
}
}
--- einde dbDao.java ------
14-08-2007 om 00:00 geschreven door de makers
20-07-2007
Voorbeeld HQL - sample HQL FROM (class name)
Java eclipse HQL :: mapping Database server : mysql Ophalen van databasegegevens met HQL :: Hibernate Query Language C opyright willems(c)juli 2007 Link = http://blog.seniorennet.be/pwtechniek/archief.php?ID=57
Voordeel van het gebruik van HQL: - overzichtelijke code - programma is nadien gemakkelijk aan te passen Voorbeeld HQL [sample HQL FROM (class name)] Structuur project: [-]mysqltest [-]bron + Leverancier.java + main_test.java [+][] JRE System Library [+][] xerces-2.6.2.jar [+][] ant-antlr-1.6.3.jar [+][] antlr-2.7.5H3.jar [+][] asm.jar [+][] asm-attrs.jar [+][] cglib-2.1.jar [+][] commons-collections-2.1.1.jar [+][] commons-logging-1.0.4.jar [+][] dom4j-1.6.jar [+][] ehache-1.1.jar [+][] hibernate3.jar [+][] hsqldb.jar [+][] jta.jar [+][] log4j-1.2.9.jar [+][] mysql-connector-java-3.1.6-bin.jar |-- hibernate.cfg.xml |-- Leverancier.hbm.xml |-- log4j.properties 1.Code van Leverancier.java in package bron package bron; import java.sql.ResultSet; import java.sql.SQLException; public class Leverancier{ private String firmanaam, rechtspers, straat, gemeente, telefoon, fax, GSM, email, vertegenwoordiger, vertegen_GSM, vertegen_email, tweede_naam, tweede_straat, tweede_gemeente, tweede_telefoon, tweede_GSM, beschrijving, info ; private int id, nr, postcode, tweede_nr, tweede_postcode ; public int getid(){ return id; } public void setid(int id){ this.id = id; } public String getfirmanaam(){ return firmanaam; } public void setfirmanaam(String firmanaam){ this.firmanaam = firmanaam; } public String getrechtspers(){ return rechtspers; } public void setrechtspers(String rechtspers){ this.rechtspers = rechtspers; } public String getstraat(){ return straat; } public void setstraat(String straat){ this.straat = straat; } public int getnr(){ return nr; } public void setnr(int nr){ this.nr = nr; } public int getpostcode(){ return postcode; } public void setpostcode(int postcode){ this.postcode = postcode; } public String getgemeente(){ return gemeente; } public void setgemeente(String gemeente){ this.gemeente = gemeente; } public String gettelefoon(){ return telefoon; } public void settelefoon(String telefoon){ this.telefoon = telefoon; } public String getfax(){ return fax; } public void setfax(String fax){ this.fax = fax; } public String getGSM(){ return GSM; } public void setGSM(String GSM){ this.GSM = GSM; } public String getemail(){ return email; } public void setemail(String email){ this.email = email; } public String getvertegenwoordiger(){ return vertegenwoordiger; } public void setvertegenwoordiger(String vertegenwoordiger){ this.vertegenwoordiger = vertegenwoordiger; } public String getvertegen_GSM(){ return vertegen_GSM; } public void setvertegen_GSM(String vertegen_GSM){ this.vertegen_GSM = vertegen_GSM; } public String getvertegen_email(){ return vertegen_email; } public void setvertegen_email(String vertegen_email){ this.vertegen_email = vertegen_email; } public String gettweede_naam(){ return tweede_naam; } public void settweede_naam(String tweede_naam){ this.tweede_naam = tweede_naam; } public String gettweede_straat(){ return tweede_straat; } public void settweede_straat(String tweede_straat){ this.tweede_straat = tweede_straat; } public int gettweede_nr(){ return tweede_nr; } public void settweede_nr(int tweede_nr){ this.tweede_nr = tweede_nr; } public int gettweede_postcode(){ return tweede_postcode; } public void settweede_postcode(int tweede_postcode){ this.tweede_postcode = tweede_postcode; } public String gettweede_gemeente(){ return tweede_gemeente; } public void settweede_gemeente(String tweede_gemeente){ this.tweede_gemeente = tweede_gemeente; } public String gettweede_telefoon(){ return tweede_telefoon; } public void settweede_telefoon(String tweede_telefoon){ this.tweede_telefoon = tweede_telefoon; } public String gettweede_GSM(){ return tweede_GSM; } public void settweede_GSM(String tweede_GSM){ this.tweede_GSM = tweede_GSM; } public String getbeschrijving(){ return beschrijving; } public void setbeschrijving(String beschrijving){ this.beschrijving = beschrijving; } public String getinfo(){ return info; } public void setinfo(String info){ this.info = info; } } 2.Code van main_test.java in package bron package bron; import org.hibernate.*; import org.hibernate.cfg.*; import java.util.*; /** * @author piet willems * * pwTechniek * HQL Example */ public class main_test { public static void main(String[] args) { Session session = null; try{ // lezen hibernate.cfg.xml en voorbereiding hibernate SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory(); session =sessionFactory.openSession(); // HQL : FROM class !! String hql_QUERY ="FROM Leverancier as p"; Query query = session.createQuery(hql_QUERY); for(Iterator it=query.iterate();it.hasNext();){ Leverancier row = (Leverancier) it.next(); System.out.println("Firma: " + row.getfirmanaam()); System.out.println("Straat: " + row.getstraat()); System.out.println("Gemeente: " + row.getgemeente()); System.out.println("ID: " + row.getid()); } session.close(); }catch(Exception e){ System.out.println(e.getMessage()); }finally{ } System.out.println("end"); } } 3.Code van hibernate.cfg.xml in project mysqltest <?xml version='1.0' encoding='utf-8'?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <!-- Database connection settings --> <property name="connection.driver_class">com.mysql.jdbc.Driver</property> <property name="connection.url">jdbc:mysql://localhost/mysqltest</property> <property name="connection.username">sa</property> <property name="connection.password">hqlhql</property> <!-- JDBC connection pool (use the built-in) --> <property name="connection.pool_size">1</property> <!-- Volgende lijn uit commentaar zetten om de database opnieuw te laten aanmaken --> <!--property name="hbm2ddl.auto">create</property--> <!-- SQL dialect --> <property name="dialect">org.hibernate.dialect.SQLServerDialect</property> <!-- Echo all executed SQL to stdout --> <property name="show_sql">true</property> <mapping resource="Leverancier.hbm.xml"/> </session-factory> </hibernate-configuration> 4.Code van Leverancier.hbm.xml !! Overeenkomst : - classe Leverancier met hoofdletter - tabel database : met kleine letters code : <?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd"> <hibernate-mapping> <!-- pwTechniek:: class:bron.Leverancier, tabel: leverancier" pwTechniek:: HQL -voorbeeld, project : Kantoren , mapping --> <class name="bron.Leverancier" table="leverancier"> <id name="id" column="ID" type="int" unsaved-value="null"> <generator class="increment"/> </id> <property name="firmanaam" type="string"/> <property name="straat" type="string"/> <property name="nr" type="int"/> <property name="postcode" type="int"/> <property name="gemeente" type="string"/> <property name="telefoon" type="string"/> <property name="fax" type="string"/> <property name="GSM" type="string"/> <property name="email" type="string"/> <property name="vertegenwoordiger" type="string"/> <property name="vertegen_GSM" type="string"/> <property name="vertegen_email" type="string"/> <property name="tweede_naam" type="string"/> <property name="tweede_straat" type="string"/> <property name="tweede_nr" type="int"/> <property name="tweede_postcode" type="int"/> <property name="tweede_gemeente" type="string"/> <property name="tweede_telefoon" type="string"/> <property name="tweede_GSM" type="string"/> <property name="beschrijving" type="string"/> <property name="info" type="string"/> </class> </hibernate-mapping> 5.Code log4j.properties log4j.rootLogger=DEBUG, A1 log4j.appender.A1= org.apache.log4j.ConsoleAppender log4j.appender.A1.layout= org.apache.log4j.PatternLayout log4j.appender.A1.layout.ConversionPattern= %-4r [%t] %-5p %c %x - %m%n 6.Database : Mysqltest : table : leverancier -- phpMyAdmin SQL Dump -- version 2.6.1-pl3 -- http://www.phpmyadmin.net -- -- Host: localhost -- Generatie Tijd: 21 Jul 2007 om 21:06 -- Server versie: 5.0.24 -- PHP Versie: 5.0.3 -- -- Database: `mysqltest` -- -- -------------------------------------------------------- -- -- Tabel structuur voor tabel `leverancier` -- CREATE TABLE `leverancier` ( `id` int(11) NOT NULL auto_increment, `firmanaam` varchar(30) NOT NULL, `rechtspers` varchar(6) NOT NULL, `straat` varchar(50) NOT NULL, `nr` int(11) NOT NULL, `postcode` int(11) NOT NULL, `gemeente` varchar(30) NOT NULL, `telefoon` varchar(9) NOT NULL, `fax` varchar(9) NOT NULL, `GSM` varchar(10) NOT NULL, `email` varchar(50) NOT NULL, `vertegenwoordiger` varchar(30) NOT NULL, `vertegen_GSM` varchar(10) NOT NULL, `vertegen_email` varchar(50) NOT NULL, `tweede_naam` varchar(50) NOT NULL, `tweede_straat` varchar(50) NOT NULL, `tweede_nr` int(11) NOT NULL, `tweede_postcode` int(11) NOT NULL, `tweede_gemeente` varchar(30) NOT NULL, `tweede_telefoon` varchar(9) NOT NULL, `tweede_GSM` varchar(10) NOT NULL, `beschrijving` varchar(255) NOT NULL, `info` varchar(255) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=0; -- -- Gegevens worden uitgevoerd voor tabel `leverancier` -- INSERT INTO `leverancier` VALUES (1, 'Sarcotem', 'NV', 'Industiepark', 11, 4562, 'Bontem', '4144141', '141445', '14745456', 'sarc@bottem.be', 'Gulleman', '147456458', 'sarc-gul@bottem.be', 'Torrens', 'kortebeekstraat', 14, 5584, 'Strandem', '05785245', '147569485', 'verwarmingstoestellen', 'info1'); INSERT INTO `leverancier` VALUES (2, 'ADGE', 'bvba', 'nieuwstraat', 11, 4562, 'grimstad', '4144141', '141445544', '147458154', 'mail@infotec.be', 'Debreke', '147658254', 'miel.mail@infotec.be', 'Tamin', 'torenstraat', 45, 5466, 'Bunzegem', '05765489', 'geen', 'verlichtingsarmaturen', 'info2');
20-07-2007 om 00:00 geschreven door de makers
19-07-2007
Vervolg eclipse java :: HQL - FROM :: run application
7.Eclipse : Run as java application Resultaat eclipse : 0 [main] INFO org.hibernate.cfg.Environment - Hibernate 3.0.3 0 [main] INFO org.hibernate.cfg.Environment - hibernate.properties not found 0 [main] INFO org.hibernate.cfg.Environment - using CGLIB reflection optimizer 15 [main] INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling 78 [main] INFO org.hibernate.cfg.Configuration - configuring from resource: /hibernate.cfg.xml 78 [main] INFO org.hibernate.cfg.Configuration - Configuration resource: /hibernate.cfg.xml 328 [main] DEBUG org.hibernate.util.DTDEntityResolver ..... 390 [main] DEBUG org.hibernate.util.DTDEntityResolver - http://hibernate.sourceforge.net/hibernate- mapping-2.0.dtd not found in classpath 2078 [main] INFO org.hibernate.cfg.HbmBinder - Mapping class: bron.Leverancier -> leverancier 2078 [main] DEBUG org.hibernate.cfg.HbmBinder - Mapped property: id -> ID 2093 [main] DEBUG org.hibernate.cfg.HbmBinder - Mapped property: firmanaam -> firmanaam 2093 [main] DEBUG org.hibernate.cfg.HbmBinder - Mapped property: straat -> straat 2093 [main] DEBUG org.hibernate.cfg.HbmBinder - Mapped property: nr -> nr 2093 [main] DEBUG org.hibernate.cfg.HbmBinder - Mapped property: postcode -> postcode 2093 [main] DEBUG org.hibernate.cfg.HbmBinder - Mapped property: gemeente -> gemeente 2093 [main] DEBUG org.hibernate.cfg.HbmBinder - Mapped property: telefoon -> telefoon 2093 [main] DEBUG org.hibernate.cfg.HbmBinder - Mapped property: fax -> fax 2093 [main] DEBUG org.hibernate.cfg.HbmBinder - Mapped property: GSM -> GSM 2093 [main] DEBUG org.hibernate.cfg.HbmBinder - Mapped property: email -> email 2093 [main] DEBUG org.hibernate.cfg.HbmBinder - Mapped property: vertegenwoordiger -> vertegenwoordiger 2093 [main] DEBUG org.hibernate.cfg.HbmBinder - Mapped property: vertegen_GSM -> vertegen_GSM 2093 [main] DEBUG org.hibernate.cfg.HbmBinder - Mapped property: vertegen_email -> vertegen_email 2093 [main] DEBUG org.hibernate.cfg.HbmBinder - Mapped property: tweede_naam -> tweede_naam 2093 [main] DEBUG org.hibernate.cfg.HbmBinder - Mapped property: tweede_straat -> tweede_straat 2093 [main] DEBUG org.hibernate.cfg.HbmBinder - Mapped property: tweede_nr -> tweede_nr 2093 [main] DEBUG org.hibernate.cfg.HbmBinder - Mapped property: tweede_postcode -> tweede_postcode 2093 [main] DEBUG org.hibernate.cfg.HbmBinder - Mapped property: tweede_gemeente -> tweede_gemeente 2093 [main] DEBUG org.hibernate.cfg.HbmBinder - Mapped property: tweede_telefoon -> tweede_telefoon 2093 [main] DEBUG org.hibernate.cfg.HbmBinder - Mapped property: tweede_GSM -> tweede_GSM 2093 [main] DEBUG org.hibernate.cfg.HbmBinder - Mapped property: beschrijving -> beschrijving 2093 [main] DEBUG org.hibernate.cfg.HbmBinder - Mapped property: info -> info 2093 [main] INFO org.hibernate.cfg.Configuration - Configured SessionFactory: null .... 2093 [main] INFO org.hibernate.cfg.Configuration - processing extends queue 2093 [main] INFO org.hibernate.cfg.Configuration - processing collection mappings 2093 [main] INFO org.hibernate.cfg.Configuration - processing association property references 2093 [main] INFO org.hibernate.cfg.Configuration - processing foreign key constraints 2156 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider .... 2390 [main] INFO org.hibernate.cfg.SettingsFactory - RDBMS: MySQL, version: 5.0.24a-community-nt .... 3046 [main] DEBUG org.hibernate.hql.ast.QueryTranslatorImpl - parse() - HQL: FROM bron.Leverancier as p 3062 [main] DEBUG org.hibernate.hql.AST - --- HQL AST --- -[QUERY] 'query' -[SELECT_FROM] 'SELECT_FROM' -[FROM] 'FROM' -[RANGE] 'RANGE' +-[DOT] '.' | +-[IDENT] 'bron' | -[IDENT] 'Leverancier' -[ALIAS] 'p' 3062 [main] DEBUG org.hibernate.hql.ast.ErrorCounter - throwQueryException() : no errors 3093 [main] DEBUG org.hibernate.hql.antlr.HqlSqlBaseWalker - query() << begin, level = 1 3125 [main] DEBUG org.hibernate.hql.ast.FromElement - FromClause{level=1} : bron.Leverancier (p) -> leverancie0_ 3125 [main] DEBUG org.hibernate.hql.antlr.HqlSqlBaseWalker - query() : finishing up , level = 1 3125 [main] DEBUG org.hibernate.hql.ast.HqlSqlWalker - processQuery() : ( SELECT ( FromClause{level=1} leverancier leverancie0_ ) ) 3125 [main] DEBUG org.hibernate.hql.ast.HqlSqlWalker - Derived SELECT clause created. 3125 [main] DEBUG org.hibernate.hql.ast.JoinProcessor - Using FROM fragment [leverancier leverancie0_] 3125 [main] DEBUG org.hibernate.hql.antlr.HqlSqlBaseWalker - query() >> end, level = 1 3140 [main] DEBUG org.hibernate.hql.AST - --- SQL AST --- -[SELECT] QueryNode: 'SELECT' querySpaces (leverancier) +-[SELECT_CLAUSE] SelectClause: '{derived select clause}' | -[SELECT_EXPR] SelectExpressionImpl: 'leverancie0_.ID as col_0_0_' {FromElement{explicit,not a collection join,not a fetch join,fetch non-lazy properties,classAlias=p,role=null,tableName=leverancier,tableAlias=leverancie0_,colums={,className= bron.Leverancier}}} -[FROM] FromClause: 'FROM' FromClause{level=1, fromElementCounter=1, fromElements=1, fromElementByClassAlias=[p], fromElementByTableAlias=[leverancie0_], fromElementsByPath=[], collectionJoinFromElementsByPath=[], impliedElements=[]} -[FROM_FRAGMENT] FromElement: 'leverancier leverancie0_' FromElement{explicit,not a collection join,not a fetch join,fetch non-lazy properties,classAlias=p,role=null,tableName=leverancier,tableAlias=leverancie0_,colums={,className =bron.Leverancier}} 3140 [main] DEBUG org.hibernate.hql.ast.ErrorCounter - throwQueryException() : no errors 3156 [main] DEBUG org.hibernate.hql.ast.QueryTranslatorImpl - HQL: FROM bron.Leverancier as p 3156 [main] DEBUG org.hibernate.hql.ast.QueryTranslatorImpl - SQL: select leverancie0_.ID as col_0_0_ from leverancier leverancie0_ 3156 [main] DEBUG org.hibernate.hql.ast.ErrorCounter - throwQueryException() : no errors 3156 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - about to open PreparedStatement (open PreparedStatements: 0, globally: 0) 3156 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - opening JDBC connection 3156 [main] DEBUG org.hibernate.connection.DriverManagerConnectionProvider - total checked-out connections: 0 3156 [main] DEBUG org.hibernate.connection.DriverManagerConnectionProvider - using pooled JDBC connection, pool size: 0 3156 [main] DEBUG org.hibernate.SQL - select leverancie0_.ID as col_0_0_ from leverancier leverancie0_ Hibernate: select leverancie0_.ID as col_0_0_ from leverancier leverancie0_ 3156 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - preparing statement 3156 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - about to open ResultSet (open ResultSets: 0, globally: 0) 3171 [main] DEBUG org.hibernate.impl.IteratorImpl - retrieving next results 3171 [main] DEBUG org.hibernate.type.IntegerType - returning '1' as column: col_0_0_ 3171 [main] DEBUG org.hibernate.event.def.DefaultLoadEventListener - loading entity: [bron.Leverancier#1] 3171 [main] DEBUG org.hibernate.event.def.DefaultLoadEventListener - creating new proxy for entity 3171 [main] DEBUG org.hibernate.impl.IteratorImpl - retrieving next results 3171 [main] DEBUG org.hibernate.type.IntegerType - returning '2' as column: col_0_0_ 3171 [main] DEBUG org.hibernate.event.def.DefaultLoadEventListener - loading entity: [bron.Leverancier#2] 3171 [main] DEBUG org.hibernate.event.def.DefaultLoadEventListener - creating new proxy for entity 3171 [main] DEBUG org.hibernate.impl.IteratorImpl - returning current results 3171 [main] DEBUG org.hibernate.impl.SessionImpl - initializing proxy: [bron.Leverancier#1] 3171 [main] DEBUG org.hibernate.event.def.DefaultLoadEventListener - attempting to resolve: [bron.Leverancier#1] 3171 [main] DEBUG org.hibernate.event.def.DefaultLoadEventListener - object not resolved in any cache: [bron.Leverancier#1] 3171 [main] DEBUG org.hibernate.persister.entity.BasicEntityPersister - Materializing entity: [bron.Leverancier#1] 3171 [main] DEBUG org.hibernate.loader.Loader - loading entity: [bron.Leverancier#1] 3171 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - about to open PreparedStatement (open PreparedStatements: 1, globally: 1) .... 3171 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - preparing statement 3171 [main] DEBUG org.hibernate.type.IntegerType - binding '1' to parameter: 1 3171 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - about to open ResultSet (open ResultSets: 1, globally: 1) 3171 [main] DEBUG org.hibernate.loader.Loader - processing result set 3171 [main] DEBUG org.hibernate.loader.Loader - result set row: 0 3171 [main] DEBUG org.hibernate.loader.Loader - result row: EntityKey[bron.Leverancier#1] 3171 [main] DEBUG org.hibernate.loader.Loader - Initializing object from ResultSet: [bron.Leverancier#1] 3187 [main] DEBUG org.hibernate.persister.entity.BasicEntityPersister - Hydrating entity: [bron.Leverancier#1] 3187 [main] DEBUG org.hibernate.type.StringType - returning 'Sarcotem' as column: firmanaam0_0_ 3187 [main] DEBUG org.hibernate.type.StringType - returning 'Industiepark' as column: straat0_0_ 3187 [main] DEBUG org.hibernate.type.IntegerType - returning '11' as column: nr0_0_ 3187 [main] DEBUG org.hibernate.type.IntegerType - returning '4562' as column: postcode0_0_ 3187 [main] DEBUG org.hibernate.type.StringType - returning 'Bontem' as column: gemeente0_0_ 3187 [main] DEBUG org.hibernate.type.StringType - returning '4144141' as column: telefoon0_0_ 3187 [main] DEBUG org.hibernate.type.StringType - returning '141445' as column: fax0_0_ 3187 [main] DEBUG org.hibernate.type.StringType - returning '14745456' as column: GSM0_0_ 3187 [main] DEBUG org.hibernate.type.StringType - returning 'sarc@bottem.be' as column: email0_0_ 3187 [main] DEBUG org.hibernate.type.StringType - returning 'Gulleman' as column: vertege11_0_0_ 3187 [main] DEBUG org.hibernate.type.StringType - returning '147456458' as column: vertegen12_0_0_ 3187 [main] DEBUG org.hibernate.type.StringType - returning 'sarc-gul@bottem.be' as column: vertegen13_0_0_ 3187 [main] DEBUG org.hibernate.type.StringType - returning 'Torrens' as column: tweede14_0_0_ 3187 [main] DEBUG org.hibernate.type.StringType - returning 'kortebeekstraat' as column: tweede15_0_0_ 3187 [main] DEBUG org.hibernate.type.IntegerType - returning '14' as column: tweede16_0_0_ 3187 [main] DEBUG org.hibernate.type.IntegerType - returning '5584' as column: tweede17_0_0_ 3187 [main] DEBUG org.hibernate.type.StringType - returning 'Strandem' as column: tweede18_0_0_ 3187 [main] DEBUG org.hibernate.type.StringType - returning '05785245' as column: tweede19_0_0_ 3187 [main] DEBUG org.hibernate.type.StringType - returning '147569485' as column: tweede20_0_0_ 3187 [main] DEBUG org.hibernate.type.StringType - returning 'verwarmingstoestellen' as column: beschri21_0_0_ 3187 [main] DEBUG org.hibernate.type.StringType - returning 'info1' as column: info0_0_ 3187 [main] DEBUG org.hibernate.loader.Loader - done processing result set (1 rows) 3187 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - about to close ResultSet (open ResultSets: 2, globally: 2) 3187 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - about to close PreparedStatement (open PreparedStatements: 2, globally: 2) 3187 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - closing statement 3187 [main] DEBUG org.hibernate.loader.Loader - total objects hydrated: 1 3187 [main] DEBUG org.hibernate.engine.TwoPhaseLoad - resolving associations for [bron.Leverancier#1] 3203 [main] DEBUG org.hibernate.engine.TwoPhaseLoad - done materializing entity [bron.Leverancier#1] 3203 [main] DEBUG org.hibernate.engine.PersistenceContext - initializing non-lazy collections 3203 [main] DEBUG org.hibernate.loader.Loader - done entity loadType: Sarcotem Title: Industiepark Title: Bontem ID: 1 3203 [main] DEBUG org.hibernate.impl.IteratorImpl - exhausted results 3203 [main] DEBUG org.hibernate.impl.IteratorImpl - closing iterator 3203 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - about to close ResultSet (open ResultSets: 1, globally: 1) 3203 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - about to close PreparedStatement (open PreparedStatements: 1, globally: 1) 3203 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - closing statement 3203 [main] DEBUG org.hibernate.impl.IteratorImpl - returning current results 3203 [main] DEBUG org.hibernate.impl.SessionImpl - initializing proxy: [bron.Leverancier#2] 3203 [main] DEBUG org.hibernate.event.def.DefaultLoadEventListener - attempting to resolve: [bron.Leverancier#2] 3203 [main] DEBUG org.hibernate.event.def.DefaultLoadEventListener - object not resolved in any cache: [bron.Leverancier#2] 3203 [main] DEBUG org.hibernate.persister.entity.BasicEntityPersister - Materializing entity: [bron.Leverancier#2] 3203 [main] DEBUG org.hibernate.loader.Loader - loading entity: [bron.Leverancier#2] 3203 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - about to open PreparedStatement (open PreparedStatements: 0, globally: 0) ... 3203 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - preparing statement 3203 [main] DEBUG org.hibernate.type.IntegerType - binding '2' to parameter: 1 3203 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - about to open ResultSet (open ResultSets: 0, globally: 0) 3203 [main] DEBUG org.hibernate.loader.Loader - processing result set 3203 [main] DEBUG org.hibernate.loader.Loader - result set row: 0 3203 [main] DEBUG org.hibernate.loader.Loader - result row: EntityKey[bron.Leverancier#2] 3203 [main] DEBUG org.hibernate.loader.Loader - Initializing object from ResultSet: [bron.Leverancier#2] 3203 [main] DEBUG org.hibernate.persister.entity.BasicEntityPersister - Hydrating entity: [bron.Leverancier#2] 3203 [main] DEBUG org.hibernate.type.StringType - returning 'ADGE' as column: firmanaam0_0_ 3203 [main] DEBUG org.hibernate.type.StringType - returning 'nieuwstraat' as column: straat0_0_ 3203 [main] DEBUG org.hibernate.type.IntegerType - returning '11' as column: nr0_0_ 3203 [main] DEBUG org.hibernate.type.IntegerType - returning '4562' as column: postcode0_0_ 3203 [main] DEBUG org.hibernate.type.StringType - returning 'grimstad' as column: gemeente0_0_ 3203 [main] DEBUG org.hibernate.type.StringType - returning '4144141' as column: telefoon0_0_ 3203 [main] DEBUG org.hibernate.type.StringType - returning '141445544' as column: fax0_0_ 3203 [main] DEBUG org.hibernate.type.StringType - returning '147458154' as column: GSM0_0_ 3203 [main] DEBUG org.hibernate.type.StringType - returning 'mail@infotec.be' as column: email0_0_ 3203 [main] DEBUG org.hibernate.type.StringType - returning 'Debreke' as column: vertege11_0_0_ 3203 [main] DEBUG org.hibernate.type.StringType - returning '147658254' as column: vertegen12_0_0_ 3203 [main] DEBUG org.hibernate.type.StringType - returning 'miel.mail@infotec.be' as column: vertegen13_0_0_ 3203 [main] DEBUG org.hibernate.type.StringType - returning 'Tamin' as column: tweede14_0_0_ 3203 [main] DEBUG org.hibernate.type.StringType - returning 'torenstraat' as column: tweede15_0_0_ 3203 [main] DEBUG org.hibernate.type.IntegerType - returning '45' as column: tweede16_0_0_ 3203 [main] DEBUG org.hibernate.type.IntegerType - returning '5466' as column: tweede17_0_0_ 3203 [main] DEBUG org.hibernate.type.StringType - returning 'Bunzegem' as column: tweede18_0_0_ 3203 [main] DEBUG org.hibernate.type.StringType - returning '05765489' as column: tweede19_0_0_ 3203 [main] DEBUG org.hibernate.type.StringType - returning 'geen' as column: tweede20_0_0_ 3203 [main] DEBUG org.hibernate.type.StringType - returning 'verlichtingsarmaturen' as column: beschri21_0_0_ 3203 [main] DEBUG org.hibernate.type.StringType - returning 'info2' as column: info0_0_ 3203 [main] DEBUG org.hibernate.loader.Loader - done processing result set (1 rows) 3203 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - about to close ResultSet (open ResultSets: 1, globally: 1) 3203 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - about to close PreparedStatement (open PreparedStatements: 1, globally: 1) 3203 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - closing statement 3203 [main] DEBUG org.hibernate.loader.Loader - total objects hydrated: 1 3203 [main] DEBUG org.hibernate.engine.TwoPhaseLoad - resolving associations for [bron.Leverancier#2] 3203 [main] DEBUG org.hibernate.engine.TwoPhaseLoad - done materializing entity [bron.Leverancier#2] 3203 [main] DEBUG org.hibernate.engine.PersistenceContext - initializing non-lazy collections 3203 [main] DEBUG org.hibernate.loader.Loader - done entity loadType: ADGE Title: nieuwstraat Title: grimstad ID: 2 3203 [main] DEBUG org.hibernate.impl.SessionImpl - closing session 3203 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - closing JDBC connection (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0) 3203 [main] DEBUG org.hibernate.connection.DriverManagerConnectionProvider - returning connection to pool, pool size: 1 3203 [main] DEBUG org.hibernate.jdbc.JDBCContext - after transaction completion 3203 [main] DEBUG org.hibernate.impl.SessionImpl - after transaction completion end
19-07-2007 om 00:00 geschreven door de makers
16-07-2007
java : eclipse : aanmaken object klant [class]
Eclipse :: java :: Aanmaken van
Object Klant [Class]
Eclips project - src + AdminKlanten.java +OpzoekenKlant.java +VoorraadBeheer.java +Klant.java
Aanmaken van het object klant
Code :: Klant.java :
package src;
import java.sql.ResultSet;
import java.sql.SQLException;
public class Klant {
private String id,voornaam,achternaam,straat,huisnr,postnr,gemeente;
public Klant( ResultSet rs) {
try {
id = String.valueOf(rs.getInt("id"));
achternaam = rs.getString("achternaam");
voornaam = rs.getString("voornaam");
straat = rs.getString("straat");
huisnr = rs.getString("huisnr");
postnr = rs.getString("postnr");
gemeente = rs.getString("gemeente");
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public String getID() {
return id;
}
public String getAchternaam() {
return achternaam;
}
public String getVoornaam() {
return voornaam;
}
public String getStraat() {
return straat;
}
public String getHuisnr() {
return huisnr;
}
public String getPostnr() {
return postnr;
}
public String getGemeente() {
return gemeente;
}
public void setID(String id) {
this.id = id;
}
public void setAchternaam(String achternaam) {
this.achternaam = achternaam;
}
public void setVoornaam(String voornaam) {
this.voornaam = voornaam;
}
public void setStraat(String straat) {
this.straat = straat;
}
public void setHuisnr(String huisnr) {
this.huisnr = huisnr;
}
public void setPostnr(String postnr) {
this.postnr = postnr;
}
public void setGemeente(String gemeente) {
this.gemeente = gemeente;
}
}
Aan te passen in de code :
AdminKlanten.java :
knopZoek.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent
e) {
int y =
myModel.getRowCount();
for(int a =
0; a < y; a++)
{
myModel.removeRow(0);
}
klanten.clear();
System.out.println(comboBox.getSelectedItem());
try
{
Class.forName("com.mysql.jdbc.Driver");
Connection
conn = DriverManager.getConnection ("jdbc:mysql://localhost/voorraad",
"user", "passwoord");
Statement
statement = conn.createStatement();
ResultSet rs
= statement.executeQuery("SELECT * FROM klanten WHERE "+comboBox.getSelectedItem()+"
= '"+rs01.getText()+"' LIMIT 0 , 1000");
int x;x=0;
while (rs.next())
{
record[x][0]=String.valueOf(rs.getInt("id"));
record[x][1]=Klant.chternaam");
record[x][2]=rs.getString("voornaam");
record[x][3]=rs.getString("straat");
record[x][4]=rs.getString("huisnr");
record[x][5]=rs.getString("postnr");
record[x][6]=rs.getString("gemeente");
vervangen door :
Klant klant = new Klant(rs);
klanten.add(klant);
record[x][0]=klant.getID();
record[x][1]=klant.getAchternaam();
record[x][2]=klant.getVoornaam();
record[x][3]=klant.getStraat();
record[x][4]=klant.getHuisnr();
record[x][5]=klant.getPostnr();
record[x][6]=klant.getGemeente();
myModel.addRow(record[x]);
x++;
}
conn.close();
}
catch (Exception
ex)
{
ex.getStackTrace();
}
}
}
);
panel.add(jScrollPane);
getContentPane().add(panel);
Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
setSize(new Dimension(800, 600));
setLocation((screenSize.width-800)/2,(screenSize.height-600)/2);
}
16-07-2007 om 00:00 geschreven door de makers
15-07-2007
java :: eclipse :: projectvoorbeeld mySQL
Elipse : java : MySQL query, menubar , internal frame, form klanten ,DefaultTableModel
MySQL - tabel :
-- phpMyAdmin SQL Dump
-- version 2.6.1-pl3
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generatie Tijd: 15 Jul 2007 om 11:24
-- Server versie: 5.0.24
-- PHP Versie: 5.0.3
--
-- Database: `voorraad`
--
-- --------------------------------------------------------
--
-- Tabel structuur voor tabel `klanten`
--
DROP TABLE IF EXISTS `klanten`;
CREATE TABLE `klanten` (
`id` int(11) NOT NULL auto_increment,
`geslacht` char(1) NOT NULL,
`achternaam` varchar(30) NOT NULL,
`voornaam` varchar(30) NOT NULL,
`straat` varchar(50) NOT NULL,
`huisnr` char(10) NOT NULL,
`postnr` char(4) NOT NULL,
`gemeente` varchar(30) NOT NULL,
`telefoon` varchar(12) NOT NULL,
`GSM` varchar(20) NOT NULL,
`fax` varchar(12) NOT NULL,
`email` varchar(50) NOT NULL,
`korting` int(2) NOT NULL,
`nieuws` char(1) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ;
--
-- Gegevens worden uitgevoerd voor tabel `klanten`
--
INSERT INTO `klanten` VALUES (1, 'm', 'de
gieter', 'jefke', 'mollestraat ', '362', '8640', 'vleteren', '057400017', '',
'057400017', 'degieter@gegoten.com', 0, 'n');
INSERT INTO `klanten` VALUES (2, 'm', 'de wachter', 'jozef', 'diepestraat',
'31', '8641', 'izenberge', '057425218', 'geen', '057555223', 'dewachter@wachteenbeke.be',
2, 'j');
INSERT INTO `klanten` VALUES (3, 'm', 'de gieter', 'jaak', 'mollestraat ',
'362', '8640', 'vleteren', '057425217', '448 155515', '057555222', 'bler@blobbers.com',
5, 'n');
INSERT INTO `klanten` VALUES (4, 'm', 'maresco', 'stefaan', 'diepebeekstraat ',
'36', '8640', 'vleteren', '057425217', '448 145915', '057555222', 'maresco@blobbers.com',
5, 'n');
INSERT INTO `klanten` VALUES (7, 'v', 'smolders', 'jenny', 'vennestraat', '62',
'4525', 'izenberge', '0245678925', 'geen', 'geen', 'jenny@column.com', 0, 'j');
INSERT INTO `klanten` VALUES (8, 'v', 'van santen', 'mary', 'wipstraat', '47',
'2010', 'vleteren', '0358946545', 'geen', 'geen', 'mary@strijders.com', 0, 'n');
Eclips project - src + AdminKlanten.java +OpzoekenKlant.java +VoorraadBeheer.java
1.Code :: AdminKlanten.java
package src;
import java.awt.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.table.DefaultTableModel;
import java.awt.event.*;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
public class AdminKlanten extends JInternalFrame
{
final String[] columnNames = {"id","Familienaam","Voornaam","Straat","Nr","Postnr","Gemeente"};
Object[][] record = new Object[1000][7];
java.util.List<Klant> klanten = new ArrayList<Klant> ();
final DefaultTableModel myModel = new DefaultTableModel(record,columnNames )
{
public Class getColumnClass(int c)
{
return getValueAt(0, c).getClass();
}
};
JTable table = new JTable(myModel);
JButton knp_nieuw = new JButton("Nieuw");
JButton knp_toevoegen = new JButton("Toevoegen");
JButton knp_wijzigen = new JButton("wijzigen");
JButton knp_delete = new JButton("Verwijderen");
JLabel lab01 = new JLabel("Klantnummer");
JLabel lab02 = new JLabel("Geslacht");
JLabel lab03 = new JLabel("Achternaam");
JLabel lab04 = new JLabel("Voornaam");
JLabel lab05 = new JLabel("Straat");
JLabel lab06 = new JLabel("Huisnr");
JLabel lab07 = new JLabel("Postnummer");
JLabel lab08 = new JLabel("Gemeente");
JLabel lab09 = new JLabel("Telefoon");
JLabel lab10 = new JLabel("GSM");
JLabel lab11 = new JLabel("Fax");
JLabel lab12 = new JLabel("E-post");
JLabel lab13 = new JLabel("Korting %");
JLabel lab14 = new JLabel("Niewsbrief");
JTextField rs01 = new JTextField("auto");//klnt_id :: disable!
JTextField rs02 = new JTextField("");//klnt_geslacht
JTextField rs03 = new JTextField("");//klnt_voornaam
JTextField rs04 = new JTextField("");//klnt_achternaam
JTextField rs05 = new JTextField("");//klnt_straat
JTextField rs06 = new JTextField("");//klnt_huisnr
JTextField rs07 = new JTextField("");//klnt_postnr
JTextField rs08 = new JTextField("");//klnt_gemeente
JTextField rs09 = new JTextField("");//klnt_telefoon
JTextField rs10 = new JTextField("");//klnt_gsm
JTextField rs11 = new JTextField("");//klnt_fax
JTextField rs12 = new JTextField("");//klnt_email
JTextField rs13 = new JTextField("");//klnt_korting
JTextField rs14 = new JTextField("");//klnt_nieuws
public AdminKlanten()
{
super("Klanten",true,true,true,true);
try {
} catch (Exception exception) {
exception.printStackTrace();
}
knp_nieuw.addActionListener(new KnpnieHandler());knp_nieuw.setBounds(550, 190,
140, 20);add(knp_nieuw);
knp_toevoegen.addActionListener(new KnptoeHandler());knp_toevoegen.setBounds(550,
220, 140, 20);add(knp_toevoegen);
knp_wijzigen.addActionListener(new KnpwijHandler());knp_wijzigen.setBounds(550,
250, 140, 20);add(knp_wijzigen);
knp_delete.addActionListener(new KnpdelHandler());knp_delete.setBounds(550, 280,
140, 20);add(knp_delete);
add(lab01);lab01.setForeground(Color.black);lab01.setBounds(190, 20, 150,
20);lab01.setHorizontalAlignment(SwingConstants.RIGHT);
add(lab02);lab02.setForeground(Color.black);lab02.setBounds(190, 40, 150,
20);lab02.setHorizontalAlignment(SwingConstants.RIGHT);
add(lab03);lab03.setForeground(Color.black);lab03.setBounds(190, 60, 150,
20);lab03.setHorizontalAlignment(SwingConstants.RIGHT);
add(lab04);lab04.setForeground(Color.black);lab04.setBounds(190, 80, 150,
20);lab04.setHorizontalAlignment(SwingConstants.RIGHT);
add(lab05);lab05.setForeground(Color.black);lab05.setBounds(190, 100, 150,
20);lab05.setHorizontalAlignment(SwingConstants.RIGHT);
add(lab06);lab06.setForeground(Color.black);lab06.setBounds(190, 120, 150,
20);lab06.setHorizontalAlignment(SwingConstants.RIGHT);
add(lab07);lab07.setForeground(Color.black);lab07.setBounds(190, 140, 150,
20);lab07.setHorizontalAlignment(SwingConstants.RIGHT);
add(lab08);lab08.setForeground(Color.black);lab08.setBounds(190, 160, 150,
20);lab08.setHorizontalAlignment(SwingConstants.RIGHT);
add(lab09);lab09.setForeground(Color.black);lab09.setBounds(190, 180, 150,
20);lab09.setHorizontalAlignment(SwingConstants.RIGHT);
add(lab10);lab10.setForeground(Color.black);lab10.setBounds(190, 200, 150,
20);lab10.setHorizontalAlignment(SwingConstants.RIGHT);
add(lab11);lab11.setForeground(Color.black);lab11.setBounds(190, 220, 150,
20);lab11.setHorizontalAlignment(SwingConstants.RIGHT);
add(lab12);lab12.setForeground(Color.black);lab12.setBounds(190, 240, 150,
20);lab12.setHorizontalAlignment(SwingConstants.RIGHT);
add(lab13);lab13.setForeground(Color.black);lab13.setBounds(190, 260, 150,
20);lab13.setHorizontalAlignment(SwingConstants.RIGHT);
add(lab14);lab14.setForeground(Color.black);lab14.setBounds(190, 280, 150,
20);lab14.setHorizontalAlignment(SwingConstants.RIGHT);
add(rs01);rs01.setBounds(350, 20, 150, 20);
add(rs02);rs02.setBounds(350, 40, 150, 20);
add(rs03);rs03.setBounds(350, 60, 150, 20);
add(rs04);rs04.setBounds(350, 80, 150, 20);
add(rs05);rs05.setBounds(350, 100, 150, 20);
add(rs06);rs06.setBounds(350, 120, 150, 20);
add(rs07);rs07.setBounds(350, 140, 150, 20);
add(rs08);rs08.setBounds(350, 160, 150, 20);
add(rs09);rs09.setBounds(350, 180, 150, 20);
add(rs10);rs10.setBounds(350, 200, 150, 20);
add(rs11);rs11.setBounds(350, 220, 150, 20);
add(rs12);rs12.setBounds(350, 240, 150, 20);
add(rs13);rs13.setBounds(350, 260, 150, 20);
add(rs14);rs14.setBounds(350, 280, 150, 20);
JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
vulTabel();
table.setSurrendersFocusOnKeystroke(true);
table.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
class pwLeesToets extends KeyAdapter{
public void keyReleased(KeyEvent e)
{
int key = e.getKeyCode();
if (( key == 13)||(key == 10))
{
int r = table.getSelectedRow();
rs03.setText(table.getValueAt(r,1).toString());//achternaam
rs04.setText(table.getValueAt(r,2).toString());//voornaam
rs05.setText(table.getValueAt(r,3).toString());//straat table edit
rs06.setText(table.getValueAt(r,4).toString());//huisnr table edit
rs07.setText(table.getValueAt(r,5).toString());//postnr table edit
rs08.setText(table.getValueAt(r,6).toString());//gemeente table edit
//table.nextFocus();
}
}
}
table.addKeyListener(new pwLeesToets());
table.addMouseListener( new MouseAdapter()
{
public void mousePressed(MouseEvent e)
{
int r = table.rowAtPoint(e.getPoint());
String s = table.getValueAt(r,0).toString();
int i01 = Integer.parseInt(s);// bij delete veranderen listitem n recorditem!
actieTabelselectie(i01);
}
});
JScrollPane jScrollPane = new JScrollPane();
jScrollPane.setViewportView(table);
Font font01 = new Font("Arial", Font.BOLD, 12);
Font font02 = new Font("Arial", Font.BOLD, 18);
//Font font03 = new Font("Arial", Font.BOLD, 14);
JLabel lab01 = new JLabel("Criteria");
JLabel lab02 = new JLabel("Zoekitem");
JLabel lab03 = new JLabel("Administratie Klanten");
add(lab01);lab01.setFont(font02);lab01.setForeground(Color.GRAY);lab01.setBounds(-20,
360, 100, 20);lab01.setHorizontalAlignment(SwingConstants.RIGHT);
add(lab02);lab02.setFont(font02);lab02.setForeground(Color.GRAY);lab02.setBounds(190,
360, 150, 20);lab02.setHorizontalAlignment(SwingConstants.RIGHT);
add(lab03);lab03.setFont(font02);lab03.setForeground(Color.darkGray);lab03.setBounds(-45,
15, 250, 30);lab03.setHorizontalAlignment(SwingConstants.RIGHT);
final JTextField rs01 = new JTextField("");//zoek item
add(rs01);rs01.setBounds(350, 360, 150, 20);rs01.setFont(font01);
JButton knopZoek = new JButton("Zoek");
knopZoek.setBounds(550, 360, 140, 20);
knopZoek.setFont(font01);
add(knopZoek);
final JComboBox comboBox = new JComboBox();
comboBox.setName("JComboBox");
comboBox.setBounds(90,360,150,20);
comboBox.setPreferredSize(new java.awt.Dimension(100,22));
comboBox.addItem("");
comboBox.addItem("Id");
comboBox.addItem("achternaam");
comboBox.addItem("Voornaam");
comboBox.addItem("Straat");
comboBox.addItem("Huisnummer");
comboBox.addItem("Postnummer");
comboBox.addItem("Gemeente");
comboBox.setFont(font01);
add(comboBox);
for(int x = 0 ; x < 26 ; x++)
{
panel.add(new JLabel(" "));
}
knopZoek.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
int y = myModel.getRowCount();
for(int a = 0; a < y; a++)
{
myModel.removeRow(0);
}
System.out.println(comboBox.getSelectedItem());
try
{
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection ("jdbc:mysql://localhost/voorraad",
"user", "passwoord");
Statement statement = conn.createStatement();
ResultSet rs = statement.executeQuery("SELECT * FROM klanten WHERE "+comboBox.getSelectedItem()+"
= '"+rs01.getText()+"' LIMIT 0 , 1000");
int x;x=0;
while (rs.next()) {
record[x][0]=String.valueOf(rs.getInt("id"));
record[x][1]=rs.getString("achternaam");
record[x][2]=rs.getString("voornaam");
record[x][3]=rs.getString("straat");
record[x][4]=rs.getString("huisnr");
record[x][5]=rs.getString("postnr");
record[x][6]=rs.getString("gemeente");
myModel.addRow(record[x]);
x++;
}
conn.close();
}
catch (Exception ex)
{
ex.getStackTrace();
}
}
}
);
panel.add(jScrollPane);
getContentPane().add(panel);
Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
setSize(new Dimension(800, 600));
setLocation((screenSize.width-800)/2,(screenSize.height-600)/2);
}
public void actieTabelselectie(int selectie){
try
{
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection ("jdbc:mysql://localhost/voorraad",
"user", "passwoord");
Statement statement = conn.createStatement();
ResultSet rs = statement.executeQuery("SELECT * FROM klanten WHERE id="+(selectie));
while (rs.next()) {
rs01.setText(rs.getString("id"));//omzetten naar string
rs02.setText(rs.getString("geslacht"));
rs03.setText(rs.getString("achternaam"));
rs04.setText(rs.getString("voornaam"));
rs05.setText(rs.getString("straat"));
rs06.setText(rs.getString("huisnr"));
rs07.setText(rs.getString("postnr"));
rs08.setText(rs.getString("gemeente"));
rs09.setText(rs.getString("telefoon"));
rs10.setText(rs.getString("GSM"));
rs11.setText(rs.getString("fax"));
rs10.setText(rs.getString("email"));
rs13.setText(rs.getString("korting"));
rs14.setText(rs.getString("nieuws"));
rs01.disable();
}
conn.close();
}
catch (Exception ex)
{
ex.getStackTrace();
}
}
@SuppressWarnings("test")
public void vulTabel(){
int y = myModel.getRowCount();
for(int a = 0; a < y; a++)
{
myModel.removeRow(0);
}
try
{
System.out.println("start");
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection ("jdbc:mysql://localhost/voorraad",
"user", "passwoord");
Statement statement = conn.createStatement();
ResultSet rs = statement.executeQuery("SELECT * FROM `klanten`LIMIT 0 , 1000");
int x;x=0;
while (rs.next()) {
record[x][0]=String.valueOf(rs.getInt("id"));
record[x][1]=rs.getString("achternaam");
record[x][2]=rs.getString("voornaam");
record[x][3]=rs.getString("straat");
record[x][4]=rs.getString("huisnr");
record[x][5]=rs.getString("postnr");
record[x][6]=rs.getString("gemeente");
myModel.addRow(record[x]);
x++;
}
conn.close();
}
catch (Exception ex)
{
ex.getStackTrace();
}
}
public void nieuwKlantenForm(){
rs01.setText("Auto");
rs02.setText("");
rs03.setText("");
rs04.setText("");
rs05.setText("");
rs06.setText("");
rs07.setText("");
rs08.setText("");
rs09.setText("");
rs10.setText("");
rs11.setText("");
rs10.setText("");
rs13.setText("");
rs14.setText("");
rs01.disable();
}
class KnpnieHandler implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
try
{
nieuwKlantenForm();
}
catch (Exception ex)
{
ex.getStackTrace();
}
System.out.println("nieuw");
knp_delete.setEnabled( false );
knp_wijzigen.setEnabled( false );
}
}
class KnptoeHandler implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
try
{
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection ("jdbc:mysql://localhost/voorraad",
"user", "passwoord");
Statement statement = conn.createStatement();
String s = rs13.getText();
int i13;
if (s == "") {i13 = 0;} else {i13 = Integer.parseInt(s);}
statement.executeUpdate("INSERT INTO klanten ( id , geslacht , achternaam ,
voornaam , straat , huisnr , postnr , gemeente , telefoon , GSM , fax , email ,
korting , nieuws ) VALUES (0, '"+rs02.getText()+"', '"+rs03.getText()+"',
'"+rs04.getText()+"', '"+rs05.getText()+"', '"+rs06.getText()+"',
'"+rs07.getText()+"', '"+rs08.getText()+"', '"+rs09.getText()+"',
'"+rs10.getText()+"', '"+rs11.getText()+"', '"+rs12.getText()+"', "+i13+",
'"+rs14.getText()+"')");
conn.close();
}
catch (Exception ex)
{
ex.getStackTrace();
System.out.println(ex);
}
System.out.println("INSERT"+rs13.getText());
vulTabel();
knp_delete.setEnabled(true);
knp_wijzigen.setEnabled(true);
}
}
class KnpwijHandler implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
try
{
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection ("jdbc:mysql://localhost/voorraad",
"user", "passwoord");
Statement statement = conn.createStatement();
String s = rs01.getText();
int i01 = Integer.parseInt(s);
System.out.println(i01);
System.out.println(rs02.getText());
statement.executeUpdate("UPDATE klanten SET geslacht =
'"+rs02.getText()+"',achternaam = '"+rs03.getText()+"',voornaam =
'"+rs04.getText()+"',straat = '"+rs05.getText()+"',huisnr =
'"+rs06.getText()+"',postnr = '"+rs07.getText()+"',gemeente =
'"+rs08.getText()+"',telefoon = '"+rs09.getText()+"',GSM =
'"+rs10.getText()+"',fax = '"+rs11.getText()+"',email =
'"+rs12.getText()+"',korting = '"+rs13.getText()+"',nieuws =
'"+rs14.getText()+"' WHERE id = "+ i01 +" LIMIT 1");
conn.close();
}
catch (Exception ex)
{
ex.getStackTrace();
}
System.out.println("vullen");
vulTabel();
}
}
class KnpdelHandler implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
try
{
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection ("jdbc:mysql://localhost/voorraad",
"user", "passwoord");
Statement statement = conn.createStatement();
String s = rs01.getText();
int i01 = Integer.parseInt(s);
statement.executeUpdate("DELETE FROM klanten WHERE id = "+i01);
System.out.println(i01);
conn.close();
}
catch (Exception ex)
{
ex.getStackTrace();
}
System.out.println("delete");
vulTabel();
nieuwKlantenForm();
}
}
public static void main(String args[])
{
new AdminKlanten().setVisible(true);
}
}
2.Code OpzoekenKlant.java
package src;
import javax.swing.*;
import java.awt.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.swing.BoxLayout;
import javax.swing.JComboBox;
import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.table.DefaultTableModel;
import javax.swing.event.*;
import java.awt.event.*;//import org.eclipse.swt.SWT;
//import org.eclipse.swt.widgets.Listener;
public class OpzoekenKlant extends JInternalFrame
{
public OpzoekenKlant()
{
super("Klant Opzoeken",true,true,true,true);
try {
//setDefaultCloseOperation(EXIT_ON_CLOSE);
//jbInit();
} catch (Exception exception) {
exception.printStackTrace();
}
JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
final String[] columnNames = {"id","Familienaam","Voornaam","Straat","Nr","Postnr","Gemeente"};
final Object[][] record= new Object[1000][7];
try
{
System.out.println("start");
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection ("jdbc:mysql://localhost/voorraad",
"user", "passwoord");
Statement statement = conn.createStatement();
//ResultSet rs = statement.executeQuery("SELECT 'id','achternaam','voornaam','straat`,'huisnr','postnr'
FROM 'klanten' WHERE 'gemeente' = 'vleteren' LIMIT 0 , 30");
ResultSet rs = statement.executeQuery("SELECT * FROM `klanten`LIMIT 0 , 30");
int x;x=0;
while (rs.next()) {
record[x][0]=String.valueOf(rs.getInt("id"));
record[x][1]=rs.getString("achternaam");
record[x][2]=rs.getString("voornaam");
record[x][3]=rs.getString("straat");
record[x][4]=rs.getString("huisnr");
record[x][5]=rs.getString("postnr");
record[x][6]=rs.getString("gemeente");
x++;
}
conn.close();
}
catch (Exception ex)
{
ex.getStackTrace();
}
final DefaultTableModel myModel = new DefaultTableModel(record,columnNames )
{
//Gezien er geen foutenroutine voorzien is in dit voorbeeld zal de code hier vastlopen
//indien er geen database "voorraad" en tabel "klanten" bestaat
public Class getColumnClass(int c)
{
return getValueAt(0, c).getClass();
}
};
final JTable table = new JTable(myModel);
table.setSurrendersFocusOnKeystroke(true);
table.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
JScrollPane jScrollPane = new JScrollPane();
jScrollPane.setViewportView(table);
Font font01 = new Font("Arial", Font.BOLD, 18);
Font font02 = new Font("Arial", Font.BOLD, 24);
JLabel lab01 = new JLabel("Criteria");
JLabel lab02 = new JLabel("Zoekitem");
JLabel lab03 = new JLabel("Info Klant opzoeken");
add(lab01);lab01.setFont(font01);lab01.setForeground(Color.blue);lab01.setBounds(18,
60, 100, 20);lab01.setHorizontalAlignment(SwingConstants.RIGHT);
add(lab02);lab02.setFont(font01);lab02.setForeground(Color.blue);lab02.setBounds(200,
60, 150, 20);lab02.setHorizontalAlignment(SwingConstants.RIGHT);
add(lab03);lab03.setFont(font02);lab03.setForeground(Color.darkGray);lab03.setBounds(36,
20, 250, 30);lab03.setHorizontalAlignment(SwingConstants.RIGHT);
final JTextField rs01 = new JTextField("");//zoek item
add(rs01);rs01.setBounds(270, 85, 150, 22);rs01.setFont(font01);
JButton knopZoek = new JButton("Zoek");
knopZoek.setBounds(440, 62, 80, 44);
knopZoek.setFont(font01);
add(knopZoek);
final JComboBox comboBox = new JComboBox();
comboBox.setName("JComboBox");
comboBox.setBounds(55,85,150,22);
comboBox.setPreferredSize(new java.awt.Dimension(100,22));
comboBox.addItem("");
comboBox.addItem("Id");
comboBox.addItem("achternaam");
comboBox.addItem("Voornaam");
comboBox.addItem("Straat");
comboBox.addItem("Huisnummer");
comboBox.addItem("Postnummer");
comboBox.addItem("Gemeente");
comboBox.setFont(font01);
add(comboBox);
for(int x = 0 ; x < 10 ; x++)
{
panel.add(new JLabel(" "));
}
knopZoek.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
int y = myModel.getRowCount();
for(int a = 0; a < y; a++)
{
myModel.removeRow(0);
}
String[] achter; achter = new String[7];
System.out.println(comboBox.getSelectedItem());
try
{
System.out.println("start");
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection ("jdbc:mysql://localhost/voorraad",
"user", "password");
Statement statement = conn.createStatement();
//ResultSet rs = statement.executeQuery("SELECT 'id','achternaam','voornaam','straat`,'huisnr','postnr'
FROM 'klanten' WHERE 'gemeente' = 'vleteren' LIMIT 0 , 30");
ResultSet rs = statement.executeQuery("SELECT * FROM klanten WHERE "+comboBox.getSelectedItem()+"
= '"+rs01.getText()+"' LIMIT 0 , 1000");
int x;x=0;
while (rs.next()) {
record[x][0]=String.valueOf(rs.getInt("id"));
record[x][1]=rs.getString("achternaam");
record[x][2]=rs.getString("voornaam");
record[x][3]=rs.getString("straat");
record[x][4]=rs.getString("huisnr");
record[x][5]=rs.getString("postnr");
record[x][6]=rs.getString("gemeente");
myModel.addRow(record[x]);
x++;
}
conn.close();
}
catch (Exception ex)
{
ex.getStackTrace();
}
}
}
);
panel.add(jScrollPane);
getContentPane().add(panel);
Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
setSize(new Dimension(800, 600));
setLocation((screenSize.width-800)/2,(screenSize.height-600)/2);
}
public void knopZoekActie(String val, Object crit, DefaultTableModel dtm){
Object[][] record= new Object[1000][7];
try
{
System.out.println("start");
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection ("jdbc:mysql://localhost/voorraad",
"user", "password");
Statement statement = conn.createStatement();
//ResultSet rs = statement.executeQuery("SELECT 'id','achternaam','voornaam','straat`,'huisnr','postnr'
FROM 'klanten' WHERE 'gemeente' = 'vleteren' LIMIT 0 , 30");
ResultSet rs = statement.executeQuery("SELECT * FROM `klanten`LIMIT 0 , 30");
int x;x=0;int y;y=0;
while (rs.next()) {
record[x][0]=String.valueOf(rs.getInt("id"));
record[x][1]=rs.getString("achternaam");
record[x][2]=rs.getString("voornaam");
record[x][3]=rs.getString("straat");
record[x][4]=rs.getString("huisnr");
record[x][5]=rs.getString("postnr");
record[x][6]=rs.getString("gemeente");
x++;
}
conn.close();
for (y=0;y<x;y++){dtm.addRow(record);}
}
catch (Exception ex)
{
ex.getStackTrace();
}
}
public static void main(String args[])
{
new OpzoekenKlant().setVisible(true);
}
}
3.Code VoorraadBeheer.java
package src; import javax.swing.JDesktopPane; import javax.swing.JMenu; import javax.swing.JMenuItem; import javax.swing.JMenuBar; import javax.swing.JFrame; import javax.swing.KeyStroke; import java.awt.event.*; import java.awt.*; public class VoorraadBeheer extends JFrame implements ActionListener { JDesktopPane desktop; public VoorraadBeheer() { super("Voorraadbeheer"); //50 pixels van rand scherm int inset = 50; Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); setBounds(inset, inset, screenSize.width - inset*2, screenSize.height - inset*2); desktop = new JDesktopPane(); //a specialized layered pane setContentPane(desktop); setJMenuBar(createMenuBar()); desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE); } protected JMenuBar createMenuBar() { JMenuBar menuBar = new JMenuBar(); JMenu menu = new JMenu("Administratie"); menu.setMnemonic(KeyEvent.VK_A); menuBar.add(menu); JMenuItem menuItem01 = new JMenuItem("Producten"); menuItem01.setMnemonic(KeyEvent.VK_P); menuItem01.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, ActionEvent.ALT_MASK)); menuItem01.setActionCommand("adminpro"); menuItem01.addActionListener(this); menu.add(menuItem01); JMenuItem menuItem02 = new JMenuItem("Klanten"); menuItem02.setMnemonic(KeyEvent.VK_K); menuItem02.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_K, ActionEvent.ALT_MASK)); menuItem02.setActionCommand("adminkla"); menuItem02.addActionListener(this); menu.add(menuItem02); JMenuItem menuItem03 = new JMenuItem("Leveranciers"); menuItem03.setMnemonic(KeyEvent.VK_L); menuItem03.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_L, ActionEvent.ALT_MASK)); menuItem03.setActionCommand("adminlev"); menuItem03.addActionListener(this); menu.add(menuItem03); JMenuItem menuItem04 = new JMenuItem("Klant opzoeken"); menuItem04.setMnemonic(KeyEvent.VK_A); menuItem04.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, ActionEvent.ALT_MASK)); menuItem04.setActionCommand("adminzoek"); menuItem04.addActionListener(this); menu.add(menuItem04); JMenuItem menuItem05 = new JMenuItem("Printbeheer"); menuItem05.setMnemonic(KeyEvent.VK_P); menuItem05.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, ActionEvent.ALT_MASK)); menuItem05.setActionCommand("adminprint"); menuItem05.addActionListener(this); menu.add(menuItem05); JMenu menu10 = new JMenu("Voorraad"); menu.setMnemonic(KeyEvent.VK_V); menuBar.add(menu10); JMenuItem menuItem11 = new JMenuItem("Producten IN"); menuItem11.setMnemonic(KeyEvent.VK_I); menuItem11.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_I, ActionEvent.ALT_MASK)); menuItem11.setActionCommand("Prodin"); menuItem11.addActionListener(this); menu10.add(menuItem11); JMenuItem menuItem12 = new JMenuItem("Producten UIT"); menuItem12.setMnemonic(KeyEvent.VK_U); menuItem12.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_U, ActionEvent.ALT_MASK)); menuItem12.setActionCommand("produit"); menuItem12.addActionListener(this); menu10.add(menuItem12); JMenu menu20 = new JMenu("Fakturatie"); menu.setMnemonic(KeyEvent.VK_F); menuBar.add(menu20); JMenuItem menuItem21 = new JMenuItem("Kostprijs"); menuItem21.setMnemonic(KeyEvent.VK_K); menuItem21.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_K, ActionEvent.ALT_MASK)); menuItem21.setActionCommand("kost"); menuItem21.addActionListener(this); menu20.add(menuItem21); JMenuItem menuItem22 = new JMenuItem("Rekening"); menuItem22.setMnemonic(KeyEvent.VK_R); menuItem22.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, ActionEvent.ALT_MASK)); menuItem22.setActionCommand("rek"); menuItem22.addActionListener(this); menu20.add(menuItem22); JMenu menu50 = new JMenu("Systeem"); menu.setMnemonic(KeyEvent.VK_S); menuBar.add(menu50); JMenuItem menuItem51 = new JMenuItem("Quit"); menuItem51.setMnemonic(KeyEvent.VK_Q); menuItem51.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, ActionEvent.ALT_MASK)); menuItem51.setActionCommand("quit"); menuItem51.addActionListener(this); menu50.add(menuItem51); return menuBar; } public void actionPerformed(ActionEvent e) { if ("adminpro".equals(e.getActionCommand())) { //new maakProductAdmin(); } else if ("adminkla".equals(e.getActionCommand())) { maakKlantenAdmin(); } else if ("adminlev".equals(e.getActionCommand())) { maakLeveranciersAdmin(); } else if ("adminzoek".equals(e.getActionCommand())) { maakKlantOpzoeken(); } else { //quit quit(); } } protected void maakProductAdmin() { //AdminProducten frame01 = new AdminProducten(); // frame01.setVisible(true); //necessary as of 1.3 // desktop.add(frame01); // try { // frame01.setSelected(true); // } catch (java.beans.PropertyVetoException e) {} } protected void maakKlantenAdmin() { AdminKlanten frame02 = new AdminKlanten(); frame02.setVisible(true); desktop.add(frame02); try { frame02.setSelected(true); } catch (java.beans.PropertyVetoException e) {} } protected void maakLeveranciersAdmin() { //AdminLeveranciers frame03 = new AdminLeveranciers(); //frame03.setVisible(true); //desktop.add(frame03); //try { // frame03.setSelected(true); //} catch (java.beans.PropertyVetoException e) {} } protected void maakKlantOpzoeken() { OpzoekenKlant frame04 = new OpzoekenKlant(); frame04.setVisible(true); desktop.add(frame04); try { frame04.setSelected(true); } catch (java.beans.PropertyVetoException e) {} } //Beêindig toepessing. protected void quit() { System.exit(0); } /** * Maak hoofdraam */ private static void createAndShowGUI() { JFrame.setDefaultLookAndFeelDecorated(true); VoorraadBeheer frame = new VoorraadBeheer(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } public static void main(String[] args) { javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { createAndShowGUI(); } }); } }
Run
VoorraadBeheer.java als
java application
dit project is slechts een basis voorbeeld
gezien het de uiteindelijke bedoeling is om met hibernate 3 te werken.
De volgende stap in dit voolbeeld die we
volgen is : het object klant maken Ook is het aan te raden om in een definitief
project met meer duidelijke benamingen te weken bvb ipv lab01 » labelKlantID te gebruiken
enz...
zie : Aanmaken object klant : Klant;java
15-07-2007 om 00:00 geschreven door de makers
01-07-2007
MDI
MDI :: auto op perslucht / 100 km per uur , opladen na 250 km [Sterkste motor : 130 km/u]
Franse uitvinding :: productie voorzien voor volgend jaar onder belgische licensie.
Extra :: slechts opladen na 1000 km indien ook benzine wordt gebruikt :: 1 l per 100 km
Geschatte kostprijs van deze wagen (grootte = mercedes A-klasse) : 4000 euro
Nu even iets over een man die echt wel weet hoe hij reclame moet maken voor de VLD zonder zich te schamen
Het Franstalige Le Soir Magazine zet in haar editie van donderdag de
ministeriële dienstwagens op een rij. De nieuwe aanwinst van Marc
Verwilghen, minister van Energie nota bene , blijkt een van de minst zuinige en veruit de meest vervuilende . Bovendien is het een dure wagen. Bedankt belastingbetalers!.
O zoete irronie , als ik mij niet vergis is hij ook één van de mannen die voorstellen
om alle wagens ouder dan 1995 uit omloop te nemen wegens te vervuilend. Over "verwaand zijn" gesproken.
Ik dank nog steeds Van den Brande op mijn blote knieen die verhinderde dat deze man kon overstappen naar Europa.
01-07-2007 om 22:41 geschreven door de makers
30-06-2007
Eclipse - Mysql - MS sql-server - Apach server
Gratis MySQL database - serve r
Download Mysql server ::
MySQL
5.0 downloads
Indien je niet wil inloggen klik :
» No thanks, just take me to the downloads!
onderaan het formulier.
Hulpprogramma's voor Mysql-server voor het aanmaken en onderhouden van databases en tabellen
phpMyAdmin
Sources mirror 1
Om dit programma te gebruiken moet je wel
een server op je pc geinstalleerd hebben
Ideaal hiervoor is Apache 2.0. De
installatieprogramma van apache werkt zeer goed en de server kan
onmiddellijk na de installatie getest worden. Je dient deze server ook
te configureren voor php.
Download php :
klik hier
Installatie php en aanpassing apache
configure file "httpd.conf "
Installatie van php4 -
php5
Info
Deze installatie werd getest op winXP en
Win98 op Localhost [Apach Group].(map aangemaakt bij de installatie van
de Apache-server. in program files.
De installatie verliep vlot en de programma's draaien goed.
Neem vooraf een copie van de bestanden
die je gaat veranderen en plaats deze op een afzonderlijke plaats zodat
je wanneer het fout gaat niet alles opnieuw moet installeren.
Installeren
Het zipbestand uitpakken naar map [Apach
Group]
Verkort voor de gemakkelijkheid de
mapnaam [php-4.3.4-Win32] in [php] na het uitpakken.
In de map php vind je het bestand
php.ini-dist .Wijzig de naam hiervan in php.ini en
copieer het naar de map C:Windows .
Copieer tevens de twee dll-bastanden
Msvcrt.dll en php4ts.dll naar C:WindowsSystem
Om de apacheserver te configureren
voor php brengen we de volgende veranderingen aan in httpd.conf
[Start] > [Programmas]
> [Apache HTTPserver] > [Configure] > [Edit httpd.conf]
Of ga direct
naar het bestand httpd.conf in
C:ProgramFiles Apach
GroupApache2Conf
Open het bestand en ga naar
regel 320
verander : DirectoryIndex
index.html index.html.var
in : DirectoryIndex index.html index.php
Voeg geheel onderaan het bestand
devolgende code toe: voor
php4:
LoadModule php4_module
C:ProgramFiles Apach
Group phpsapiphp4apache2.dll
AddType application/x-httpd-php .php
voor php5:
LoadModule php5_module " C:/ProgramFiles/
Apach Group /php/php5apache2.dll"
AddType application/x-httpd-php .php
# configuratie van het pad naar php.ini
PHPIniDir "C:/windows" (Tenzij je dit bestand ergens
anders hebt ondergebracht)
Indien je mysql hebt
geinstalleerd zal je voor het gebruik hiervan door php5 de
volgende veranderingen moeten doorvoeren.
zoek [extension=php_mysql.dll] op in php.ini
..
...
;extension=php_mhash.dll
;extension=php_mime_magic.dll
;extension=php_ming.dll
;extension=php_mssql.dll
;extension=php_msql.dll
;extension=php_mysql.dll
;extension=php_oci8.dll
;extension=php_openssl.dll
...
..
voor mysql :
verwijder de puntkomma die zich voor de configuratie voor mysql
bevindt
..
extension=php_mysql.dll
..
zodat deze geactiveerd wordt bij het starten.
Wanneer je nu de apache server herstart krijg je de foutmelding
:
..
Unable to load dynamic library php_mysql.dll
kan ./php_mysql.dll niet vinden
..
om dit te voorkomen dien je deze bibliotheek te copieêren naar
de basismap /php
zoek nadien [extention_dir] op in php.ini en wijzig
extension_dir = "./"
in
extension_dir = "c:php"
of
extension_dir = "D:Apachephp"
of
extension_dir = " C:ProgramFiles
Apach Groupphp"
afhankelijk van waar je php hebt geinstalleerd.
uiteindelijk dien je nog het bestand libmysql.dll te copieêren
naar C:/windows/system32
nu zou de php-code contact moeten kunnen leggen met de
mysql-server.
Sla het bestand op en sluit het
af.
Dubbelklik in de sys-tray het apache
icoon.
Stop the server (Wacht tot indicator
verandert van groen naar rood) en start hem opnieuw[zodat hij de
nieuwe configuratie kan impementeren]
Maak met het kladblok een testpagina
bvb:
test.php
<?php
echo "Lang leve php en apache. Datum : ";
$today = getdate();
$month = $today['month'];
$day = $today['mday'];
$year = $today['year'];
echo $day," , ",$month," ", $year;
?>
Bewaar dit bestand en plaats het in
de bestandenmap met de webbestanden :C:pwIntraNetwww > test.php
Start de webbrowser op adres
Localhost of 127.0.0.1 en klik het bestand dat je net hebt
aangemaakt:test.php.
Wanneer de de huidige datum
wordt weergegeven is php goed geînstalleerd zie je echter
dezelfde code als hierboven dan zit er ergens een fout in de
configuratie.Zorg ervoor het testbestand wel degelijk de
extentie .php meeheeft.
Noot: Wanneer je een andere map wenst te
gebruiken voor het onderbrengen van uw html-php code dan dien je deze
nieuwe plaats ook te configureren in de
httpd.conf - file
Wanneer het bestand httpd.conf
geopend is zoek je regel 228.
Verander :
DocumentRoot "C:/Program Files/Apache Group/Apache2/htdocs"
in : DocumentRoot "C:/pwIntraNet/www"
zoek nadien regel 253
Verander : <Directory "C:/Program
Files/Apache Group/Apache2/htdocs">
in : <Directory "C:/pwIntraNet/www">
Na elke verandering die je aanbrengt in
de configuratiefile http.config dien je de apache server te stoppen en
nadien weer op te starten opdat de verandering effect zou hebben. Bij
het invoeren van verkeerde code zal de server niet meer starten daarom
is het best dat je een copie neemt van het bestand vooraleer je start
met veranderen.
Voorbeeld van een httpd.conf file :
klik hier
Microsoft
Gratis Microsoft SQL
Server 2005 Express Edition
SQL Server 2005 Express Edition is
free to download, has no time limits, and is freely redistributable
(with registration)
30-06-2007 om 00:00 geschreven door de makers
29-06-2007
Voorbeeld httpd.conf voor apache server 2.0 met php ondersteuning
Gezien dit [php] programma sommige tekens in deze code niet correct weergeeft gelieve volgende link te volgen:klik hier Dit is een voorbeeld voor php4_module, en de map waarin de html-bestanden zijn ondergebracht is C:intranet ... ipv C:Program Files... enz Voorbeeld van verkeerde weergave : frontslash ontbreekt LoadModule php5_module "C:Program FilesApache Groupphpphp5apache2.dll" AddType application/x-httpd-php .php PHPIniDir "C:Program FilesApache Groupphp"
29-06-2007 om 00:00 geschreven door de makers
>