Properties类有类似功能
test.txt:
driverManagerclass="sun.jdbc.odbc.JdbcOdbcDriver";
ConnectionURL="jdbc:odbc:test.mdb.";
部分代码:
import java.sql.*;
import java.util.*;
import java.io.*;
Properties prop=new Properties();
prop.load(new FileInputStream("test.txt"));
//load the Drive class
Class.forName(
prop.getProperty("driverManagerclass")
);
//create the connection usong the static getConnection method
Connection con=DriverManager.getConnection(prop.getProperty("ConnectionURL"));