Illustrate jdbc, JAVA Programming

Assignment Help:

 

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


Related Discussions:- Illustrate jdbc

Explain multi dimentional arrays in java, Explain multi dimentional arrays ...

Explain multi dimentional arrays in java? So far all these arrays have been one-dimensional. That is, a single number could locate any value in the array. Therefore sometimes d

Oop, creating a point of sale

creating a point of sale

Create a new project in eclipse , Task 1 Create a new project in Eclips...

Task 1 Create a new project in Eclipse called Assignment 1. Within this project create a package called task01. 1/ Download the class Date (you must use this class - no

Write a java code to explain else if, Write a java code to explain Else If ...

Write a java code to explain Else If ? if statements are not limited to two cases. You can merge an else and an if to form an else if and test a overall range of mutually exclu

How we can changing the implementation, How we can changing the Implementat...

How we can changing the Implementation ? Suppose the Car class requires to be used in a simulation of New York City traffic in that each actual car on the street is represente

Algorithm, #question)i) devising ii) validating and iii) tes...

#question)i) devising ii) validating and iii) testing of algorithms...

Heap and Stack memory allocation in java, Each time an object is started in...

Each time an object is started in Java it goes into the area of memory named as heap. The primitive variables like double and int are allocated in the stack, if they are local inst

What is a final modifier? illustrate other java modifiers?, A final class w...

A final class will not be extended i.e. A final method cannot be overridden when its class is added. You can't modify value of a final variable.

Need remote synchronization tool for folders and files, Need Remote Synchro...

Need Remote Synchronization tool for folders and files? Project Description:                 We want a tool to synchronize the content of one or more folders on the file syst

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd