Reputation: 21329
There are certain things that i don't understand when i am writing a program to query into the database.
In the following 2 lines of code :
Context context = new InitialContext();
DataSource ds = (DataSource)context.lookup("java:comp/env/jdbc/MyDatasource");
What does the first instruction do ? What is context and what is initial context
? I have read the doc but don't understand it.
Then what is a DataSource
?
While working with netbeans I have to make a new file of category JDBCConnectionPool
:
What is a JDBC Connection Pool
and what is a JDBC Resource
?
And what does Steady Pool Size
and Max Pool Size
mean ? What is a pool size ?
Upvotes: 3
Views: 1143
Reputation: 6158
What is context and what is initial context ?
Context
: represents a naming context, which consists of a set of name-to-object bindings. It contains methods for examining and updating these bindings. source
InitialContext
: Is a class, or you can say the starting context for performing naming operations, and this class is implementing the Context
interface and provide the implementation.
mustRead
DataSource ds = (DataSource)context.lookup("java:comp/env/jdbc/MyDatasource");
what is a DataSource:
The above line of code is showing that,You are retrieving a DataSource object by looking up a JNDI location.
JDBCConnectionPool
JDBCConnection Pooling is conceptually same as any other form of object pooling such as String
object pooling. Database connection creation are always expensive because of the overhead of establishing a network connection and initializing a database connection session in the back end database source
JDBC Resource:
Very good example of steady pooling readHere
Upvotes: 2