摘要:
持久化单元,持久化对象的集合。事务类型:本地事务和全局事务。某些应用场合,只能使用全局事务。有两个数据库,mysql和oracle.转账时扣钱从mysql进行,加钱是在oracle执行,怎样确保两个语句在同一个事务中执行。普通JDBC不能,只能用全局事务。事务的生命周期应该从Connection对象中抽取出来,不应该局限在Connection中。通常由容器(WebLogic,JBoss)提供JTA实现。二次提交协议,执行一条语句预提交到数据库,执行结果保存到某个变量中,再执行另一条语句,如果都成功,再进行第二次提交。类路径下META-INF/persistence.xml如下:<?xml 阅读全文
摘要:
1.odbc方式2.jdbc驱动包方式public static void main(String[] args) { try { //Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Class.forName("oracle.jdbc.driver.OracleDriver"); //Connection con=DriverManager.getConnection("jdbc:odbc:scott", "scott", "123456"); C 阅读全文
摘要:
1.加上Context命名空间xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation加上http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd"2.要使用注解方式,进行依赖注入。要加上@Resource等注解的解析器<context:annotation-config/>3.要 阅读全文
摘要:
使用Hibernate 1.Hibernate核心包 hibernate-distribution-3.31.GA hibernate3.jar lib/bytecode/cglib/hiber... 阅读全文