Connecting JdbcRowSet to Database Servers

This section describes how to connect JdbcRowSet objects to database servers through JDBC drivers.

There are a number of ways you can connect a JdbcRowSet object to a database server through a JDBC driver:

1. Auto-connecting with DriverManager. A JdbcRowSet object is created without a connection object. But you provide a connection URL before executing any SQL statements as shown below:

  JdbcRowSet jrs = new JdbcRowSetImpl();
  jrs.setUrl("connection_url");
  jrs.setCommand("SQL_statement");
  jrs.execute();
  jrs.next();
  String val = jrs.getString(1)

2. Predefined Connection object. A JdbcRowSet object is created with a predefined Connection object. See the sample statements below:

  Connection con = DriverManager.getConnection("connection_url");
  JdbcRowSet jrs = new JdbcRowSetImpl(con);
  jrs.setCommand("SQL_statement");
  jrs.execute();
  jrs.next();
  String val = jrs.getString(1)

3. Predefined ResultSet object. A JdbcRowSet object is created with a predefined ResultSet object. See the sample statements below:

  Connection con = DriverManager.getConnection("connection_url");
  Statement sta = con.createStatement();
  ResultSet res = sta.executeQuery("SQL_statement");
  JdbcRowSet jrs = new JdbcRowSetImpl(res);
  jrs.next();
  String val = jrs.getString(1)

4. DataSource name lookup. A JdbcRowSet object is created without any connection object. But a DataSource name is provided. The JdbcRowSet object will do a JNDI lookup to obtain a DataSource object and create a Connection object when execute() method is called. See the sample statements below:

  JdbcRowSet jrs = new JdbcRowSetImpl();
  jrs.setDataSourceName("DataSource_name");
  jrs.setCommand("SQL_statement");
  jrs.execute();
  jrs.next();
  String val = jrs.getString(1)

Table of Contents

 About This Book

 JDBC (Java Database Connectivity) Introduction

 JDK (Java SE) Installation

 Oracle Express Edition Installation on Windows

 Oracle JDBC Drivers

Oracle - Reference Implementation of JdbcRowSet

 Overview of RowSet Objects

 Installation of JdbcRowSet Reference Implementation

Connecting JdbcRowSet to Database Servers

 Connecting JdbcRowSet with a Connection URL

 Connecting JdbcRowSet with a Predefined Connection Object

 Connecting JdbcRowSet with a Predefined ResultSet Object

 Connecting JdbcRowSet with JNDI Directory Service

 JdbcRowSet Query Statement with Parameters

 Inserting Rows with JdbcRowSet Objects

 Oracle - PreparedStatement

 Oracle - JBDC CallableStatement

 Oracle CLOB (Character Large Object) - TEXT

 Oracle BLOB (Binary Large Object) - BLOB

 Archived Tutorials

 References

 Full Version in PDF/EPUB