@PersistenceCapable
public class Person {
@PrimaryKey
private String id;
private String name;
// getters and setters
}
PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory("myconfig.jdo");
PersistenceManager pm = pmf.getPersistenceManager();
Person person = new Person();
person.setId("1");
person.setName("John Doe");
try {
pm.makePersistent(person);
} finally {
pm.close();
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jdo PUBLIC "-//Sun Microsystems, Inc.//DTD Java Data Objects 2.0//EN"
"http://java.sun.com/dtd/jdo_2_0.dtd">
<jdo>
<datastore name="mydatastore">
<jdbc>
<driver>com.mysql.jdbc.Driver</driver>
<url>jdbc:mysql://localhost/mydb</url>
<user>username</user>
<password>password</password>
</jdbc>
</datastore>
</jdo>