Vote 投票 0 0
How to access Microsoft Access database from JDBC如何使用Microsoft Access数据库的JDBC从
Angsuman Chakraborty日由Angsuman Chakraborty
October 25th, 2003 2003年10月25日 private static final String accessDBURLPrefix = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ="; private static final String accessDBURLSuffix = ";DriverID=22;READONLY=false}"; // Initialize the JdbcOdbc Bridge Driver static { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); } catch(ClassNotFoundException e) { System.err.println("JdbcOdbc Bridge Driver not found!"); } } /** Creates a Connection to a Access Database */ public static Connection getAccessDBConnection(String filename) throws SQLException { filename = filename.replace('', '/').trim(); String databaseURL = accessDBURLPrefix + filename + accessDBURLSuffix; return DriverManager.getConnection(databaseURL, "", ""); }私人静态的最后字符串accessdburlprefix = “的JDBC为: ODBC :司机= ( Microsoft Access的驱动程序( *. mdb )中) ; dbq = ” ;私人静态的最后字符串accessdburlsuffix = “ ; driverid = 22 ;只读=虚假) ” ; / /初始化jdbcodbc桥式驱动器的静态(尝试( class.forname ( “ sun.jdbc.odbc.jdbcodbcdriver ” ) ; )赶上( classnotfoundexception五) ( system.err.println ( “ jdbcodbc桥式驱动器未找到! ” ) ; ) ) / **创建一个连接到Access数据库中* /公共静态连接getaccessdbconnection (字符串的文件名)抛出sqlexception (文件名= filename.replace ( '' , '/').修剪( ) ;字符串databaseurl = accessdburlprefix +文件名+ accessdburlsuffix ;返回drivermanager 。 getconnection ( databaseurl , “ ” , “ ” ) ; ) Filed under提起下 Database数据库 , , Java Software Java软件 , , Microsoft微软 , , Technology技术 | |
| |
RSS 2.0 2.0 | |
Email this Article电子邮件此文章
You may also like to read您也可以想读 |




October 12th, 2004 at 4:44 am 2004年10月12日在上午04时44分
and if the database have password?如果数据库的密码?
March 28th, 2006 at 5:20 am 2006年3月28日在上午05时20分
[...] Previously I had provided the gist of how to access MS Access database from JDBC using JDBC-ODBC bridge. [ … … ]以前我曾提供精神如何访问MS Access资料库从JDBC的使用JDBC - ODBC的桥梁。 Today I will elaborate on that and provide you with two sample classes.今天,我将详细阐述,并为您提供两个范例班。 The first - AccessJDBCUtil.java defines a method which provides you with a connection to the ms access database.第一-a ccessjdbcutil.java定义了一个方法,为你提供了一种连接到M SA ccess资料库。 The second - AccessJDBCTest.java uses the first to execute any given query (DDL & DML supported) on any ms access database and displays the result on console.第二-a ccessjdbctest.java用途第一执行任何特定的查询( d dl& d ml支持)就任何M SA ccess资料库,并显示在控制台的结果。 [...] [ … … ]
August 23rd, 2006 at 11:40 pm 2006年8月23日在下午11时40分
hi angsuman,喜由Angsuman ,
your code was really useful.您的代码是真的有用。 everything makes sense..一切是有道理的..
but i would like you to throw some light on how you constructed the dburl..但我想你丢了一些轻你如何构建dburl ..
if i am right your code does not require the data source name..如果我的权利,您的代码并没有规定数据源名称..
i would like to know what your url means and how to construct such an url..我想知道您的网址是什么手段,怎样建设这样一个网址..
August 24th, 2006 at 8:56 am 2006年8月24日在上午8时56分
> if i am right your code does not require the data source name.. >如果我的权利,您的代码并没有规定数据源名称..
Yes, the beauty of it is that it doesn’t require datasource name.是的,美丽的,那就是它不需要DataSource的名称。
> i would like to know what your url means and how to construct such an url.. >我想知道您的网址是什么手段,怎样建设这样一个网址..
Just reuse the code I have provided.只是重用的代码我所提供的。 It is the format which jdbc-odbc bridge driver understands and converts to appropriate format for underlying odbc layer.这是格式JDBC的ODBC的桥式驱动器的理解,并将其转换为以适当的格式为基本的ODBC层。 In short just reuse my code.在短期内只是重用我的代码。
July 7th, 2007 at 11:56 pm 2007年7月7日在下午11时56分
It is fine to know the conection of ODBC to MS ACCESS in Program.Buti wul’d like to know how to go control panel and then to ODBC and to give the这是优良知道conection的ODBC女士的访问,在program.buti wul'd想知道如何去控制面板,然后ODBC和给予
details of DNS name and select the required .mdb file.详情DNS名称并选择所需。 mdb文件。
I am sure ur going to give me the correct informatin.我深信乌拉圭回合去给我正确的informatin 。
July 15th, 2007 at 5:56 am 2007年7月15日在上午05时56分
the same question as venkat i tried using control panel but wen i ran the program it showed sql exception error…同样的问题,作为venkat我尝试使用控制面板,但文我参加该计划,它表明的SQL异常错误…
tell me how to establish connection b/w ms access and jdbc through control panel (odbc data source name )告诉我,如何建立连接的B /瓦特女士访问和JDBC通过控制面板( ODBC数据源名称)
July 16th, 2007 at 6:25 am 2007年7月16日在上午06时25分
i Want to access my Microsoft access file.我要访问我的Microsoft Access文件。 file exist on my local mechine… can any one give me example code for the same… the executed code文件存在于我的本地机… …可以任何一个给我的示例代码为同一…被处决的代码
August 3rd, 2007 at 3:06 am 2007年8月3日在上午03时06分
how to connect ajsp file with ms access….usinf jdbc….can u send me the tags whis is used如何连接ajsp文件与MS访问… … 。 usinf JDBC的… … 。 u可以寄给我的标签whis是用来
November 23rd, 2007 at 8:20 am 2007年11月23日在上午8时20分
im trying to run applet with jdbc in an html file with the internet browser but the applet is opening but the database is not getting connected …..即时通讯试图运行程序与JDBC在HTML文件与网际网路浏览器,但Applet的是开放,但数据库是得不到连接… ..
November 23rd, 2007 at 7:59 pm 2007年11月23日在下午7点59分
You need to use either a type 3 (A net-protocol fully Java technology-enabled driver translates JDBC API calls into a DBMS-independent net protocol which is then translated to a DBMS protocol by a server. This net server middleware is able to connect all of its Java technology-based clients to many different databases. The specific protocol used depends on the vendor. In general, this is the most flexible JDBC API alternative.) or type 4 (A native-protocol fully Java technology-enabled driver converts JDBC technology calls into the network protocol used by DBMSs directly. This allows a direct call from the client machine to the DBMS server and is a practical solution for Intranet access. Since many of these protocols are proprietary the database vendors themselves will be the primary source for this style of driver.) JDBC driver to connect properly.您需要使用一个3型(净协议完全支持Java技术的转换,使司机的JDBC API调用成为一个DBMS的独立网协议,这是翻译,然后到一个DBMS的议定书的一台服务器,这NET服务器中间件是能够连接在其所有基于Java技术的客户很多不同的数据库。议定书的具体使用依赖于供应商。总的来说,这是最灵活的JDBC API的选择。 )或键入4 ( 1本土协议完全Java技术,使司机转换JDBC技术要求到网络中所使用的通讯协定dbmss直接,这允许直接呼叫从客户机到服务器和数据库管理系统是一个实际的解决办法,为内部网接入。由于许多这些协议的专有数据库厂商自己将是主要来源这个作风,司机) 。 JDBC驱动程序,连接正确。
June 3rd, 2008 at 11:37 pm 2008年6月3日在下午11时37分
i want to access data in excel to MS access how to write a code for this in java我想获取的数据在Excel女士的访问如何写代码,这在Java