JAVA远程连接ACCESS失败!
我按照网上的方法配置了rmijdbc:下载了rmijdbc.jar,配置了环境变量,配置了数据源,服务窗口一直开启,显示如下D:\Program Files>java org.objectweb.rmijdbc.RJJdbcServer
Wed Jun 01 15:47:50 CST 2011: [RmiJdbc] Starting RmiJdbc Server !
Wed Jun 01 15:47:50 CST 2011: [RmiJdbc] No installation of RMI Security Manager.
..
Wed Jun 01 15:47:50 CST 2011: [RmiJdbc] Binding RmiJdbcServer...
Wed Jun 01 15:47:50 CST 2011: [RmiJdbc] RmiJdbcServer bound in rmi registry
客户端连接数据库主要代码如下:
private Connection conn = null;
private Statement stmt=null;
private ResultSet rs = null;
private String dbpath = "D:\\fdzhm\\mywork.accdb";
private String rmiurl="jdbc:rmi://127.0.0.1(自己连自己的电脑,远程连接要换IP的)/jdbc:odbc:work";//(自己连自己的电脑,远程连接要换IP的)
public Connection getConnection(){
try{
Class.forName("org.objectweb.rmijdbc.Driver").newInstance();
conn=DriverManager.getConnection(rmiurl);
stmt = conn.createStatement();
}
catch(Exception e){
System.out.println(" 连接失败!");
}
return conn;
}
........
当我连接的时候,出现错误,如下:
!java.lang.ClassNotFoundException: org.objectweb.rmijdbc.Driver
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at Beans.ConnectAccess.getConnection(ConnectAccess.java:24)
at Beans.ConnectAccess.query(ConnectAccess.java:40)
at Beans.ConnectAccess.main(ConnectAccess.java:93)
请高手指教,哪里出了问题? --------------------编程问答-------------------- 把RmiJdbc.jar放到Java\jre\lib\ext下就好了 --------------------编程问答-------------------- 缺驱动包啊,
补充:Java , Web 开发