java连接Access数据库驱动
java连接Access数据库操做数据库驱动连接方法:public static Connection getNativeConnection(){try { if(nativeConnection!=null && !nativeConnection.isClosed()){ return nativeConnection; }else{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); String dburl = "jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ="+SysPath.getAccessPath();// 此为NO-DSN方式 Connection conn = DriverManager.getConnection(dburl,"Administrator","123"); nativeConnection = conn; return nativeConnection; } } catch (Exception e) { com.hzfy.util.log.Log4jApp.getLogger().error("得到本地ACCESS数据库的连接异常"+e.getLocalizedMessage()); return null; } } String dburl = "jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ="+SysPath.getAccessPath();// 此为NO-DSN方式 Connection conn = DriverManager.getConnection(dburl,"Administrator","123"); nativeConnection = conn; return nativeConnection; } } catch (Exception e) { com.hzfy.util.log.Log4jApp.getLogger().error("得到本地ACCESS数据库的连接异常"+e.getLocalizedMessage()); return null; } }
暂无评论