Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is faster: JDBC or JNDI?

I have two options to configure my application database connection - one is using JDBC, another one is using JNDI. What will be the best option in terms of how fast those connection types work with the database.

I understand those are two different types of database connections using different principles (JDBC is a direct db connection, JNDI is a database connection pool configuration on application server side). But are there other general JDBC/JNDI pros and cons which might be more important than operating speed? If yes, what are they?

like image 950
altern Avatar asked Jul 16 '12 08:07

altern


People also ask

What is the difference between JDBC and JNDI?

JDBC is Java Database Connectivity API, while JNDI is Java Naming and Directory Interface API. The main thing here is that in a JNDI directory you're actually storing a JDBC DataSource, so, you're simply using JDBC to obtain a Connection via JNDI lookup.

Which is the best connection pooling in Java?

There are multiple JDBC frameworks for connection pooling the most popular choices being Tomcat JDBC and HikariCP. Whatever framework you choose it's important to configure the properties correctly, (a big plus of HikariCP is that it offers good defaults for optional configs).

Why JNDI is used in Java?

JNDI, part of the J2EE specification, provides naming and directory functionality for Java applications. Because JNDI is defined independently of any specific naming or directory service implementation, it enables Java applications to access different naming and directory services using a single API.

Which database is best for JDBC?

1. Java Database Connection: JDBC and MySQL [Free Course] This is a free course on Udemy to learn JDBC with MySQL, one of the popular and my favorite database. It also helps because MySQL is free and you can download and install on your machine to practice along the course.


1 Answers

A database connection always uses JDBC. With JNDI you register a datasource in a directory service which can be looked up by its name. Thus JDBC and JNDI are completly different and not interchangeable.

like image 58
stacker Avatar answered Sep 27 '22 20:09

stacker