JP2004302840A - Data base access method - Google Patents

Data base access method Download PDF

Info

Publication number
JP2004302840A
JP2004302840A JP2003094791A JP2003094791A JP2004302840A JP 2004302840 A JP2004302840 A JP 2004302840A JP 2003094791 A JP2003094791 A JP 2003094791A JP 2003094791 A JP2003094791 A JP 2003094791A JP 2004302840 A JP2004302840 A JP 2004302840A
Authority
JP
Japan
Prior art keywords
class
database
access
data
data base
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
JP2003094791A
Other languages
Japanese (ja)
Inventor
Tatsuyuki Kanefuji
達幸 金藤
Seishi Hattori
清史 服部
Katsuhiro Nakamura
克洋 中村
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
NTT Comware Corp
Original Assignee
NTT Comware Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by NTT Comware Corp filed Critical NTT Comware Corp
Priority to JP2003094791A priority Critical patent/JP2004302840A/en
Publication of JP2004302840A publication Critical patent/JP2004302840A/en
Pending legal-status Critical Current

Links

Images

Abstract

<P>PROBLEM TO BE SOLVED: To provide a method of unifying different data base access systems by one interface and an automatic creating method of a data base operation procedure therefor. <P>SOLUTION: A user program 580 converts a data base operation type and data received from a client 20 into a data base operation procedure in conformity with a corresponding data base access system using a previously-automatically created table class 541, table collection class 542 and table access class 543, and issues an access request to a DB 10 using the data base operation procedure. As a result, a plurality of data base access systems are easily used properly by the same interface, thereby enabling the reduction in the burden on a software developer. A data base user also easily uses a data base. <P>COPYRIGHT: (C)2005,JPO&NCIPI

Description

【0001】
【発明の属する技術分野】
本発明は、複数の異なるデータベースアクセス方式によるデータベースへのアクセスを同一のインタフェースでアクセスできるようにするためのデータベースアクセス方法に関するものである。
【0002】
【従来の技術】
データベースにアクセスするためには、使用するデータベースアクセス方式として定められた規約に準拠したデータベース操作手続きを記述しなければならない。したがって、例えば、大量のデータをデータベースに登録する場合には高速に登録処理を行なうことができるSQL(Structured Query Language)ローダを使用してバッチ処理的に登録する。しかし、データベースを検索したり更新するような場合には、登録機能しかないSQLローダを使用することはできないため、JDBC(Java(登録商標) DataBase Connectivity)など別のデータベースアクセス方式のソフトウェアを使用してデータベースにアクセスすることになる。このように、複数の異なるデータベースアクセス方式を用いてデータベースをアクセスするためには、各データベースアクセス方式で規定された形式に準拠したデータベース操作手続きを記述するというように、データベースアクセス方式によりデータベース操作手続きを使い分ける必要があった。
【0003】
そのため、従来の複数の異なるデータベースアクセス方式を使用したデータベースのアクセスにおいては、ソフトウェア開発者によるアプリケーション・ソフトウェアなどの開発作業が複雑になったり、データベース利用者にとってデータベースのアクセスが面倒であるといった問題があった。また、データベースのテーブル構造に応じて人が手書きでクラス等を定義しなければならないため、手間がかかっていた。尚、従来技術としては特許文献1が公開されている。
【0004】
【特許文献1】
特開平5−197600号公報
【0005】
【発明が解決しようとする課題】
本発明は、上記の問題に鑑みてなされたもので、複数の異なるデータベースアクセス方式を使用したデータベースへのアクセスを容易にするために、データベースのアクセス方式が異なっても一つのインタフェースで統一するデータベースのアクセス方法、およびそのためのクラスやデータベース操作手続きを自動生成する方法を提供することを目的とする。
【0006】
【課題を解決するための手段】
この発明は、上記の課題を解決すべくなされたもので、請求項1に記載の発明は、複数の異なるデータベースアクセス方式を用いてデータベースをアクセスするデータベースアクセス方法において、端末から前記データベースをアクセスするためのデータおよびデータベース操作種別を受信し、前記受信したデータベース操作種別を識別し、前記識別したデータ操作種別に対応したデータベースアクセス方式で定められた所定の規則に準拠したデータベースアクセス形式に前記データおよびデータベース操作種別を変換し、前記データベースアクセス形式を用いて前記データベースにアクセス要求を出すことを特徴とするデータベースアクセス方法である。
【0007】
請求項2に記載の発明は、請求項1に記載のデータベースアクセス方法において、前記データベースアクセス形式への変換は、前記受信したデータを前記データベースの対応するテーブルと同一形式で格納するためのテーブルクラスおよび前記データベースアクセス方式に対応した制御用のテーブルアクセスクラスを、前記データベースのテーブルに対応付けて予め生成しておき、前記受信したデータを対応する前記テーブルクラスに格納し、前記識別したデータ操作種別に対応した前記テーブルアクセスクラスに記述された前記所定の規則にしたがって前記データおよびデータベース操作種別を変換することを特徴とする。
【0008】
請求項3に記載の発明は、請求項2に記載のデータベースアクセス方法において、前記テーブルクラスおよびテーブルアクセスクラスの生成は、前記データベースのテーブルに対応して予め準備されているテーブルクラス生成用雛形ファイル、および前記データベースアクセス方式に対応して予め準備されているテーブルアクセスクラス雛形ファイルと、前記データベースの属性情報をもとに生成することを特徴とする。
【0009】
【発明の実施の形態】
以下、本発明の実施の形態によるデータベースアクセス方法について説明する。ここでは、2通りのデータベースアクセス方式(JDBCおよびSQLローダ)を使用する場合に本発明を適用したデータベースアクセス方法について図1を参照して説明する。図1は本発明をアプリケーションサーバ(APサーバ)に適用した実施の形態によるシステム全体を示すブロック図である。図1において、10は、様々なデータを格納するデータベース(DB)である。20は利用者がDB10をアクセスする際に利用するクライアント(端末)であり、30はDB10を利用して様々な処理を行なう社内システムである。50は、本発明を適用した各種のアプリケーションサービスを提供するAPサーバであり、Web系(オンライン)の機能が実行されるWeb系DBアクセス部540とバッチ系の機能が実行されるバッチ系DBアクセス部560およびユーザプログラム580で構成(特許請求の範囲に記載のデータベースアクセス手段に相当)される。
【0010】
Web系DBアクセス部540は、JDBCを使用してDB10に対して検索、更新、登録および削除の全ての操作を可能としている。これに対して、バッチ系DBアクセス部560は、SQLローダを使用してDB10に対して登録の操作のみを可能としている。そのため、バッチ系DBアクセス部560は、Web系DBアクセス部540よりも高速にDB10に登録操作を行なうことが可能である。また、ユーザプログラム580は、クライアント20や社内システム30とのインタフェースを司るとともに、Web系DBアクセス部540やバッチ系DBアクセス部560を制御してDB10にアクセスする。
【0011】
なお、図1に示した各処理部は専用のハードウェアにより実現されるものであってもよく、また、これらの処理部はメモリおよびCPU(中央演算装置)により構成され、各処理部に機能を実現するためのプログラム(図示せず)をメモリにロードして実行することによりその機能を実現させるものであってもよい。また、記憶部(図示せず)は、ハードディスク装置や光ディスク装置、フラッシュメモリなどの不揮発性メモリや、RAM(Random Access Memory)のような揮発性のメモリ、あるいはこれらの組合せにより構成されるものとする。
【0012】
また、図1における各処理部の機能を実現するためのプログラムをコンピュータ読み取り可能な記録媒体に記録して、この記録媒体に記録されたプログラムをコンピュータシステムに読み込ませ、実行することにより各処理部の処理を行ってもよい。なお、ここでいう「コンピュータシステム」とは、OSや周辺機器などのハードウェアを含むものとする。
【0013】
次に、本発明の実施の形態の動作の概要について図1を参照して説明する。図1において、クライアント20や社内システム30からDB10にアクセスする際、DB10にデータを登録する場合には、クライアント20または社内システム30でJDBCまたはSQLローダのいずれを使用するかを指定することにより、ユーザプログラム530は指定されたJDBCまたはSQLローダに対応したWeb系DBアクセス部540またはバッチ系DBアクセス部560のいずれかを選択し、選択したWeb系DBアクセス部540またはバッチ系DBアクセス部560を制御してDB10にアクセスしデータを登録する。また、DB10に対して検索、更新および削除のいずれかを行なう場合には、ユーザプログラム580の制御によりWeb系DBアクセス部540によってJDBCを使ってDB10をアクセスして、検索、更新または削除の処理を行なう。なお、これらの動作の詳細については後述する。
【0014】
次に、図1のWeb系DBアクセス部540、バッチ系DBアクセス部560におけるDBアクセスクラスの自動生成について、図2を参照して説明する。図2において、図1と同一部分には同一符号を付して、その説明を省略する。図2は、DBアクセスクラス自動作成プログラムによってDBアクセスクラスを自動生成する仕組みを示す図である。ここで、DBアクセスクラスとは、DB10をアクセスするために必要な情報であるデータ、テーブル名、データベース操作内容などのデータや制御情報を格納するためのクラスである。
【0015】
図2において、DB10はデータのほかに属性情報11を保持している。属性情報11は、テーブル名、カラム名、データ型といったDB10に格納されているテーブルに関する情報である。510はDBアクセスクラス530を自動生成するために必要な6種類の雛形ファイルから構成される雛形ファイルの総称である。511はDB10の属性情報11のテーブル名に対応したテーブルクラス541を生成するためのテーブルクラス生成用雛型ファイルであり、そのファイルの中にDB10の属性情報11に置換するための置換用文字列が埋め込まれている。512はテーブルコレクションクラス542を生成するためのコレクションクラス生成用雛型ファイルであり、その中に属性情報11に置換するための置換用文字列が埋め込まれている。
【0016】
また、513はテーブルアクセスクラス543を生成するためのテーブルアクセスクラス生成用雛型ファイルであり、その中に属性情報11に置換するための置換用文字列が埋め込まれている。514はSQLローダ実行用クラス561を生成するためのSQLローダ実行用クラス生成用雛型ファイルであり、その中に属性情報11に置換するための置換用文字列が埋め込まれている。515はCTLファイル562を生成するためのCTLファイル生成用雛型ファイルであり、その中に属性情報11に置換するための置換用文字列が埋め込まれている。516は登録データCSVファイル作成用クラス563を生成するための雛型ファイルであり、その中に属性情報11に置換するための置換用文字列が埋め込まれている。
【0017】
そして、520は、雛型ファイル510とDB10より取得するテーブル名、カラム名、データ型といった属性情報11を入力情報として、DBアクセスクラス530の自動生成を行うDBアクセスクラス自動生成プログラムである。DBアクセスクラス530は、Web系DBアクセス部540およびバッチ系DBアクセス部560の各クラスから構成され、DB10にアクセスするために必要な情報を持つ様々なクラスの総称である。
【0018】
JDBCを使用してDB10へのアクセス処理を行うWeb系DBアクセス部540のクラスは、テーブルクラス群541g、テーブルコレクションクラス群542gおよびテーブルアクセスクラス群543gで構成される。ここで、テーブルクラス群541g、テーブルコレクションクラス群542gおよびテーブルアクセスクラス群543gは、それぞれ、DB10のテーブルの数だけテーブルクラス541、テーブルコレクションクラス542、テーブルアクセスクラス543を持つクラスである。
【0019】
テーブルクラス541は、DB10のテーブルに対応したクラスであり、テーブルアクセスクラス543に送るキー項目、更新用データ、登録用データを設定する。テーブルコレクションクラス542は、テーブルクラス541をvector型で複数持つことができ、同じ顔つきをした複数行のデータの扱いを簡単にすることを目的とするクラスである(テーブルクラス541とテーブルコレクションクラス542は特許請求の範囲に記載のテーブルクラスに相当)。テーブルアクセスクラス543は、JDBCを使用してDB10にアクセスするための制御用のクラスである。
【0020】
また、SQLローダを使用してDB10へのアクセス処理を行うバッチ系DBアクセス部560は、SQLローダ実行用クラス群561g、CTLファイル群562gおよび登録データCSVファイル作成用クラス群563gで構成される。ここで、SQLローダ実行用クラス群561g、CTLファイル群562gおよび登録データCSVファイル作成用クラス群563gは、それぞれ、SQLローダ実行用クラス561、CTLファイル562、登録データCSVファイル作成用クラス563をテーブル数だけ備えている。SQLローダ実行用クラス561は、DB10にSQLローダを使用してアクセスするための制御用のクラスである。CTLファイル562は、SQLローダを使用するために必要な設定ファイルである。登録データCSVファイル作成用クラス563は、SQLローダ実行用クラス561に送る登録データをCSVファイルとして作成するための制御用のクラスである。
【0021】
次に、図2を参照してDBアクセスクラスを自動生成する動作について説明する。図2において、まず、DBアクセスクラス自動生成プログラム520は、DB10に接続し(ステップS1)、DB10より属性情報11を取得する(ステップS2)。また、DBアクセスクラス自動生成プログラム520は、テーブルクラス生成用雛型ファイル511を読み込み、テーブルクラス生成用雛形ファイル511の中の置換用文字列をステップS2で取得した属性情報11に置換し、テーブルクラス541を作成する。これを、属性情報11、すなわちテーブルの数だけ繰り返しテーブルクラス群541gを作成する(ステップS3)。このテーブルクラスの作成の詳細については、具体例を用いて後述する。
【0022】
そして、DBアクセスクラス自動生成プログラム520は、同様にして、テーブルコレクションクラス生成用雛型ファイル512、テーブルアクセスクラス生成用雛型ファイル513、SQLローダ実行用クラス生成用雛型ファイル514、CTLファイル生成用雛型ファイル515、登録データCSVファイル作成用クラス生成用雛型ファイル516、および属性情報11をもとに、テーブルコレクションクラス群542g、テーブルアクセスクラス郡543g、SQLローダ実行用クラス群561g、CTLファイル群562g、登録データCSVファイル作成用クラス群563gを作成し(ステップS4〜ステップS8)、DBアクセスクラス530の生成を終了する。
【0023】
次に、図2で説明したDBアクセスクラス自動生成プログラム520によって、テーブルクラス生成用雛形ファイル511からテーブルクラス(ファイル)541を作成した一例を図3、図4に示す。図3はデータベースDB10の属性情報11の取り出しおよびテーブルクラス生成用雛形ファイル511の一例(関連する部分を抜粋)を示す図であり、図4は作成されたテーブルクラス(ファイル)541の一例(関連部分を抜粋)を示す図である。図3に示すテーブルクラス生成用雛形ファイル511の中の置換用文字列の部分がDB10の該当する属性情報11の内容により置換されて図4に示すテーブルクラス(ファイル)541が作成される。
【0024】
例えば、図3の3行目のpublic class Table%TABLE_NAME%{の中のTableは置換用文字列%TABLE_NAME%を属性情報11のテーブル名と置換することを意味しているため、この部分をテーブル名USERに置換し、図4の3行目に示すようにpublic class TableUSER{に変換される。テーブルクラス生成用雛形ファイル511の中の他の置換用文字列の部分についても、同様にして置換され、テーブルクラス(ファイル)541が作成される。また、図2に示したテーブルコレクションクラス542など他のクラスについても、テーブルクラス541の場合と同様にして作成される。
【0025】
次に、DB10へデータを登録する場合の動作について図5を参照して説明する。図5は、クライアント20からDB10にデータを登録する場合の動作の流れを示す図である。図5において、図1または図2と同一部分には同一符号を付して、その説明を省略する。図5において、ユーザプログラム580は、クライアント20から登録するデータを受け取ると(ステップS50)、受け取ったデータをテーブルクラス541に設定する。この際、受け取ったデータが複数行ある場合には、1行分のデータをそれぞれ一つのテーブルクラス541に設定するため、テーブルクラス541は行数分の数だけ設定されることになる(ステップS51)。
【0026】
また、ユーザプログラム580は、設定したテーブルクラス541を全てテーブルコネクションクラス542に設定する(ステップS52)。そして、ユーザプログラム580は、ステップS50でデータとともに受信した、データベースを操作するメソッド(関数)(データベース操作種別)を識別し、その結果をもとに対応するJDBCまたはSQLローダのメソッドをテーブルアクセスクラス543に対してコールする(ステップS53)。コールされたテーブルアクセスクラス543のメソッドは、所定の方法でDB10にデータを登録する(ステップS54)。
【0027】
次に、図5で説明したDB10への登録動作についてさらに詳細に説明する。ここでは、JDBCとSQLローダを使用して、DB10に格納されているテーブル名が「ユーザ」であるテーブルに2つのデータを登録することとする。まず、図6を参照してJDBCを使用してDB10にデータを登録する場合の動作について説明する。図6はJDBCを使用したDBアクセスクラスの方式のイメージを示す図である。図6において、ユーザテーブルクラス541uはDB10の「ユーザ」テーブルに対応したテーブルクラスであり、ユーザテーブルコレクションクラス542uはユーザテーブルクラス541uのコレクションクラスである。
【0028】
図6において、ユーザプログラム580は、クライアント20から受け取ったユーザ番号、名字、名前およびメールアドレスで構成されるユーザ番号11とユーザ番号12の2つのデータをそれぞれユーザテーブルクラス541uの対応するユーザ番号、名字、名前およびメールアドレスの欄に設定し(ステップS61)、設定した2つのユーザテーブルクラス541uを順次、ユーザテーブルコレクションクラス542uに設定する(ステップS62)。また、データの登録を行なうJDBCのメソッドinsertTableUsersをユーザテーブルコレクションクラス542uのオブジェクト名tableUsersを引数としてコールする(ステップS63)。
【0029】
そして、ユーザプログラム580は、コールされたinsertTableUsersメソッドに対応したSQL文を作成するために、引数として受け渡されたオブジェクト名tableUsersのユーザテーブルコレクションクラス542uから対応するユーザテーブルクラス541uを取り出し(ステップS64)、ユーザテーブルクラス541uに設定されている、ユーザ番号、名字、名前およびメールアドレスと対応するテーブル名を作成するSQL文INSERTの所定の箇所に設定し、2つのSQL文を作成する(ステップS65)。この2つのSQL文を用いてDB10にアクセスすることによって、2つのデータがDB10に登録される。
【0030】
次に、図7を参照してSQLローダを使用してDB10にデータを登録する場合の動作について説明する。図7において、図6と同一部分には同一符号を付してある。図7は、SQLローダを使用したDBアクセスクラスの方式のイメージを示す図である。図7において、ユーザプログラム580は、クライアント20から受け取ったユーザ番号、名字、名前およびメールアドレスで構成されるユーザ番号11とユーザ番号12の2つのデータをそれぞれユーザテーブルクラス541uの対応するユーザ番号、名字、名前およびメールアドレスの欄に設定し(ステップS71)、これをユーザテーブルコレクションクラス542uに設定する(ステップS72)。そして、登録を行なうSQLローダのメソッドappendTableUsersをユーザテーブルコレクションクラスのオブジェクト名tableUsersを引数としてコールする(ステップS73)。
【0031】
次に、ユーザプログラム580は、コールされたappendTableUsersメソッドの引数として受け渡されたオブジェクト名tableUsersのユーザテーブルコレクションクラス542uから対応するユーザテーブルクラス541uを取り出し(ステップS74)、ユーザテーブルクラス541uに設定されているユーザ番号、名字、名前およびメールアドレスを用いて、CSVファイルを出力する(ステップS75)。また、ユーザプログラム580は、ユーザテーブルクラス541uを用いてSQLローダコマンドを作成し(ステップS76)、実行する。これにより、CSVファイル内の2つのデータがDB10に登録される。
【0032】
このように、JDBCをコールするためのメソッドinsertTableUser(tableUsers tables)とSQLローダをコールするためのメソッappendTableUsers(tableUsers tables)は、JDBCとSQLローダでメソッドの名前は異なるが、その引数tableUsers tablesは同じになるため、アプリケーション・ソフトウェアの開発やデータベース利用者はJDBCとSQLローダのメソッド名のみを意識すればよい。
【0033】
【発明の効果】
以上説明したように、この発明の請求項1および請求項2によれば、予め生成したテーブルクラスおよびテーブルアクセスクラスを用いて、端末から受信したデータベース操作種別を識別し、そのデータ操作種別に対応したデータベースアクセス方式に準拠したデータベースアクセス形式に受信したデータベース操作種別およびデータを変換し、このデータベースアクセス形式を用いてデータベースにアクセス要求を出すようにした。その結果、同一のインタフェースで複数のデータベースアクセス方式を容易に使い分けることができるようになり、アプリケーション・ソフトウェアなどのソフトウェア開発者の開発作業の負担を軽減することができる。また、データベースの利用者もデータベースを容易に利用できるようになる。さらに、データベースへのアクセスのルールを統一することにより、処理構造がわかりやすくなり、作業効率、保守性を向上することができる。
また、この発明の請求項3によれば、テーブルクラスおよびテーブルアクセスクラスの生成は、データベースのテーブルに対応して予め準備されているテーブルクラス生成用雛形ファイル、およびデータベースアクセス方式に対応して予め準備されているテーブルアクセスクラス生成用雛形ファイルと、データベースに予め格納されている属性情報をもとに自動的に生成するようにした。その結果、テーブル構造に応じて人が手書きでクラス等を定義する手間が無くなり、特に、テーブル数の多いデータベースほど手間を大幅に減らすことができる。
【図面の簡単な説明】
【図1】この発明の一実施形態によるデータベースアクセス方法を適用したシステムの構成を示すブロック図である。
【図2】同実施形態によるDBアクセスクラスの自動生成の仕組みを示す図である。
【図3】同実施形態によるテーブルクラス生成用雛形ファイルの一例を示す図である。
【図4】同実施形態によるテーブルクラス(ファイル)の一例を示す図である。
【図5】同実施形態によるクライアントからデータベースにデータを登録する場合の動作の流れを示す図である。
【図6】同実施形態によるJDBCを使用したDBアクセスクラスの方式のイメージを示す図である。
【図7】同実施形態によるSQLローダを使用したDBアクセスクラスの方式のイメージを示す図である。
【符号の説明】
10…データベース(DB)、20…クライアント、30…社内システム、50…APサーバ(アプリケーションサーバ)、510…雛形ファイル、520…DBアクセスクラス自動生成プログラム、530…DBアクセスクラス、540…Web系DBアクセス部、560…バッチ系DBアクセス部、580…ユーザプログラム
[0001]
TECHNICAL FIELD OF THE INVENTION
The present invention relates to a database access method for enabling access to a database by a plurality of different database access methods using the same interface.
[0002]
[Prior art]
In order to access a database, a database operation procedure that conforms to the rules defined as the database access method to be used must be described. Therefore, for example, when registering a large amount of data in a database, the data is registered in a batch process using an SQL (Structured Query Language) loader that can perform registration processing at high speed. However, when searching or updating a database, it is not possible to use an SQL loader having only a registration function. Therefore, software of another database access method such as JDBC (Java (registered trademark) DataBase Connectivity) is used. To access the database. As described above, in order to access a database using a plurality of different database access methods, a database operation procedure conforming to the format specified by each database access method is described. Had to be used properly.
[0003]
As a result, in conventional database access using a plurality of different database access methods, there are problems in that the development work of application software and the like by software developers becomes complicated and database access is troublesome for database users. there were. In addition, a person must manually define a class or the like according to the table structure of the database, which is troublesome. Note that Patent Document 1 is disclosed as a conventional technique.
[0004]
[Patent Document 1]
JP-A-5-197600
[Problems to be solved by the invention]
The present invention has been made in view of the above problems, and in order to facilitate access to a database using a plurality of different database access methods, a database that is unified with one interface even if the database access method is different. It is an object of the present invention to provide a method for automatically accessing a database and a method for automatically generating a class and a database operation procedure therefor.
[0006]
[Means for Solving the Problems]
SUMMARY OF THE INVENTION The present invention has been made to solve the above problems, and an invention according to claim 1 is a database access method for accessing a database using a plurality of different database access methods, wherein the database is accessed from a terminal. For receiving data and database operation type, identify the received database operation type, the data and the database into a database access format that conforms to a predetermined rule determined by the database access method corresponding to the identified data operation type A database access method comprising converting a database operation type and issuing an access request to the database using the database access format.
[0007]
According to a second aspect of the present invention, in the database access method according to the first aspect, the conversion into the database access format is a table class for storing the received data in the same format as a corresponding table in the database. And a control table access class corresponding to the database access method is generated in advance in association with the database table, the received data is stored in the corresponding table class, and the identified data operation type is stored. The data and the database operation type are converted according to the predetermined rule described in the table access class corresponding to.
[0008]
According to a third aspect of the present invention, in the database access method according to the second aspect, the generation of the table class and the table access class is performed by preparing a table class generating template file corresponding to a table of the database. , And a table access class template file prepared in advance corresponding to the database access method, and attribute information of the database.
[0009]
BEST MODE FOR CARRYING OUT THE INVENTION
Hereinafter, a database access method according to an embodiment of the present invention will be described. Here, a database access method to which the present invention is applied when two types of database access methods (JDBC and SQL loader) are used will be described with reference to FIG. FIG. 1 is a block diagram showing an entire system according to an embodiment in which the present invention is applied to an application server (AP server). In FIG. 1, reference numeral 10 denotes a database (DB) for storing various data. Reference numeral 20 denotes a client (terminal) used when a user accesses the DB 10, and reference numeral 30 denotes an in-house system that performs various processes using the DB 10. Reference numeral 50 denotes an AP server that provides various application services to which the present invention is applied. The AP server 50 includes a Web DB access unit 540 that executes Web (online) functions and a batch DB access unit that executes batch functions. It comprises a unit 560 and a user program 580 (corresponding to a database access unit described in the claims).
[0010]
The Web DB access unit 540 enables all operations of search, update, registration, and deletion for the DB 10 using JDBC. On the other hand, the batch DB access unit 560 enables only the registration operation to the DB 10 using the SQL loader. Therefore, the batch DB access unit 560 can perform a registration operation in the DB 10 faster than the Web DB access unit 540. Further, the user program 580 controls an interface with the client 20 and the in-house system 30, and controls the Web DB access unit 540 and the batch DB access unit 560 to access the DB 10.
[0011]
Each processing unit shown in FIG. 1 may be realized by dedicated hardware, and these processing units are configured by a memory and a CPU (Central Processing Unit). May be implemented by loading a program (not shown) for realizing the function into a memory and executing the program. The storage unit (not shown) includes a nonvolatile memory such as a hard disk device, an optical disk device, or a flash memory, a volatile memory such as a RAM (Random Access Memory), or a combination thereof. I do.
[0012]
Also, a program for realizing the function of each processing unit in FIG. 1 is recorded on a computer-readable recording medium, and the program recorded on this recording medium is read into a computer system and executed, thereby executing each processing unit. May be performed. Here, the “computer system” includes an OS and hardware such as peripheral devices.
[0013]
Next, an outline of the operation of the embodiment of the present invention will be described with reference to FIG. In FIG. 1, when data is registered in the DB 10 when accessing the DB 10 from the client 20 or the in-house system 30, the client 20 or the in-house system 30 specifies whether to use the JDBC or the SQL loader, The user program 530 selects either the Web DB access unit 540 or the batch DB access unit 560 corresponding to the specified JDBC or SQL loader, and selects the selected Web DB access unit 540 or batch DB access unit 560. It controls and accesses the DB 10 to register data. When any of search, update, and delete is performed on the DB 10, the DB 10 is accessed by the Web DB access unit 540 using JDBC under the control of the user program 580 to perform search, update, or delete processing. Perform The details of these operations will be described later.
[0014]
Next, automatic generation of a DB access class in the Web DB access unit 540 and the batch DB access unit 560 in FIG. 1 will be described with reference to FIG. 2, the same parts as those in FIG. 1 are denoted by the same reference numerals, and the description thereof will be omitted. FIG. 2 is a diagram illustrating a mechanism for automatically generating a DB access class by a DB access class automatic creation program. Here, the DB access class is a class for storing data as information necessary for accessing the DB 10, a table name, data such as database operation contents, and control information.
[0015]
In FIG. 2, a DB 10 holds attribute information 11 in addition to data. The attribute information 11 is information on a table stored in the DB 10, such as a table name, a column name, and a data type. Reference numeral 510 is a generic name of template files composed of six types of template files necessary for automatically generating the DB access class 530. Reference numeral 511 denotes a table class generation template file for generating a table class 541 corresponding to the table name of the attribute information 11 of the DB 10, and a replacement character string for replacing the attribute information 11 of the DB 10 in the file. Is embedded. Reference numeral 512 denotes a collection class generation template file for generating the table collection class 542, in which a replacement character string for replacement with the attribute information 11 is embedded.
[0016]
Reference numeral 513 denotes a template file for generating a table access class 543 for generating a table access class 543, in which a replacement character string for replacing the attribute information 11 is embedded. Reference numeral 514 denotes an SQL loader execution class generation template file for generating the SQL loader execution class 561, and a replacement character string for replacement with the attribute information 11 is embedded therein. Reference numeral 515 denotes a CTL file generation template file for generating the CTL file 562, in which a replacement character string for replacement with the attribute information 11 is embedded. Reference numeral 516 denotes a template file for generating a registration data CSV file creation class 563, in which a replacement character string for replacement with the attribute information 11 is embedded.
[0017]
Reference numeral 520 denotes a DB access class automatic generation program for automatically generating the DB access class 530 using the template file 510 and the attribute information 11 such as the table name, column name, and data type acquired from the DB 10 as input information. The DB access class 530 is a generic term for various classes that are configured from the classes of the Web DB access unit 540 and the batch DB access unit 560, and that have information necessary for accessing the DB 10.
[0018]
The classes of the Web DB access unit 540 that performs access processing to the DB 10 using JDBC include a table class group 541g, a table collection class group 542g, and a table access class group 543g. Here, the table class group 541g, the table collection class group 542g, and the table access class group 543g are classes having the same number of table classes 541, table collection classes 542, and table access classes 543 as the number of tables in the DB 10.
[0019]
The table class 541 is a class corresponding to the table of the DB 10 and sets key items, update data, and registration data to be sent to the table access class 543. The table collection class 542 is a class that can have a plurality of table classes 541 in a vector type and is intended to simplify the handling of data of a plurality of rows having the same face (the table class 541 and the table collection class 542). Is equivalent to the table class described in the claims). The table access class 543 is a control class for accessing the DB 10 using JDBC.
[0020]
Further, the batch DB access unit 560 that performs an access process to the DB 10 using the SQL loader includes a SQL loader execution class group 561g, a CTL file group 562g, and a registration data CSV file creation class group 563g. Here, the SQL loader execution class group 561g, the CTL file group 562g, and the registration data CSV file creation class group 563g are a SQL loader execution class 561, a CTL file 562, and a registration data CSV file creation class 563, respectively. We have only number. The SQL loader execution class 561 is a control class for accessing the DB 10 using the SQL loader. The CTL file 562 is a setting file necessary for using the SQL loader. The registration data CSV file creation class 563 is a control class for creating registration data to be sent to the SQL loader execution class 561 as a CSV file.
[0021]
Next, an operation of automatically generating a DB access class will be described with reference to FIG. 2, first, the DB access class automatic generation program 520 connects to the DB 10 (step S1) and acquires the attribute information 11 from the DB 10 (step S2). Further, the DB access class automatic generation program 520 reads the table class generation template file 511 and replaces the replacement character string in the table class generation template file 511 with the attribute information 11 acquired in step S2. Create a class 541. This is repeated for the attribute information 11, that is, the number of tables, to create a table class group 541g (step S3). Details of creation of this table class will be described later using a specific example.
[0022]
The DB access class automatic generation program 520 similarly generates the table collection class generation template file 512, the table access class generation template file 513, the SQL loader execution class generation template file 514, and the CTL file generation. Based on the template file 515, the template file 516 for creating a registration data CSV file, and the attribute information 11, a table collection class group 542g, a table access class group 543g, an SQL loader execution class group 561g, CTL A file group 562g and a registration data CSV file creation class group 563g are created (steps S4 to S8), and the generation of the DB access class 530 ends.
[0023]
Next, FIGS. 3 and 4 show an example in which a table class (file) 541 is created from the table class generation template file 511 by the DB access class automatic generation program 520 described in FIG. FIG. 3 is a diagram showing an example of a template file 511 for extracting the attribute information 11 of the database DB 10 and generating a table class (extracting related portions). FIG. 4 shows an example of a created table class (file) 541 (related). FIG. The replacement character string portion in the table class generation template file 511 shown in FIG. 3 is replaced by the contents of the corresponding attribute information 11 in the DB 10 to create the table class (file) 541 shown in FIG.
[0024]
For example, since “Table” in “public class Table% TABLE_NAME%} on the third line in FIG. 3 indicates that the replacement character string% TABLE_NAME% is to be replaced with the table name of the attribute information 11, this part is replaced with a table. The name is replaced with USER, and as shown in the third line of FIG. 4, it is converted to public class TableUSER. Other replacement character strings in the table class generation template file 511 are similarly replaced, and a table class (file) 541 is created. Further, other classes such as the table collection class 542 shown in FIG. 2 are created in the same manner as the table class 541.
[0025]
Next, an operation for registering data in the DB 10 will be described with reference to FIG. FIG. 5 is a diagram showing a flow of operation when data is registered in the DB 10 from the client 20. 5, the same parts as those in FIG. 1 or FIG. 2 are denoted by the same reference numerals, and description thereof will be omitted. In FIG. 5, upon receiving data to be registered from the client 20 (step S50), the user program 580 sets the received data in the table class 541. At this time, if the received data has a plurality of rows, one row of data is set to one table class 541, and therefore the number of table classes 541 is set to the number of rows (step S51). ).
[0026]
Further, the user program 580 sets all the set table classes 541 to the table connection class 542 (step S52). Then, the user program 580 identifies the method (function) (database operation type) for operating the database, which is received together with the data in step S50, and classifies the corresponding JDBC or SQL loader method into a table access class based on the result. 543 (step S53). The called method of the table access class 543 registers data in the DB 10 by a predetermined method (step S54).
[0027]
Next, the registration operation to the DB 10 described in FIG. 5 will be described in further detail. Here, it is assumed that two data are registered in a table whose table name is “user” stored in the DB 10 using the JDBC and the SQL loader. First, an operation when data is registered in the DB 10 using JDBC will be described with reference to FIG. FIG. 6 is a diagram showing an image of a method of a DB access class using JDBC. In FIG. 6, a user table class 541u is a table class corresponding to the “user” table of the DB 10, and a user table collection class 542u is a collection class of the user table class 541u.
[0028]
In FIG. 6, the user program 580 stores two data of the user number 11 and the user number 12 each composed of the user number, last name, name and mail address received from the client 20, respectively, with the corresponding user number of the user table class 541u, The user table class 541u is set in the user name, name, and mail address fields (step S61), and is sequentially set in the user table collection class 542u (step S62). Also, the JDBC method insertTableUsers for registering data is called with the object name tableUsers of the user table collection class 542u as an argument (step S63).
[0029]
Then, the user program 580 extracts the corresponding user table class 541u from the user table collection class 542u of the object name tableUsers passed as an argument in order to create an SQL statement corresponding to the called insertTableUsers method (step S64). ), A user name, a surname, a name, and a table name corresponding to a mail address set in the user table class 541u are set in predetermined portions of an SQL statement INSERT for creating a table name, and two SQL statements are created (step S65). ). By accessing the DB 10 using these two SQL statements, two data are registered in the DB 10.
[0030]
Next, an operation of registering data in the DB 10 using the SQL loader will be described with reference to FIG. 7, the same parts as those in FIG. 6 are denoted by the same reference numerals. FIG. 7 is a diagram showing an image of a method of the DB access class using the SQL loader. In FIG. 7, the user program 580 stores two data of the user number 11 and the user number 12, which are composed of the user number, last name, name, and mail address received from the client 20, respectively, with the corresponding user number of the user table class 541u, The information is set in the fields of first name, last name, and mail address (step S71), and is set in the user table collection class 542u (step S72). Then, the method "appendTableUsers" of the SQL loader to be registered is called with the object name "tableUsers" of the user table collection class as an argument (step S73).
[0031]
Next, the user program 580 extracts the corresponding user table class 541u from the user table collection class 542u of the object name tableUsers passed as an argument of the called appendTableUsers method (step S74), and is set in the user table class 541u. A CSV file is output using the current user number, last name, first name, and mail address (step S75). Further, the user program 580 creates an SQL loader command using the user table class 541u (Step S76) and executes it. Thereby, the two data in the CSV file are registered in the DB 10.
[0032]
In this way, the method insertTableUser (tableUsers tables) for calling JDBC and the method applicableTableUsers (tableUsers tables) for calling SQL loader are different in the JDBC and SQL loader, but the method where le is the same as the argument sab is the same as the argument sab t sab Therefore, application software developers and database users need only be aware of the JDBC and SQL loader method names.
[0033]
【The invention's effect】
As described above, according to claims 1 and 2 of the present invention, a database operation type received from a terminal is identified using a table class and a table access class generated in advance, and the data operation type corresponding to the database operation type is identified. The received database operation type and data are converted into a database access format conforming to the database access method described above, and an access request is issued to the database using the database access format. As a result, a plurality of database access methods can be easily used properly with the same interface, and the burden of development work of software developers such as application software can be reduced. Also, users of the database can easily use the database. Furthermore, by unifying the rules for accessing the database, the processing structure can be easily understood, and work efficiency and maintainability can be improved.
According to the third aspect of the present invention, the table class and the table access class are generated in advance according to the table class generating template file prepared in advance corresponding to the database table and the database access method. It is automatically generated based on the prepared table access class generation template file and the attribute information stored in the database in advance. As a result, there is no need for a person to manually define a class or the like according to the table structure, and in particular, a database having a large number of tables can greatly reduce the trouble.
[Brief description of the drawings]
FIG. 1 is a block diagram showing a configuration of a system to which a database access method according to an embodiment of the present invention is applied.
FIG. 2 is a diagram showing a mechanism for automatically generating a DB access class according to the embodiment;
FIG. 3 is a view showing an example of a template file for generating table classes according to the embodiment;
FIG. 4 is a diagram showing an example of a table class (file) according to the embodiment.
FIG. 5 is a diagram showing an operation flow when data is registered in a database from a client according to the embodiment.
FIG. 6 is a diagram showing an image of a method of a DB access class using JDBC according to the embodiment.
FIG. 7 is a diagram showing an image of a method of a DB access class using an SQL loader according to the embodiment.
[Explanation of symbols]
Reference Signs List 10: database (DB), 20: client, 30: in-house system, 50: AP server (application server), 510: template file, 520: DB access class automatic generation program, 530: DB access class, 540: Web DB Access unit, 560: Batch DB access unit, 580: User program

Claims (3)

複数の異なるデータベースアクセス方式を用いてデータベースをアクセスするデータベースアクセス方法において、
端末から前記データベースをアクセスするためのデータおよびデータベース操作種別を受信し、前記受信したデータベース操作種別を識別し、前記識別したデータ操作種別に対応したデータベースアクセス方式で定められた所定の規則に準拠したデータベースアクセス形式に前記データおよびデータベース操作種別を変換し、前記データベースアクセス形式を用いて前記データベースにアクセス要求を出すことを特徴とするデータベースアクセス方法。
In a database access method for accessing a database using a plurality of different database access methods,
The terminal receives data and a database operation type for accessing the database from the terminal, identifies the received database operation type, and conforms to a predetermined rule defined by a database access method corresponding to the identified data operation type. A database access method comprising: converting the data and the database operation type into a database access format; and issuing an access request to the database using the database access format.
前記データベースアクセス形式への変換は、前記受信したデータを前記データベースの対応するテーブルと同一形式で格納するためのテーブルクラスおよび前記データベースアクセス方式に対応した制御用のテーブルアクセスクラスを、前記データベースのテーブルに対応付けて予め生成しておき、前記受信したデータを対応する前記テーブルクラスに格納し、前記識別したデータ操作種別に対応した前記テーブルアクセスクラスに記述された前記所定の規則にしたがって前記データおよびデータベース操作種別を変換する
ことを特徴とする請求項1に記載のデータベースアクセス方法。
The conversion to the database access format is performed by storing a table class for storing the received data in the same format as the corresponding table of the database and a table access class for control corresponding to the database access method, Is generated in advance in association with, the received data is stored in the corresponding table class, the data and the data according to the predetermined rule described in the table access class corresponding to the identified data operation type 2. The database access method according to claim 1, wherein a database operation type is converted.
前記テーブルクラスおよびテーブルアクセスクラスの生成は、前記データベースのテーブルに対応して予め準備されているテーブルクラス生成用雛形ファイル、および前記データベースアクセス方式に対応して予め準備されているテーブルアクセスクラス雛形ファイルと、前記データベースの属性情報をもとに生成する
ことを特徴とする請求項2に記載のデータベースアクセス方法。
The generation of the table class and the table access class includes a table class generation template file prepared in advance corresponding to the database table, and a table access class template file prepared in advance corresponding to the database access method. 3. The database access method according to claim 2, wherein the information is generated based on attribute information of the database.
JP2003094791A 2003-03-31 2003-03-31 Data base access method Pending JP2004302840A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2003094791A JP2004302840A (en) 2003-03-31 2003-03-31 Data base access method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2003094791A JP2004302840A (en) 2003-03-31 2003-03-31 Data base access method

Publications (1)

Publication Number Publication Date
JP2004302840A true JP2004302840A (en) 2004-10-28

Family

ID=33407282

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2003094791A Pending JP2004302840A (en) 2003-03-31 2003-03-31 Data base access method

Country Status (1)

Country Link
JP (1) JP2004302840A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2006293796A (en) * 2005-04-13 2006-10-26 Hitachi Software Eng Co Ltd Database migration method
CN111124718A (en) * 2019-12-31 2020-05-08 中国银行股份有限公司 Parameter data acquisition method, parameter data processing method and device and electronic equipment

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2006293796A (en) * 2005-04-13 2006-10-26 Hitachi Software Eng Co Ltd Database migration method
JP4681338B2 (en) * 2005-04-13 2011-05-11 株式会社日立ソリューションズ Database migration method
CN111124718A (en) * 2019-12-31 2020-05-08 中国银行股份有限公司 Parameter data acquisition method, parameter data processing method and device and electronic equipment
CN111124718B (en) * 2019-12-31 2024-04-19 中国银行股份有限公司 Parameter data acquisition method, parameter data processing method, device and electronic equipment

Similar Documents

Publication Publication Date Title
JP3437849B2 (en) Database management system and method for supporting object-oriented programming
US20030093420A1 (en) Method and system for retrieving sharable information using a hierarchically dependent directory structure
US20080098037A1 (en) Markup language based database upgrades
CN111259067B (en) Method, device and equipment for realizing DAO interface based on Spring
CN113204571B (en) SQL execution method and device related to write-in operation and storage medium
US20060015483A1 (en) SQL query enhancement technique
JP2005301985A (en) Information processor, object generation method, object conversion method, object generation program, object conversion program, and recording medium
JP3756407B2 (en) Method for handling user-defined data type data items
US20090171922A1 (en) System and Method for Dynamically Exposing SQL Statements as Web Protocols
JP2003248635A (en) Database accessing method and system in management information base of network management protocol
JP2004302840A (en) Data base access method
EP1881420B1 (en) Mark Up Language Based Database Upgrades
JP3439368B2 (en) Data conversion processing system and recording medium recording program for realizing the function
JP2003280956A (en) Database case device
JP2923917B2 (en) Data access method for large-scale knowledge database system
EP0126123A1 (en) Dynamic data base representation
JP2002132502A (en) Automatic creating system and method of distributed object with interpretation of language function
JP3472454B2 (en) Business program creation support device and program storage medium
JP2785138B2 (en) Genetic methods in large-scale knowledge database systems
JP2004252536A (en) Program development support device
JPH01286020A (en) Program retrieving system
JP2003177923A (en) Reserved word converting method for porting support system
JP2003085013A (en) Pdm system and programming method for system connection
US20180246900A1 (en) File managing method and system thereof for integrated circuit design
JP2000347907A (en) Automatic data file converting device

Legal Events

Date Code Title Description
A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20061024

A02 Decision of refusal

Free format text: JAPANESE INTERMEDIATE CODE: A02

Effective date: 20070417