Hi Using the manager to get the connection is hard code way and using jndi gives you the ability to change the connection properties in deployment . using manager make you coupled within the connection you made , and in using jndi you are not. another thing : I used jndi and datasources while i need the conection to be managed by container and i need connection pooling. I think its another benefits of using container managed (jndi based) connection management than plain jdbc one. hope it helps
Hi, Obtaining the Connection from JNDI: 1)That Connection is a Dynamic connection. 2)In JNDI we defined some connection previously (Connectionpool) from here we are obtaining the predefined connection. 3)High performance. Obtaining the Connection from DriverManger: 1) Is a static connection. 2) We can create our own connection object here. 3)Poor performance for this connection. Hope that some how cleare. Regards, G Sirish Reddy.,
No password is needed to get a Connection as the password is supplied on creation of the connection pool on server startup. Each instance in the pool will maintain a connection to the DB. When you look up a data source via JNDI and access a database connection, you get a stub for the Connection instance in the server process.
Sri, Welcome to JavaRanch! Note that it is ok to ask a new question in a new thread. No need to bump old threads.
Using JNDI to get the datasource allows you to keep all the datasource's information on the server. In this way, it is completely independent of the code. You just change the properties through the server's interface and the code doesn't even have to know that it changed.