官术网_书友最值得收藏!

Chapter 2. Configuring JDBC in Oracle JDeveloper

Oracle JDeveloper is a free Integrated Development Environment (IDE) for modeling, developing, debugging, optimizing, and deploying Java applications. JDeveloper 10g is used to develop J2EE applications comprising the JSPs, EJBs, Struts, Servlets, and the Java classes that may require accessing a database table in the Oracle 10g Database, or a third-party database. Unlike Eclipse, which requires a plugin, JDeveloper has a built-in provision to establish a JDBC connection with a database. JDeveloper is the only Java IDE with an embedded application server, the Oracle Containers for J2EE (OC4J). This database-based web application may run in JDeveloper without requiring a third-party application server. However, JDeveloper also supports third-party application servers. Starting with JDeveloper 11, application developers may point the IDE to an application server instance (or OC4J instance), including third-party application servers that they want to use for testing during development. JDeveloper provides connection pooling for the efficient use of database connections. A database connection may be used in an ADF BC application, or in a JavaEE application.

A database connection in JDeveloper may be configured in the Connections Navigator. A Connections Navigator connection is available as a DataSource registered with a JNDI naming service. The database connection in JDeveloper is a reusable named connection that developers configure once and then use in as many of their projects as they want. Depending on the nature of the project and the database connection, the connection is configured in the bc4j.xcfg file or a JavaEE data source. Here, it is necessary to distinguish between data source and DataSource. A data source is a source of data; for example an RDBMS database is a data source. A DataSource is an interface that represents a factory for JDBC Connection objects. JDeveloper uses the term Data Source or data source to refer to a factory for connections. We will also use the term Data Source or data source to refer to a factory for connections, which in the javax.sql package is represented by the DataSource interface. A DataSource object may be created from a data source registered with the JNDI (Java Naming and Directory) naming service using JNDI lookup. A JDBC Connection object may be obtained from a DataSource object using the getConnection method. As an alternative to configuring a connection in the Connections Navigator a data source may also be specified directly in the data source configuration file data-sources.xml. In this chapter we will discuss the procedure to configure a JDBC connection and a JDBC data source in JDeveloper 10g IDE. We will use the MySQL 5.0 database server and MySQL Connector/J 5.1 JDBC driver, which support the JDBC 4.0 specification. In this chapter you will learn the following:

  • Creating a database connection in JDeveloper Connections Navigator
  • Configuring the Data Source and Connection Pool associated with the connection configured in the Connections Navigator
  • The common JDBC Connection Errors
  • Creating a Connection Pool and Data Source
  • Connecting to a Database from a Web Application
  • The JDBC 4.0 Version of the Web Application

Before we create a JDBC connection and a data source we will discuss connection pooling and DataSource.

主站蜘蛛池模板: 大足县| 廉江市| 荆门市| 南安市| 平乡县| 潞西市| 太和县| 通江县| 宣恩县| 淳化县| 白山市| 白玉县| 六枝特区| 长春市| 阜平县| 屯留县| 鄂托克旗| 沅陵县| 保靖县| 基隆市| 津市市| 凭祥市| 万安县| 衡水市| 佳木斯市| 宁城县| 惠安县| 富顺县| 合水县| 济源市| 达孜县| 开封县| 曲阜市| 马鞍山市| 石景山区| 琼结县| 周宁县| 定结县| 乌审旗| 襄樊市| 应用必备|