I just want to understand how the database connection work through datasource.
When we set up data source, we need to provide username/password. However, if you want to retrieve a connection through datasource, we still supply another user name/password.
datasource.getConnection(username,password)
vs
datasource.getConnection();
Why do we do that? is that redundancy?
I hope someone can help me to clarify that.
I do not think so :
this is the code to get a connection via DataSource:
Now here I did not supply the uname/passw when obtaining a connection, as they are already specified in mysql-ds.xml [ my environ jboss , mysql ].
without JNDI:
Please let me know if this helps.