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
What is the difference between static and non-static variables? A static variable is associated with the class as a whole rather than with specific instances of a class. Non-st

Project Description: You should give A Working, Sample Android .apk Project and Java source code Original Photoshop PSD that I can edit and customize to fit my needs All S

Question 1 Describe the browser components and its features Question 2 Define in detail the building of webpage Question 3 How to use forms? Describe with an example

Mine craft plug-in Coder Project Description: Some custom plugging for my Mine craft server. Skills required: Java, Editing

Explain Overriding Methods: The Solution The object oriented solution to this problem is to describe a new class, call it SlowCar, that inherits from Car and imposes the additi

Execution Process of Java bytecode JVM are available for almost every operating system. Java bytecode is executed by employing any operating system's JVM. Hence achieve port

Write a program that finds the minimum total number of shelves, including the initial one required for this loading process

The hashCode() and equals() methods have to be very important, when objects implementing these two functions are added to collections. If not implemented or implemented incorre

in java string is a

Add extra Features to exciting Minecraft plugin Project Description: I own a minecraft server and have a minigame plug-in but at the end of the game the map need to regenerat