首页 > 学院 > 开发设计 > 正文

java:使用路径访问Access数据库

2019-11-17 05:49:55
字体:
来源:转载
供稿:网友
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");

}

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表