![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
JDBC
单曲循环
小菜鸡小菜鸡
展开
-
JDBC获取数据库连接(仅代码,少量注释)
配置文件信息 # 文件名 SQLFile.properties username=root password=root url=jdbc:mysql://localhost:3306/test?serverTimezone=UTC driverClass=com.mysql.cj.jdbc.Driver 代码: public class JDBCUtils { /** * 获取...原创 2019-11-23 21:09:41 · 147 阅读 · 0 评论 -
使用类加载器关联文件后,加载出现空指针的问题
今天使用JDBC连接数据库,在读取文件时出现了空指针异常 代码如下: public static Connection getConnection() throws Exception { // 获得类加载器,将加载器关联文件 InputStream is = JDBCUtils.class.getResourceAsStream("SQLFile.prop...原创 2019-11-23 01:38:23 · 1127 阅读 · 1 评论 -
JDBC连接MySQL Loading class `com.mysql.jdbc.Driver'. This is deprecated
解决问题 今天使用JDBC连接数据库时报了异常 Loading class `com.mysql.jdbc.Driver’. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver’. The driver is automatically registered via the SPI and manual lo...原创 2019-11-23 00:10:35 · 20636 阅读 · 13 评论