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

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.

主站蜘蛛池模板: 绍兴市| 西宁市| 洪雅县| 高雄市| 德阳市| 莆田市| 隆尧县| 双牌县| 华安县| 北流市| 竹溪县| 黄冈市| 来凤县| 密云县| 灵石县| 开平市| 静乐县| 鹰潭市| 商南县| 紫云| 建瓯市| 承德市| 突泉县| 文化| 嘉鱼县| 罗江县| 滁州市| 芷江| 上栗县| 东兴市| 金塔县| 陆河县| 南溪县| 琼结县| 通化县| 江山市| 邵阳市| 延安市| 定边县| 广饶县| 西平县|