Access with jdbc to Ms Access with embedded connection |
Stefano |
2005-11-29 00:00:00 |
Hello,
I'm developing a jsp web site and i connect the jsp pages to a Ms Access db with java bean. The database it is located in the same directory where is placed the java bean. I would like to know which string i have to pass to the method DriverManager.getConnection() to refer to the database in local. For example "../sql/..../file_name.extension" using html to tell to the browser to do this action:
1- cd..
2- cd sql
3- open file_name.extension.
I'm using tomcat but i can't use a poolable connection because i can't access to the conf file of tomcat.
Sorry for my english.
Thanks, Stefano.
|
Re:Access with jdbc to Ms Access with embedded connection |
HXTT Support |
2005-11-29 00:00:00 |
You can use "jdbc:access:///../sql/file_name.mdb" or "jdbc:access:///"+request.getRealPath("../")+"/sql/file_name.mdb".
|
Re:Re:Access with jdbc to Ms Access with embedded connection |
Stefano |
2005-11-29 00:00:00 |
Thanks for your fast reply. The first method doesnt't work and the second method works but only in Tomcat. I have to put this method in a javabean, a java class compilated that it is used by the jsp pages to connect to the db. In a java class i can't use the method request.getRealPath. I need a corresponding method for java that i can use in a java environment like Eclipse.
Thanks, Stefano
|
Re:Re:Access with jdbc to Ms Access with embedded connection |
Stefano |
2005-11-29 00:00:00 |
Thanks for your fast reply. The first method doesnt't work and the second method works but only in Tomcat. I have to put this method in a javabean, a java class compilated that it is used by the jsp pages to connect to the db. In a java class i can't use the method request.getRealPath. I need a corresponding method for java that i can use in a java environment like Eclipse.
Thanks, Stefano
|
Re:Re:Re:Re:Access with jdbc to Ms Access with embedded connection |
HXTT Supports |
2005-11-29 00:00:00 |
If you know an absolute path, you can use:
"jdbc:access:///c:/aDirectory/../sql/file_name.mdb" for Windows
Or
"jdbc:access:////sys/data/sql/file_name.mdb" for Linux/Unix's sys volumn.
a relative sample:
"jdbc:access:///./../sql/file_name.mdb"
|
sorry, but I do not solve the problem |
Stefano |
2006-02-22 00:00:00 |
Here it's the string that i use in my jsp file:
String urlDb = "jdbc:Access:///./../../db/database.mdb";
The file prova.jsp is in the follow absolute path:
C:\Programmi\Apache Group\Tomcat 4.1\webapps\prova22\jsp\italiano
and the database.mdb is in the follow absolute path:
C:\Programmi\Apache Group\Tomcat 4.1\webapps\prova22\db.
The message that reply tomcat is:
javax.servlet.ServletException: ./../../db/database.mdb doesn't exist!
It is very important that i can't use the method getRealPath() and I must use relative and not absolute path. Thanks very much
|
Re:Re:Re:Re:Re:Re:Access with jdbc to Ms Access with embedded connection |
HXTT Support |
2006-02-22 00:00:00 |
You can use System.out.println(new java.io.File("./../../db/database.mdb").getAbsolutePath());
to see where's that path.
|
reply |
stefano |
2006-02-22 00:00:00 |
i can't use getAbsolutePaht() on the server that hosts my jsp web site
|
Re:Re:Re:Re:Re:Re:Re:Re:Access with jdbc to Ms Access with embedded connection |
HXTT Support |
2006-02-22 00:00:00 |
You can use getClass().getResource("../..").toString() to get a relative path from classpath for your java bean.
|