java:使用路径访问Access数据库
2008-03-08 11:05:37 来源:WEB开发网核心提示:public class Query{String url,classname;Connection conn;public Query() throws ClassNotFoundException,SQLException{//Specify the database path to connectString s
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+"\\dbpath\\dbFile.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");
}
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+"\\dbpath\\dbFile.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");
}
更多精彩
赞助商链接