Tuesday, November 6, 2007

Datalinks in JAVA

Datalinks

A DATALINK value references a file outside of the underlying data source that the
data source manages.

Retrieving References to External Data

A reference to external data being managed by the data source can be retrieved
using the method ResultSet.getURL. The java.net.URL object that is returned
can be used to manipulate the data.

java.net.URL url = rs.getURL(1);

CODE EXAMPLE 16-13 Retrieving a reference to an external data object

In cases where the type of URL returned by the methods getObject or getURL is
not supported by the Java platform, the URL can be retrieved as a String by calling
the method getString.

Storing References to External Data

The method PreparedStatement.setURL can be used to pass a java.net.URL
object to a prepared statement. In cases where the type of URL being set is not
supported by the Java platform, the URL can be stored using the setString
method.

Metadata

The type code DATALINK is defined in the class java.sql.Types. This value is
returned by methods such as DatabaseMetaData.getTypeInfo and
DatabaseMetaData.getColumns when a JDBC driver supports the Datalink
data type or references to external files.

No comments: