Michael Duller
michael.duller_at_inf.ethz.ch
Ionut Subasu
ionut.subasu_at_inf.ethz.ch
Prerequisits:
Relational DBMS (eg. MySQL Server/Postgres)
Latest Java SE SDK
Eclipse 3.3 / Netbeans 6.1 IDE
Tomcat Server
Primary supported platform is Windows
Mac OS X, Linux, FreeBSD,… users: use at your
own risk, some pointers on separate foil
Wednesday, 24 September 2008 Department of Computer Science
Installing Java SDK
SQL Query
Available Schemas
(Databases)
Syntax Help
Query Results
javax.jdo.option.ConnectionDriverName=com.mysql.jdbc.Driver
javax.jdo.option.ConnectionURL=jdbc:mysql://localhost:3306/demoshop
javax.jdo.option.ConnectionUserName=root
javax.jdo.option.ConnectionPassword=
org.jpox.implementationCreatorName = asm
org.jpox.autoCreateSchema=true
org.jpox.validateTables=false
org.jpox.validateConstraints=false
Normal classes
are not persistable,
have no knowledge of persistence.
are totally unchanged in JDO, and require no JDO Meta-Data whatsoever.
@PersistenceCapable
@Inheritance(strategy=InheritanceStrategy.NEW_TABLE)
public class Book extends Product{
@Persistent
protected String author = null;
@Persistent
protected String isbn = null;
@Persistent
protected String publisher = null;
tx.commit();
Transaction tx = pm.currentTransaction();
try{
tx.begin();
Book book = new Book(“Web Services", “the blue book on the shelf“ ,47.96,
“Gustavo Alonso", " 3540440089 ", " Springer ");
pm.makePersistent(test);
pm.makePersistent(book);
tx.commit
}
finally{
if(tx.isActive())
tx.rollback();
pm.close();
}
tx.begin();
while(pIterator.hasNext()){
Product p = pIterator.next();
System.out.println(p.name + "-" + p.description+ "-" + p.price);
}
tx.commit();
tx.begin();
while(pIterator.hasNext()){
Product p = pIterator.next();
p.setPrice(25.0); // Change the value
}
tx.commit();
From Wikipedia:
A transaction is a unit of interaction with a
database management system or similar system
that is treated in a coherent and reliable way
independent of other transactions.
Important for concurrent interactions on the
same data