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