发表于: 2017-12-10 18:58:09
1 689
今天完成的事情
1.实现mybatis操作数据库
窃以为mybatis和jdbc操作数据库的语句是一样的,不同的是mybatis将方法封装进了xml文件中,使用更加简洁方便(自己写配置文件还是做不到)
(1)在配置文件中新增crud的方法
<
mapper
namespace
=
"com.how2java.pojo"
>
<
insert
id
=
"addCategory"
parameterType
=
"Category"
>
insert into category_ ( name ) values (#{name})
</
insert
>
<
delete
id
=
"deleteCategory"
parameterType
=
"Category"
>
delete from category_ where id= #{id}
</
delete
>
<
select
id
=
"getCategory"
parameterType
=
"_int"
resultType
=
"Category"
>
select * from category_ where id= #{id}
</
select
>
<
update
id
=
"updateCategory"
parameterType
=
"Category"
>
update category_ set name=#{name} where id=#{id}
</
update
>
<
select
id
=
"listCategory"
resultType
=
"Category"
>
select * from category_
</
select
>
</
mapper
>
(2)这个代码是增加一条数据,同理通过session.操作对应的sql语句进行数据库的操作。
2.复习了之前的知识
因为今天的任务顺利完成,想到了温故知新,将java基础知识重新过了一遍,做了几道练习题,加深了巩固
3.进行了较为深刻的思考,考虑无论jdbc还是mybatis,其实大体的操作基本一样,反复思考自己为什么用了这么长的时间
4.学习了junit
但是知识很浅的了解了一下,谢了一个计算类,然后用junit测试了一下...
测试成功了,但是怎么感觉这个这么简单,这一定是我的错觉。
今天遇到的问题
使用idea弄junit时,总是失败,截止到目前还在百度为什么
今天的收获
焦灼的内心算是得到了慰藉吧,终于将节点17过了
明天的计划
junit没问题之后就开始spring的学习吧
最后,麻烦师兄审核啦
评论