| 導購 | 订阅 | 在线投稿
分享
 
 
 

java:使用路徑訪問Access數據庫

來源:互聯網  2008-06-01 01:14:32  評論

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");

}

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"); }
󰈣󰈤
王朝萬家燈火計劃
期待原創作者加盟
 
 
 
>>返回首頁<<
 
 
 
 
 熱帖排行
 
 
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有