日期:2014-05-18  浏览次数:20717 次

[Microsoft][ODBC Microsoft Access Driver]问题求教
项目不是放在webapps/root下,而是另外的目录,现在使用
    String   strDirPath=application.getRealPath(request.getRequestURI());
    strDirPath=strDirPath.substring(0,strDirPath.lastIndexOf( '\\ '))+ "\\ ";
    String   url   =   "jdbc:odbc:driver={Microsoft   Access   Driver   (*.mdb)};DBQ= "+strDirPath+ "db\\test.mdb ";
来连接数据库,却出现
java.sql.SQLException:   [Microsoft][ODBC   Microsoft   Access   Driver]   '(未知的) '不是一个有效的路径。   确定路径名称拼写是否正确,以及是否连接到文件存放的服务器。这样的错误

而相同的代码我将文件放在webapps/root下却是正确的.

请问如何解决呢?项目位置不能更改了

------解决方案--------------------
System.out.println(url);看看真实url是什么,和正确的比较下
------解决方案--------------------
strDirPath.lastIndexOf()对么?不是indexOf()?