Illustrate jdbc, JAVA Programming


JDBC stands for Java Database Connectivity:

It is an API which gives easy connection to a wide range of databases. To connect to a database we have to load the appropriate driver and then request for a connection object. The Class.forName(....) will prepare the driver and register it with the DriverManager.

Class.forName("oracle.jdbc.driver.OracleDriver"); //dynamic class loading

String url = jdbc:oracle:thin:@hostname:1526:myDB;

Connection myConnection = DriverManager.getConnection(url, "username", "password");


The DataSource interface gives an alternative to the DriverManager for building a connection. DataSource builds the code more portable than DriverManager because it works with JNDI and it is prepared, managed and deployed separately from the application that uses it. If the DataSource location modifies, then there is no need to modify the code but change the configuration properties in the server. This gives your application code easier to maintain. DataSource allows the need of connection pooling and support for distributed transactions. A DataSource is not only a database but also may be a spreadsheet or a file. A DataSource object may be bound to JNDI and an application can find and use it to prepare a connection to the database. J2EE application servers give tools to describe your DataSource with a JNDI name. When the server initialize it loads all the DataSources into the application server's JNDI service.

DataSource configuration properties are given below:

1. JNDI Name  jdbc/myDataSource

2. URL jdbc:oracle:thin:@hostname:1526:myDB

3. Password, serName

4. Implementation classname  oracle.jdbc.pool.OracleConnectionPoolDataSource

5. Classpath  ora_jdbc.jar

6. Connection pooling settings as illustrate maximum pool size, minimum pool size, connection timeout, statement cache size etc.

Once the DataSource has been set up, then you may get the connection object as given:

Context ctx = new InitialContext();

DataSource ds = (DataSource)ctx.lookup("jdbc/myDataSource"); Connection myConnection = ds.getConnection("username","password");




1995_Illustrate JDBC.png

Posted Date: 7/26/2012 6:42:46 AM | Location : United States

Related Discussions:- Illustrate jdbc, Assignment Help, Ask Question on Illustrate jdbc, Get Answer, Expert's Help, Illustrate jdbc Discussions

Write discussion on Illustrate jdbc
Your posts are moderated
Related Questions

Purpose Demonstrate your ability to ability to use Java data and control structures. Draw with the aid of conditionals and loops. Background Thought A note on comments:

A socket is one end-point of a two-way communication link among two programs running on the network. A socket is bound to a port number so that the TCP layer can recognize the appl

How are this () and super() used with constructors? this() Constructors: is used to pointing current class instance. Can be used with methods or variables. Used to call

EJB 2.0 has the additional advantages over the EJB 1.1 given below 1. Local interfaces : These are beans that can be needed locally, that means by the same Java Virtual Machi

A BeanFactory is like a factory class that having a collection of beans. The BeanFactory holds Bean Definitions of multiple beans within itself and then instantiates the bean whene

Ten pigs were all in a pen, enjoying their morning slop when a bird flew down from a nearby tree and began picking all the best bits out from the trough. This greatly perturbed the

I need Java Web Applications Development Project Description: MySQL databases, Oracle. SVN, GIT team collaborations. Skills required: Java, SQL, Software Architectur