java:使用路径访问Access数据库
public class Query{
String url,classname;
Connection conn;
public Query() throws ClassNotFoundException,SQLException{
//Specify the database path to connect
String soFTPath=(new File("")).getAbosultePath();
//String softPath="D:myProject";
String dbPath=softPath+"dbpathdbFile.mdb";
url="jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ="+dbPath;
classname="sun.jdbc.odbc.JdbcOdbcDriver";
Class.forName(classname);
conn=DriverManager.getConnection(url,"newWord","newword");
}
- 上一篇:switch语句的“不准遍历”
- 下一篇:舍弃浮躁, 50条重要的C++学习建议