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 ?
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.
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.
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.
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.
Statements presented by mathworks website, these appear to be generally applicable.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With