1、读取配置文件
//Properties集合 流对象读取键值对
public static void getNum() throws Exception {
Properties p=new Properties();
FileReader f=new FileReader("c:\\root.properties");
p.load(f);
f.close();
}
2、properties文件
url:jdbc:mysql://localhost:3306/qy97
name:"root"
password:"root"
3、数据库连接代码
package com.aaa.QuDong;
import java.io.FileReader;
import java.sql.*;
import java.util.Properties;
public class SQLEnc_Test {
public static void main(String[] args) throws Exception {
Properties p=new Properties();
//获取文件里边的值
FileReader f=new FileReader("c:\\root.properties");
p.load(f);
String url=p.getProperty("url");
String user = p.getProperty("name");
String r