收录学习过程中的小疑问
spring-jdbc和mysql-connector-java之间的区别
- The
MySQL connector java
is aJDBC
driver provided byMySQL
and you must include it in your Java app, if you want your app to talk to aMySQL
database.JDBC
is a standardAPI
in Java to communicate with aSQL
database and each type of database has its own driver that knows how to communicate with the database.- On the other hand,
Spring JDBC
is a convenience tool and an abstraction layer built on top of theJDBC
api that allows developers to communicate withSQL
databases using theirJDBC
drivers removing a lot of the boilerplate(模版) code. You don't necessary have to use
Spring JDBC`, but it will make your life easier.
MySQL connector java
是MySQL
提供的给Java
语言访问MySQL
的数据库驱动;JDBC
是标准的Java API
,是专门用来管理SQL
数据库的,JDBC
是一个接口,这个接口上可以插上不同的数据库驱动,MySQL connector java
只是用来它用来访问MySQL
数据库的一种驱动。还有其他的数据库如Oracle, DB2等也提供了驱动给JDBC
使用;Spring JDBC
是Spring
包装了JDBC
的工具,省去了很多使用JDBC
的模版代码;
所以使用java
语言访问MySQL
数据库可以使用原始的JDBC
+MySQL connector java
, 或者使用更方便的Spring JDBC
+MySQL connector java
com.mysql.jdbc.Driver和com.mysql.cj.jdbc.Driver的区别
com.mysql.jdbc.Driver 是 mysql-connector-java 5中的,
com.mysql.cj.jdbc.Driver 是 mysql-connector-java 6中的
参考com.mysql.jdbc.Driver 和 com.mysql.cj.jdbc.Driver的区别
@inherited注解
@Inherited 元注解是一个标记注解,@Inherited阐述了某个被标注的类型是被继承的。
如果一个使用了@Inherited修饰的annotation类型被用于一个class,则这个annotation将被用于该class的子类。
参考理解注解中的@Inherited