Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ODBC vs JDBC performance

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 ?

like image 572
user3213918 Avatar asked Feb 15 '14 08:02

user3213918


People also ask

Is ODBC faster than JDBC?

ODBC drivers are implemented in native languages like C/C++. JDBC drivers are implemented in Java. ODBC drivers are faster. JDBC drivers are slower than ODBC drivers.

Should I use ODBC or JDBC?

Conclusion. Both JDBC and ODBC are used from an application on the client side to access different types of database on the server side. If you want to platform and language independent then use ODBC else if you are working on Java platform then use JDBC.

Why we use JDBC instead of ODBC?

We can Use JDBC in any platform. Mostly ODBC Driver developed in native languages like C,C++. JDBC Stands for java database connectivity. For Java applications it is not recommended to use ODBC because performance will be down due to internal conversion and applications will become platform Dependent.

Is ODBC slower?

Microsoft's testing has shown that the performance of ODBC-based and DB-Library–based SQL Server applications is roughly equal. According to Oracle, their ODBC driver, on average, runs only about 3% slower than native Oracle access. But their ODBC driver may not be yours, and your mileage will vary.


2 Answers

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.
like image 88
Dennis Jaheruddin Avatar answered Sep 19 '22 15:09

Dennis Jaheruddin


The following points may help:

Multithread: - JDBC is multi-threaded - ODBC is not multi-threaded (at least not thread safe)

Flexibility: - ODBC is a windows-specific technology - JDBC is specific to Java, and is therefore supported on whatever OS supports Java

Power : you can do everything with JDBC that you can do with ODBC, on any platform.

Language: - ODBC is procedural and language independent - JDBC is object oriented and language dependent (specific to java).

Heavy load: - JDBC is faster - ODBC is slower

ODBC limitation: it is a relational API and can only work with data types that can be expressed in rectangular or two-dimensional format. (it will not work with data types like Oracle’s spatial data type)

API: JDBC API is a natural Java Interface and is built on ODBC, and therefore JDBC retains some of the basic feature of ODBC

like image 34
soulemane moumie Avatar answered Sep 20 '22 15:09

soulemane moumie