How to store and retrieve references to external data
How to store and retrieve references to external data
Date: February 09, 2004
How to store and retrieve references to external
data
After completing this How-to you should be able
to:
Use DATALINK Datatype in a JDBC application.
Reader should be familiar with
To understand this document the readers should
have basic knowledge about JDBC.
Introduction
This document illustrates how to use the datalink datatype to store
and retrieve, references to the external resources.
Description
As part of the changes to the JDBC3.0 specifications,
two new datatypes DATALINK and BOOLEAN have been added. The DATALINK
datatype enables distributed JDBC applications to retrieve and store
references to external data, from and into the database. The newly added
type refer to the SQL type of the same names. DATALINK provides access
to external resources, or URLs. The value of a DATALINK column is retrieved
from an instance of ResultSet using the new getURL() methods.
Methods are added to classes in oracle.jdbc package
to support,
Retrieving references
to external data with a DATALINK.
Storing references
to external data
Obtaining DATALINK related
metadata information.
The following methods are available in java.sql.ResultSet,
public java.net.URL getURL(int columnIndex) throws SQLException;
public java.net.URL getURL(String columnName) throws SQLException;
Methods in java.sql.CallableStatement
public java.net.URL getURL(int parameterIndex) throws SQLException;
public java.net.URL getURL(String parameterName) throws SQLException;
Method in java.sql.PreparedStatement
public void setURL(int parameterIndex,
java.net.URL x) throws SQLException;
To retrieve the all the type codes available in the
java.sql.Types, you can use the following methods from the java.sql.DatabaseMetaData
class,
public java.sql.ResultSet getTypeInfo(...)
public java.sql.ResultSet getColumns(....)
Code Snippet
The code below inserts an HTTP URL object in
to the database using the PreparedStatement.