iBATIS 2.0 开发完全指南 - 夏昕

需积分: 0 2 下载量 61 浏览量 更新于2024-10-14 收藏 370KB PDF 举报
iBATISDeveloper’sGuide 《iBATIS2.0开发指南》是由作者夏昕编写的关于iBATIS框架的详细教程,旨在帮助开发者理解和掌握iBATIS 2.0的使用。该指南于2004年9月2日发布,是开源文档系列的一部分,鼓励开放文档分享。文档包含了作者的版权声明,允许在无附加条件的情况下自由传播,但部分或全文引用需事先得到作者许可。 iBATIS是一个Java语言的持久层框架,它提供了一种将SQL语句与Java代码分离的方式,简化了数据库访问的复杂性。以下是该指南中涉及的一些关键知识点: 1. **快速入门**:这部分介绍了如何开始使用iBATIS,包括准备工作,如添加依赖库,以及构建ibatis基础代码。它还涵盖了配置iBATIS的基本步骤,以便在项目中集成。 2. **iBATIS配置**:这部分详细解释了如何配置SqlMapConfig.xml文件,这是iBATIS的核心配置文件,用于定义数据源、事务管理器和SqlMapClient等关键元素。 3. **iBATIS基础语义**:详细阐述了SqlMapClientBuilder和SqlMapClient的概念及其作用。SqlMapClientBuilder用于构建SqlMapClient实例,而SqlMapClient则是执行SQL映射语句的对象。 4. **SqlMapClient基本操作示例**:提供了如何执行查询、插入、更新和删除等数据库操作的实例,展示了iBATIS如何处理SQL语句和结果集映射。 5. **对象关系映射(ORM)**:这部分详细介绍了iBATIS如何实现对象与数据库表之间的映射。包括了如何在XML映射文件中定义字段和对象属性的对应关系。 6. **高级特性**:涵盖了数据关联、一对多关联、一对一关联和延迟加载等特性。数据关联是处理复杂数据结构的关键,一对多和一对一关联定义了实体对象间的关联规则,而延迟加载则是一种优化性能的策略,只在需要时加载关联数据。 7. **动态映射**:讲解了如何使用动态SQL,使得SQL语句可以根据业务逻辑的变化灵活调整,增强了SQL的可维护性和灵活性。 8. **事务管理**:介绍了基于JDBC和基于JTA的事务管理机制,包括如何配置和控制事务的开始、提交、回滚等操作。 9. **其他内容**:尽管未在提供的内容中详细展开,但通常还包括错误处理、缓存机制、结果处理器等内容,这些在实际开发中也非常重要。 《iBATIS2.0开发指南》是一份全面的参考资料,涵盖了iBATIS框架的各个方面,对于希望使用iBATIS进行数据库操作的Java开发者来说非常有价值。通过深入学习和实践,开发者可以有效地利用iBATIS提高开发效率,降低数据库访问的复杂度。

D:\javaJDK17\bin\java.exe "-javaagent:D:\编程软件\idea2022\IntelliJ IDEA 2022.1.3\lib\idea_rt.jar=4912:D:\编程软件\idea2022\IntelliJ IDEA 2022.1.3\bin" -Dfile.encoding=UTF-8 -classpath "D:\IDEA java\javaWeb\Maven\maven-project01\target\classes;D:\Maven\apache-maven-3.9.3-bin\apache-maven-3.9.3\mvn_store\org\mybatis\mybatis\3.5.5\mybatis-3.5.5.jar;D:\Maven\apache-maven-3.9.3-bin\apache-maven-3.9.3\mvn_store\mysql\mysql-connector-java\5.1.46\mysql-connector-java-5.1.46.jar;D:\Maven\apache-maven-3.9.3-bin\apache-maven-3.9.3\mvn_store\org\slf4j\slf4j-api\1.7.32\slf4j-api-1.7.32.jar;D:\Maven\apache-maven-3.9.3-bin\apache-maven-3.9.3\mvn_store\ch\qos\logback\logback-core\1.2.6\logback-core-1.2.6.jar;D:\Maven\apache-maven-3.9.3-bin\apache-maven-3.9.3\mvn_store\ch\qos\logback\logback-classic\1.2.6\logback-classic-1.2.6.jar" Demo1.HelloWord Exception in thread "main" org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: java.sql.SQLException: Error setting driver on UnpooledDataSource. Cause: java.lang.ClassNotFoundException: Cannot find class: ${com.mysql.jdbc.Driver} ### The error may exist in UserMapper.xml ### The error may involve test.selectAll ### The error occurred while executing a query ### Cause: java.sql.SQLException: Error setting driver on UnpooledDataSource. Cause: java.lang.ClassNotFoundException: Cannot find class: ${com.mysql.jdbc.Driver} at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:149) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:140) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:135) at Demo1.HelloWord.main(HelloWord.java:23) Caused by: java.sql.SQLException: Error setting driver on UnpooledDataSource. Cause: java.lang.ClassNotFoundException: Cannot find class: ${com.mysql.jdbc.Driver} at org.apache.ibatis.datasource.unpooled.UnpooledDataSource.initializeDriver(UnpooledDataSource.java:244) at org.apache.ibatis.datasource.unpooled.UnpooledDataSource.doGetConnection(UnpooledDataSource.java:223) at org.apache.ibatis.datasource.unpooled.UnpooledDataSource.doGetConnection(UnpooledDataSource.java:219) at org.apache.ibatis.datasource.unpooled.UnpooledDataSource.getConnection(UnpooledDataSource.java:95) at org.apache.ibatis.datasource.pooled.PooledDataSource.popConnection(PooledDataSource.java:432) at org.apache.ibatis.datasource.pooled.PooledDataSource.getConnection(PooledDataSource.java:89) at org.apache.ibatis.transaction.jdbc.JdbcTransaction.openConnection(JdbcTransaction.java:139) at org.apache.ibatis.transaction.jdbc.JdbcTransaction.getConnection(JdbcTransaction.java:61) at org.apache.ibatis.executor.BaseExecutor.getConnection(BaseExecutor.java:337) at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:86) at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:62) at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:325) at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156) at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109) at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:89) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:147) ... 3 more

2023-07-22 上传

java.lang.IllegalStateException: Failed to execute CommandLineRunner at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:798) [spring-boot-2.3.4.RELEASE.jar:2.3.4.RELEASE] at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:779) [spring-boot-2.3.4.RELEASE.jar:2.3.4.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:322) [spring-boot-2.3.4.RELEASE.jar:2.3.4.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) [spring-boot-2.3.4.RELEASE.jar:2.3.4.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.3.4.RELEASE.jar:2.3.4.RELEASE] at com.unkown.data.hw.ipran.straight.collect.UnkownDataHwIpranStraightCollectApplication.main(UnkownDataHwIpranStraightCollectApplication.java:39) [classes/:na] Caused by: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.unkown.data.hw.ipran.straight.collect.dao.RTrsHwIpranCircuitDao.queryById at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:235) ~[mybatis-3.5.5.jar:3.5.5] at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:53) ~[mybatis-3.5.5.jar:3.5.5] at org.apache.ibatis.binding.MapperProxy.lambda$cachedInvoker$0(MapperProxy.java:115) ~[mybatis-3.5.5.jar:3.5.5] at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660) ~[na:1.8.0_271] at org.apache.ibatis.binding.MapperProxy.cachedInvoker(MapperProxy.java:102) ~[mybatis-3.5.5.jar:3.5.5] at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:85) ~[mybatis-3.5.5.jar:3.5.5] at com.sun.proxy.$Proxy108.queryById(Unknown Source) ~[na:na] at com.unkown.data.hw.ipran.straight.collect.service.impl.RTrsHwIpranCircuitServiceImpl.queryById(RTrsHwIpranCircuitServiceImpl.java:29) ~[classes/:na] at com.unkown.data.hw.ipran.straight.collect.controller.RTrsHwIpranCircuitController.IpranSend(RTrsHwIpranCircuitController.java:54) ~[classes/:na] at com.unkown.data.hw.ipran.straight.collect.MyRunner.run(MyRunner.java:24) ~[classes/:na] at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:795) [spring-boot-2.3.4.RELEASE.jar:2.3.4.RELEASE] ... 5 common frames omitted

2023-05-18 上传