You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
809 B
34 lines
809 B
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;
|
|
|
|
}
|
|
}
|