龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > 软件开发 > C/C++开发 >

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

时间:2009-12-22 15:42来源:未知 作者:admin 点击:
分享到:

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

  

  }

  

精彩图集

赞助商链接