;
sess.save(p);
t.commit();
sess.close();
}
}
让我们来运行它!通过运行java test.InsertProduct Milk 100 1.99命令,插入价格为1.99的100瓶牛奶。我们会得到如下的输出日志:
Nov 23, 2003 9:05:50 AM net.sf.hibernate.cfg.Environment <clinit>
INFO: Hibernate 2.0.3
Nov 23, 2003 9:05:50 AM net.sf.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
Nov 23, 2003 9:05:50 AM net.sf.hibernate.cfg.Environment <clinit>
INFO: using CGLIB reflection optimizer
Nov 23, 2003 9:05:50 AM net.sf.hibernate.cfg.Environment <clinit>
INFO: JVM proxy support: true
Nov 23, 2003 9:05:50 AM net.sf.hibernate.cfg.Configuration addClass
INFO: Mapping resource: test/hibernate/Product.hbm.xml
Exception in thread "main" net.sf.hibernate.MappingException:
Resource: test/hibernate/Product.hbm.xml not found
at net.sf.hibernate.cfg.Configuration.addClass(Configuration.java:285)
at test.FindProductByName.main(FindProductByName.java:24)
它无法工作。其中有两行尤其让人感兴趣:
INFO: hibernate.properties not found and
Resource: test/hibernate/Product.hbm.xml not found. 当然,INFO行指出我们需要一个hibernate.properties配置文件。在这个文件中,我们配置要使用的数据库、用户名和密码以及其他选项。使用下面提供的这个示例来连接前面提到的Hypersoni上一页 [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] ... 下一页 >>
|