2008. 6. 28. 14:19

Connector/ODBC Examples

23.1.5. Connector/ODBC Examples

Once you have configured a DSN to provide access to a database, how you access and use that connection is dependent on the application or programming language. As ODBC is a standardized interface, any application or language that supports ODBC can use the DSN and connect to the configured database.

23.1.5.1. Basic Connector/ODBC Application Steps

Interacting with a MySQL server from an applications using the Connector/ODBC typically involves the following operations:

  • Configure the Connector/ODBC DSN

  • Connect to MySQL server

  • Initialization operations

  • Execute SQL statements

  • Retrieve results

  • Perform Transactions

  • Disconnect from the server

Most applications use some variation of these steps. The basic application steps are shown in the following diagram:

사용자 삽입 이미지

23.1.5.2. Step-by-step Guide to Connecting to a MySQL Database through Connector/ODBC

A typical installation situation where you would install Connector/ODBC is when you want to access a database on a Linux or Unix host from a Windows machine.

As an example of the process required to set up access between two machines, the steps below take you through the basic steps. These instructions assume that you want to connect to system ALPHA from system BETA with a username and password of myuser and mypassword.

On system ALPHA (the MySQL server) follow these steps:

  1. Start the MySQL server.

  2. Use GRANT to set up an account with a username of myuser that can connect from system BETA using a password of myuser to the database test:

    GRANT ALL ON test.* to 'myuser'@'BETA' IDENTIFIED BY 'mypassword';

    For more information about MySQL privileges, refer to Section 5.5, “MySQL User Account Management”.

On system BETA (the Connector/ODBC client), follow these steps:

  1. Configure a Connector/ODBC DSN using parameters that match the server, database and authentication information that you have just configured on system ALPHA.

    Parameter Value Comment
    DSN remote_test A name to identify the connection.
    SERVER ALPHA The address of the remote server.
    DATABASE test The name of the default database.
    USER myuser The username configured for access to this database.
    PASSWORD mypassword The password for myuser.
  2. Using an ODBC-capable application, such as Microsoft Office, connect to the MySQL server using the DSN you have just created. If the connection fails, use tracing to examine the connection process. See Section 23.1.4.8, “Getting an ODBC Trace File”, for more information.

23.1.5.3. Connector/ODBC and Third-Party ODBC Tools

Once you have configured your Connector/ODBC DSN, you can access your MySQL database through any application that supports the ODBC interface, including programming languages and third-party applications. This section contains guides and help on using Connector/ODBC with various ODBC-compatible tools and applications, including Microsoft Word, Microsoft Excel and Adobe/Macromedia ColdFusion.

Connector/ODBC has been tested with the following applications:

Publisher Application Notes
Adobe ColdFusion Formerly Macromedia ColdFusion
Borland C++ Builder  
  Builder 4  
  Delphi  
Business Objects Crystal Reports  
Claris Filemaker Pro  
Corel Paradox  
Computer Associates Visual Objects Also known as CAVO
  AllFusion ERwin Data Modeler  
Gupta Team Developer Previously known as Centura Team Developer; Gupta SQL/Windows
Gensym G2-ODBC Bridge  
Inline iHTML  
Lotus Notes Versions 4.5 and 4.6
Microsoft Access  
  Excel  
  Visio Enterprise  
  Visual C++  
  Visual Basic  
  ODBC.NET Using C#, Visual Basic, C++
  FoxPro  
  Visual Interdev  
OpenOffice.org OpenOffice.org  
Perl DBD::ODBC  
Pervasive Software DataJunction  
Sambar Technologies Sambar Server  
SPSS SPSS  
SoftVelocity Clarion  
SQLExpress SQLExpress for Xbase++  
Sun StarOffice  
SunSystems Vision  
Sybase PowerBuilder  
  PowerDesigner  
theKompany.com Data Architect  

If you know of any other applications that work with Connector/ODBC, please send mail to about them.

출처 : MySQA 5.0 Reference Manual