Compare commits
2 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
8756e6c73c | 2 years ago |
|
|
fcde5716ff | 2 years ago |
@ -0,0 +1,33 @@
|
||||
package com.tmj.dao.impl;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Properties;
|
||||
|
||||
public class JDBCUtil {
|
||||
static String url;
|
||||
static Properties info =new Properties();
|
||||
|
||||
static{
|
||||
InputStream input = JDBCUtil.class.getClassLoader()
|
||||
.getResourceAsStream("config.properties");
|
||||
try {
|
||||
info.load(input);
|
||||
url = info.getProperty("url");
|
||||
|
||||
|
||||
Class.forName(info.getProperty("driver"));
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public static Connection getConnection() throws SQLException {
|
||||
Connection conn = DriverManager.getConnection(url,info);
|
||||
return conn;
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
driver=com.mysql.cj.jdbc.Driver
|
||||
url=jdbc:mysql://localhost:3306/movie?userSSL=false&serverTimezone=Asia/Shanghai
|
||||
user=root
|
||||
password=20040315tang
|
||||
userSSL = false
|
||||
serverTimezone = Asia/Shanghai
|
||||
Loading…
Reference in new issue