Go to the first, previous, next, last section, table of contents.


16 MySQL ODBC Support

MySQLMyODBC プログラムで ODBC 機能を提供します。

16.1 Operating systems supported by MyODBC

MyODBC は Windows95 と NT の 32ビット ODBC (2.50) level 0 ドライバです。我々は誰かがこれを Windows 3.x へ移植するのを希望します。

16.2 MyODBCでの問題をどのように報告すべきか?

MyODBC は以下でテストされました: Access, Admndemo.exe, C++-Builder, Centura Team Developer (formerly Gupta SQL/Windows), ColdFusion (on Solaris and NT with svc pack 5), Crystal Reports, DataJunction, Delphi, ERwin, Excel, iHTML, FileMaker Pro, FoxPro, Notes 4.5/4.6, SBSS, Perl DBD-ODBC, Paradox, Powerbuilder, Powerdesigner 32 bit, VC++ and Visual Basic.

MyODBC で動作する他のアプリケーションについても知っているなら、 myodbc@lists.mysql.com までメールをください!

16.3 MyODBCで動作することが知られているプログラム

多くのプログラムが MyODBC で動作します。これらは我々自身がテストしたか、 または何人かの他のユーザから動作するという確証を得たものです:

Program
Comment
Access
Access を動作させるには:
アクセスは、MySQL が理解できない間違った SQL クエリを 作成するかもしれません。 これはアクセスのメニューから "Query|SQLSpecific|Pass-Through" を選択すれば 直すことが可能です。
DataJunction
You have to change it to output VARCHAR rather than ENUM, as it exports the latter in a manner that causes MySQL grief.
Excel
動作。Some tips:
odbcadmin
ODBC のテストプログラム.
Delphi
DBE 3.2 以上を必ず使用してください。 MySQL に接続する際には、'Don't optimize column width' オプションをセットします。 ODBCエントリとBDEエントリの両方をセットアップするおりに役に立つであろう delphi のコード例を示します ( BDE は Delphi Super Page から無償で得られる BDE Alias Editor が必要です)。 : (Thanks to Bryan Brunton bryan@flesherfab.com for this)
fReg:= TRegistry.Create;
  fReg.OpenKey('\Software\ODBC\ODBC.INI\DocumentsFab', True);
  fReg.WriteString('Database', 'Documents');
  fReg.WriteString('Description', ' ');
  fReg.WriteString('Driver', 'C:\WINNT\System32\myodbc.dll');
  fReg.WriteString('Flag', '1');
  fReg.WriteString('Password', '');
  fReg.WriteString('Port', ' ');
  fReg.WriteString('Server', 'xmark');
  fReg.WriteString('User', 'winuser');
  fReg.OpenKey('\Software\ODBC\ODBC.INI\ODBC Data Sources', True);
  fReg.WriteString('DocumentsFab', 'MySQL');
  fReg.CloseKey;
  fReg.Free;

  Memo1.Lines.Add('DATABASE NAME=');
  Memo1.Lines.Add('USER NAME=');
  Memo1.Lines.Add('ODBC DSN=DocumentsFab');
  Memo1.Lines.Add('OPEN MODE=READ/WRITE');
  Memo1.Lines.Add('BATCH COUNT=200');
  Memo1.Lines.Add('LANGDRIVER=');
  Memo1.Lines.Add('MAX ROWS=-1');
  Memo1.Lines.Add('SCHEMA CACHE DIR=');
  Memo1.Lines.Add('SCHEMA CACHE SIZE=8');
  Memo1.Lines.Add('SCHEMA CACHE TIME=-1');
  Memo1.Lines.Add('SQLPASSTHRU MODE=SHARED AUTOCOMMIT');
  Memo1.Lines.Add('SQLQRYMODE=');
  Memo1.Lines.Add('ENABLE SCHEMA CACHE=FALSE');
  Memo1.Lines.Add('ENABLE BCD=FALSE');
  Memo1.Lines.Add('ROWSET SIZE=20');
  Memo1.Lines.Add('BLOBS TO CACHE=64');
  Memo1.Lines.Add('BLOB SIZE=32');

  AliasEditor.Add('DocumentsFab','MySQL',Memo1.Lines);
C++Builder
BDE 3.0で,テストされました。唯一の知られた問題は、 テーブルスキーマが変化する時、クエリフィールドが更新されないことです。 BDE は、index PRIMARY だけを認識し、プライマリーキーは認識していないように思えます。これはさほど問題ではないですが。
Visual basic
テーブルの更新を可能にするため、テーブルにプライマリーキーを作成しなくてはなりません。

16.4 ODBC 管理プログラムの各種項目を埋めるには?

Windows95 上のサーバ名の記述には3つの可能性があります:

``ODBC setup''を埋める方法の例:

Windows DSN name:   test
Description:        This is my test database
MySql Database:     test
Server:             194.216.84.21
User:               monty
Password:           my_password
Port:

Windows DSN name フィールドの値は、あなたのwindows ODBC setup における 一意の名前です。

ODBC setup 画面で、Server, User, Password, Port フィールドを設定する必要はありません。 しかし、ここで設定をすると、後でサーバーに接続する際に、設定した値がデフォルト値として使用されます。 使用時に値を変更するオプションはあります。

ポート番号が設定されていないなら、デフォルトポート (3306) が使用されます。

もしオプションを Read options from C:\my.cnf にすると, clientodbc グループは `C:\my.cnf' ファイルから読まれます。 mysql_options() で使用できる全てのオプションが利用可能です。 「20.4.37 mysql_options()」節参照.

16.5 AUTO_INCREMENT 項目の値を ODBC で得る方法

共通の問題は、INSERT で自動的に生成されるIDの値を得ることです。 ODBCでは、以下のようにします( 例中の autoAUTO_INCREMENT 項目です):

INSERT INTO foo (auto,text) VALUES(NULL,'text');
SELECT LAST_INSERT_ID();

もしくは、他のテーブルにIDを挿入するだけなら以下のようにします:

INSERT INTO foo (auto,text) VALUES(NULL,'text');
INSERT INTO foo2 (id,text) VALUES(LAST_INSERT_ID(),'text');

いくつかのODBCアプリケーション(少なくともDelphiとAccess)は、 新しく挿入された行を見つけるのに、以下のクエリが使用できます:

SELECT * FROM tbl_name WHERE auto IS NULL;

16.6 Reporting problems with MyODBC

もし問題にあたった場合、ODBC マネージャのログファイル(ODBCADMIN からリクエストしたときのログ) と MyODBC のログがほしいです。 これはいかなる問題にも解決の糸口になるはずです。 MyODBC ログを取るには、 MyODBC connect/configure 画面の 'Trace MyODBC' オプションをチェックします。 ログは `C:\myodbc.log' に書き出されます。 このオプションを使用するに当たり、 MYSQL2.DLL ではなく、 MYSQL.DLL を使用しなくてはなりません!

Check the queries that MyODBC sends to the MySQL server; You should be able to find this by searching after the string >mysql_real_query in the `myodbc.log' file.

You should also try duplicating the queries in the mysql monitor or admndemo to find out if the error is MyODBC or MySQL.

If you find out something is wrong, please only send the relevant rows (max 40 rows) to the myodbc@lists.mysql.com. Please never send the whole MyODBC or ODBC log file !

If you are unable to find out what's wrong, the last option is to to make a archive (tar or zip) that contains a MyODBC log file, the ODBC log file and a README file that explains the problem. You can send this to ftp://www.mysql.com/pub/mysql/secret. Only we at TCX will have access to the files you upload and we will be very discrete with the data!

If you can create a program that also shows this problem, please upload this too!

If the program works with some other SQL server, you should make a ODBC log file where you do exactly the same thing in the other SQL server.

Remember that the more information you can supply to us, the more likely it is that we can fix the problem!


Go to the first, previous, next, last section, table of contents.