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

Using rmi build robust distributed systems-jdbc odbc, This work assesses th...

This work assesses the following Outcomes: • Build robust, secure distributed systems using advanced programming techniques Use RMI to build a distributed application accessing

Which models are supported by jms, Which models are supported by JMS? Pleas...

Which models are supported by JMS? Please, explain them. Ans) Publish or subscribe (pub/sub). This model permits a client (publisher) to send messages to a JMS topic. These mess

Explain the applet in java, Explain The Applet in java? The reason peo...

Explain The Applet in java? The reason people are excited about Java as more than just another OOP language is because it allows them to write interactive applets on the web.

Java, Write a program called Power that displays the positive powers of 2. ...

Write a program called Power that displays the positive powers of 2. When the user enters the exponent at a prompt, the program displays 2 to that power. The program halts when the

Toward privacy preserving and collusion resistance, Need Toward Privacy Pre...

Need Toward Privacy Preserving and Collusion Resistance in a Location Proof Updating System Project Description: Today's location-sensitive service relies on user's mobile de

List the keywords which are used in java 1.1, List the keywords which are u...

List the keywords which are used in java 1.1? The list of keywords which are used in java 1.1 are given below: Keyword Purpose boole

COMPRE METHOD, Implement the compare method of the following class Rectangl...

Implement the compare method of the following class RectangleComparator. The method compares two rectangles. The method should return: A positive integer if the area of the first r

Define the j2ee best practices to improve performance? , Manage valuable re...

Manage valuable resources recycle and wisely them where possible, serialization cost and minimize network overheads, and optimize all your database functions. 1. Recycle and man

Conversation to html, Conversation to HTML Project Description: We ha...

Conversation to HTML Project Description: We have inner pages to be transformed into html for travel domain. 1. Flight search page for one way and round trip 2. Bus res

I want solution to this question., This assignment is based on the principl...

This assignment is based on the principles of clock consistency and associated drifts in a distributed system. You have to create a simulation, running on a single machine, of a si

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