我根据这个例子
http://www.ibm.com/developerworks/cn/data/library/techarticles/dm-0506bhogal/index.html
自己做了一个实例,只是将数据库换成了MYSQL。
运行中到
private static void createEmployee(PersistenceManager pm) { Employee emp = new Employee(556974421L, "John", "Doe", 2090.12F); Transaction txn = pm.currentTransaction();
txn.begin(); pm.makePersistent(emp); txn.commit();
}的pm.makePersistent(emp);时程序出错,报一下错误
Exception in thread "main" org.jpox.exceptions.ClassNotPersistenceCapableException: The class "example.Employee" is not Persistence-Capable. This means that it either hasnt been enhanced, or that the enhanced version of the file is not in the CLASSPATH (or is hidden by an unenhanced version), or the Meta-Data for the class is not found.
at org.jpox.AbstractPersistenceManager.assertPersistenceCapable(AbstractPersistenceManager.java:3964)
at org.jpox.AbstractPersistenceManager.internalMakePersistent(AbstractPersistenceManager.java:1083)
at org.jpox.AbstractPersistenceManager.makePersistent(AbstractPersistenceManager.java:1205)
at example.MyApplication.createEmployee(MyApplication.java:78)
at example.MyApplication.main(MyApplication.java:30)
我是用ECLIPSE去编写的,package.jdo我放在了根目录SRC下。我还将所有要用的JDO的jar包编写到环境变量CLASSPATH中,还是报错,不知道原因,以前没用过这东西,请大侠指点!
http://www.ibm.com/developerworks/cn/data/library/techarticles/dm-0506bhogal/index.html
自己做了一个实例,只是将数据库换成了MYSQL。
运行中到
private static void createEmployee(PersistenceManager pm) { Employee emp = new Employee(556974421L, "John", "Doe", 2090.12F); Transaction txn = pm.currentTransaction();
txn.begin(); pm.makePersistent(emp); txn.commit();
}的pm.makePersistent(emp);时程序出错,报一下错误
Exception in thread "main" org.jpox.exceptions.ClassNotPersistenceCapableException: The class "example.Employee" is not Persistence-Capable. This means that it either hasnt been enhanced, or that the enhanced version of the file is not in the CLASSPATH (or is hidden by an unenhanced version), or the Meta-Data for the class is not found.
at org.jpox.AbstractPersistenceManager.assertPersistenceCapable(AbstractPersistenceManager.java:3964)
at org.jpox.AbstractPersistenceManager.internalMakePersistent(AbstractPersistenceManager.java:1083)
at org.jpox.AbstractPersistenceManager.makePersistent(AbstractPersistenceManager.java:1205)
at example.MyApplication.createEmployee(MyApplication.java:78)
at example.MyApplication.main(MyApplication.java:30)
我是用ECLIPSE去编写的,package.jdo我放在了根目录SRC下。我还将所有要用的JDO的jar包编写到环境变量CLASSPATH中,还是报错,不知道原因,以前没用过这东西,请大侠指点!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货