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ブリッジドライバのstatic (試し( class.forname ( " sun.jdbc.odbc.jdbcodbcdriver " ) ; )キャッチ( classnotfoundexceptionメール) ( system.err.println ( " jdbcodbcブリッジドライバが見つかりませんでした! " ) ; ) ) / ** Accessデータベースの接続を作成する場合* / public static接続getaccessdbconnection (文字列のファイル名)例外sqlexception (ファイル名= filename.replace ( '' 、 '/').トリム( ) ;文字列databaseurl = accessdburlprefix +ファイル名+ accessdburlsuffix ; drivermanagerを返します。のgetConnection ( databaseurl 、 " " 、 " " ) ; ) Filed under提出されて Databaseデータベース , 、 Java Software Javaソフトウェア , 、 Microsoftマイクロソフト , 、 Technology技術 | |
| |
RSS 2.0 RSS 2.0を | |
Email this Article電子メールこの記事
You may also like to readを読むようにすることも可能 |





October 12th, 2004 at 4:44 am 2004年10月12日は4:44アム
and if the database have password?との場合、データベースにパスワードですか?
March 28th, 2006 at 5:20 am 2006年3月28日は5: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.今日の私は、その手の込んだ2つのサンプルを提供するクラスです。 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. 2番目-a ccessjdbctest.javaを使用して任意の与えられた最初のクエリを実行する(のD MLのD DL&サポート)を任意のM SA ccessのデータベースとその結果をコンソールに表示されます。 [...]
August 23rd, 2006 at 11:40 pm 2006年8月23日11:40 pmの
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..私は何を知って希望してURLの手段と方法を構築するような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.はい、それはそれの美しさをする必要はありませんデータソース名を入力します。
> i would like to know what your url means and how to construct such an url.. >したいのURLを知ってどのような手段と方法を構築してこのような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 pmの
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これは罰金を知っている回線のODBC program.buti wul'dするMS Accessに接続さを知ってどのように行くようにと入力し、 [コントロールパネル]を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日5: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 /週を通じてMS AccessおよびJDBCのコントロールパネル( ODBCデータソース名)
July 16th, 2007 at 6:25 am 2007年7月16日の午前6時25時
i Want to access my Microsoft access file.私のマイクロソフトのアクセスしたいファイルへのアクセスします。 file exist on my local mechine… can any one give me example code for the same… the executed code私の地元に存在するファイルのいずれか1つ与えることmechine …私の例のコードを実行コードと同じ…
August 3rd, 2007 at 3:06 am 2007年8月3日3:06アム
how to connect ajsp file with ms access….usinf jdbc….can u send me the tags whis is used ajspに接続する方法でファイルをMS Accessの… 。 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形式のファイルをインターネットブラウザが、アプレットは、就学許可証のオープニングではないが、データベースの接続… ..
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の呼び出しに変換するデータベースに依存しないネットプロトコルこれはデータベースを参照して入力し、翻訳されたサーバープロトコルです。このNETサーバーへの接続ができるミドルウェアすべてのJavaテクノロジベースのクライアントを多くの異なるデータベースに依存して、特定のプロトコルのベンダに使われています。一般的には、これは、最も柔軟性のJDBC APIを代替します。 )またはタイプ4 (に自生する-プロトコルを完全にJavaテクノロジが有効になってドライバに変換するJDBCの呼び出しをするためのネットワークプロトコル技術のデータベースを直接使用されています。これにより、マシンに直接電話して、クライアントからのデータベースサーバーとは、現実的な解決策をイントラネットにアクセスします。以来の多くは、これらのプロトコルは、独自のデータベースベンダ自身はメインのソースこのスタイルのドライバを使用します。 ) JDBCドライバを適切に接続する。
June 3rd, 2008 at 11:37 pm 2008年6月3日11:37 pmの
i want to access data in excel to MS access how to write a code for this in java ExcelでのデータにアクセスしたいするMS Accessに接続する方法をここにこのコードをJavaで