Thursday, April 12, 2012

What is the purpose of an ODBC driver when connecting to a MySQL server?

I've been wondering what are the benefits of using an ODBC driver to interface with a MySQL server? What advantage does that have over directly connecting to the server via TCP and firing off your SQL commands directly?



I'm working with a code base written in labVIEW that references a UDL file which references a data source and its associated ODBC driver to handle the connection to the server. I'm not yet convinced its necessary. I can see the benefit of using a driver if you are connecting to Microsoft Access or excel but if your recipient is an SQL server of some type why would you need a middle man to handle your SQL commands?





2 comments:

  1. Why ODBC and not JDBC? Some reasons come to mind in order of helpfulness when using JDBC:

    Standard api to access the results from a query. To iterate over the results and to get the actual values with the appropriate type.
    No need to know how the protocol works to connect to the server. Just use the host, user, password, send the SQL and iterate over the result.
    Abstract out the connection to the database. Changing the database should be simpler.
    Standard way to commit and rollback for transaction based changes.
    In my experience, JDBC is very verbose. You need to write many lines to accomplish simple things. I've found the Spring JDBCTemplate wrapper to be an extremely easy to use alternative for simple stuff.

    ReplyDelete
  2. I have used the ODBC driver 3.51 for connecting to MySQL Community Server 5.1 for some time now. The ODBC driver allows you (on a Windows computer) to add your MySQL connection to the the ODBC data sources list. Now you can reference this data source in many compatible applications. I have been able to use this ODBC connection in VB.Net applications as well as proprietary applications for printing and other functions with ODBC functionality.

    I would say that when coding web or python applications i always use the built in MySQL packages, but if you need to access your data through VB.Net or another proprietary application (like a stand-alone windows app) you probably need to set up a system ODBC data source to access your database. To me the ODBC lets Windows access MySQL easily. Without Windows i don't think you need it.

    ReplyDelete