ODBC vs JDBC performance

user3213918 picture user3213918 · Feb 15, 2014 · Viewed 30.2k times · Source

I have an assignment to use Java and C with MySQL database and compare the results and give reasons as to why such result.

No. of Records  Execution time (ms)
Records     Java     C
100         586      76
500         628      216
2000        733      697
5000        963      1056
10000       1469     2178

As you can see, with less number of records being fetched from the database, C(ODBC) performed better. But as the number of records were increased, Java(JDBC) came out as the winner.

The reason that I thought of is that may be the ODBC drivers load much faster than JDBC but the access speed of JDBC is better than ODBC, hence, such results. However, I am not able to find such reasoning anywhere.

Any suggestions please ?

Answer

Dennis Jaheruddin picture Dennis Jaheruddin · Mar 3, 2016

Statements presented by mathworks website, these appear to be generally applicable.

Deciding Between ODBC and JDBC Drivers

Use native ODBC for:

  • Fastest performance for data imports and exports
  • Memory-intensive data imports and exports

Use JDBC for:

  • Platform independence allowing you to work with any operating system (including Mac and Linux®), driver version, or bitness (32-bit or 64-bit)
  • Using Database Toolbox functions not supported by the native ODBC interface (such as runstoredprocedure)
  • Working with complex or long data types (e.g., LONG, BLOB, text, etc.)

Tip:

  • On Windows systems that support both ODBC and JDBC drivers, pure JDBC drivers and the native ODBC interface provide better connectivity and performance than the JDBC/ODBC bridge.