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

Program to find prime number from linked list, For this assignment you are ...

For this assignment you are provided with a class called LNode which can be used as a list node for a linked list of ints. You are also provided with an abstract class called LList

How can you define a consistent web design, How can you define a consistent...

How can you define a consistent web design? Why is it needed? A consistent excellent designed website is generated for common public which permits users to attain what they nee

What is multiple inheritance, What is Multiple Inheritance ? A few obje...

What is Multiple Inheritance ? A few object oriented languages, notably C++, permits a class to inherit from more than one unrelated class. This is known as multiple inheritanc

Spring MVC Controllers, I want to upload an item object with it''s image is...

I want to upload an item object with it''s image is it possible that i pass a complete object of my Item along with it''s image from my Controller if yes then how may i Do it? an

List down the analytical engine''s elements name, List down the Analytical ...

List down the Analytical Engine's elements name An analytical engine elements are as follows: Input Memory Processor Output.

Convert US Dollars to Canadian Dollars, How to write a program that convert...

How to write a program that converts US dollars into Canadian dollars.The program let the user enter an amount in US dollars and display it equivalent value in Canadian dollars whe

Pogram must work on all realms and all ladders, Project Description: The...

Project Description: The program must work on all realms, all ladders, all cores (4x realms,2x ladders,2x cores) The program must be unpatchable and undetectable If patche

What is the use of throws keyword, What is the use of throws keyword ? ...

What is the use of throws keyword ? Rather than explicitly catching an exception you can declare in which your method throws the exception. This passes the repsonsibility to h

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