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 subclasses and polymorphism, Explain Subclasses and Polymorphism ? ...

Explain Subclasses and Polymorphism ? Car and Motorcycle are subclasses of MotorVehicle. If you instantiate a Car or a Motorcycle along with new, you can use in which object a

Package diagrams , To simplify complex class diagrams you may group classes...

To simplify complex class diagrams you may group classes into packages.

Carbon Footprint Applications, 10.13 (CarbonFootprint Interface: Polymorphi...

10.13 (CarbonFootprint Interface: Polymorphism) Using interfaces, as you learned in this chapter, you can specify similar behaviors for possibly disparate classes. Governments and

Write a program of else statement in java, Write a program of else statemen...

Write a program of else statement in java? The else statement in Java // This is the Hello program in Java class Hello { public static void main (String args[]) { if (

Design and implement online food delivery system, You are required to desig...

You are required to design & implement online food delivery system using Java RMI technology. This involves writing both the server and the client program(s). Client programs can u

Explain data entry issues, Explain data entry issues? DATA ENTRY: The...

Explain data entry issues? DATA ENTRY: There is new data entered every day. New customers are added every day. Some of the data entry needs the manual entry within computer s

Point of Sale Terminal, The problem statement is pretty simple. We need a s...

The problem statement is pretty simple. We need a software implementation of a Point of Sale terminal at a typical store. The users of the system are the cashiers sitting at the sa

How jms is different from rpc, In RPC the method invoker waits for the meth...

In RPC the method invoker waits for the method to finish implementation and return the control back to the invoker. Therefore it is completely synchronous in nature. Whereas in JMS

Explain primitive data types in java, Explain primitive data types in java?...

Explain primitive data types in java? Java's primitive data types are extremely similar to those of C. They involve boolean, byte, short, long, int, float, double, and char. Th

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