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 = RowSetProvider.newFactory().createJdbcRowSet();
  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 excute() 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)

Last update: 2015.

Table of Contents

 About This Book

 JDBC (Java Database Connectivity) Introduction

 JDK (Java SE) Installation

 Installing and Running Java DB - Derby

 Derby (Java DB) JDBC Driver

 Derby (Java DB) JDBC DataSource Objects

 Java DB (Derby) - DML Statements

 Java DB (Derby) - ResultSet Objects of Queries

 Java DB (Derby) - PreparedStatement

 MySQL Installation on Windows

 MySQL JDBC Driver (MySQL Connector/J)

 MySQL - PreparedStatement

MySQL - Reference Implementation of JdbcRowSet

 Overview of RowSet Objects

Connecting JdbcRowSet to Database Servers

 Sun Implementation of JdbcRowSet API

 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

 MySQL - JBDC CallableStatement

 MySQL CLOB (Character Large Object) - TEXT

 MySQL BLOB (Binary Large Object) - BLOB

 Oracle Express Edition Installation on Windows

 Oracle JDBC Drivers

 Oracle - Reference Implementation of JdbcRowSet

 Oracle - PreparedStatement

 Oracle - JBDC CallableStatement

 Oracle CLOB (Character Large Object) - TEXT

 Oracle BLOB (Binary Large Object) - BLOB

 Microsoft SQL Server 2005 Express Edition

 Microsoft JDBC Driver for SQL Server - sqljdbc42.jar

 Microsoft JDBC Driver - Query Statements and Result Sets

 Microsoft JDBC Driver - DatabaseMetaData Object

 Microsoft JDBC Driver - DDL Statements

 Microsoft JDBC Driver - DML Statements

 SQL Server - PreparedStatement

 SQL Server CLOB (Character Large Object) - TEXT

 SQL Server BLOB (Binary Large Object) - BLOB

 JDBC-ODBC Bridge Driver - sun.jdbc.odbc.JdbcOdbcDriver

 JDBC-ODBC Bridge Driver - Flat Text Files

 JDBC-ODBC Bridge Driver - MS Access

 JDBC-ODBC Bridge Driver - MS SQL Server

 Summary of JDBC Drivers and Database Servers

 Additional Tutorial Notes to Be Added

 Outdated Tutorials

 References

 PDF Printing Version