Oracle8i interMedia Audio, Image, and Video Java Client User's Guide and Reference
Release 8.1.5

A67296-01

Library

Product

Contents

Index

Prev Next

8
DataSource Reference Information

The Oracle8i interMedia Audio, Image, and Video Java Client library contains information about the DataSource:

8.1 Object Types

Oracle8i interMedia Audio, Image, and Video Java Client describes the DataSource object type, which contains the interaction of the front end with the database server. Through use of Java Database Connectivity (JDBC), this object type facilitates the storage and retrieval of data from the Oracle database.


DataSource Object Type

The DataSource object type contains the interaction of the front end with the database server and facilitates the storage and retrieval of data from the Oracle database.


Note:

In the following code, the methods begin with public. This indicates that the method can be called by all classes in all packages.  


This object type is defines as follows:

package oracle.ord.media;
import java.io.*;
import java.sql.*;
import oracle.jdbc.driver.*;

public class DataSource {
     OrdMultiMedia mediaObject;
     
     public DataSource (OrdMultiMedia mObject)
     { }
     
     public boolean initCheck( )
     { }
     
     public void setMediaLocator(String tableName, String columnName,
          String condition)
     throws NullPointerException
     { }
     
     public void setConnection(Connection the_connection)
     throws NullPointerException
     { }
     
     public String getContentType( )
     throws SQLException, NullPointerException
     { }
     
     public int getContentLength( )
     throws SQLException, NullPointerException
     { }
     
     public void getDataInFile(String fileName)
     throws SQLException, FileNotFoundException, IOException, 
          NullPointerException
     { }
     
     public byte[ ] getData( )
     throws SQLException, NullPointerException, OutOfMemoryError
     { }
     
     public InputStream getDataInStream( )
     throws SQLException, NullPointerException
     { }
     
     public String getSourceInformation( )
     throws NullPointerException
     { }
     
     public void setSourceInformation(String srcType, String srcLocation,
          String srcName)
     throws NullPointerException
     { }
     
     public boolean loadData(String fileName)
     throws SQLException, FileNotFoundException, IOException, 
          NullPointerException
     { }
}

where the class attribute is defined as:

8.2 Methods

This section presents reference information on the DataSource object type methods. These methods are as follows:

DataSource Methods

8.2.1 DataSource Methods

This section presents reference information on the DataSource methods.

The methods described in this reference chapter show examples based on the instantiation of a DataSource object. For the examples in the following section, assume that file includes the following Java code:

import oracle.ord.media.*;

public class clientProgram{
     public static void main(String[ ] args){
          The code in the examples appears here
     }
}

In each example, the parameter audObj is a previously created ORDAudio object.


initCheck( ) Method

Format

public boolean initCheck( )

Scope

public

Description

Checks whether or not the DataSource object is initialized.

Parameter

None.

Returns

This method returns true if the object is initialized; false otherwise.

Exceptions

None.

Usage

DataSource dataSource = new DataSource(audioObj);
.
.
.
if(dataSource.initCheck( )){
          system,out.println("The object is initialized.");
}

setMediaLocator( ) Method

Format

public void setMediaLocator(String tableName, String columnName,
                            String condition)
throws NullPointerException

Scope

public

Description

Sets the media locator parameters of the data source.

Parameters

tableName

The name of the table to which the data source will be bound.

columnName

The name of the column to which the data source will be bound.

condition

The select condition on the table, used to identify the row to which the data source will be bound.

Returns

None.

Exceptions

java.lang.NullPointerException

Usage

try{
     DataSource dataSource = new DataSource(audioObj);
     .
     .
     .
     dataSource.setMediaLocator("audioTable", "song", "songID = 3");
}
catch(NullPointerException np){
     .
     .
     .
}

where:


setConnection( ) Method

Format

public void setConnection(Connection the_connection)
throws NullPointerException

Scope

public

Description

Sets the connection to the data source.

Parameter

the_connection

The connection parameter.

Returns

None.

Exceptions

java.lang.NullPointerException

Usage

try{
     DataSource dataSource = new DataSource(audioObj);
     .
     .
     .
     dataSource.setConnection(connection);
}
catch(NullPointerException np){
     .
     .
     .
}

where:


getContentType( ) Method

Format

public String getContentType( )
throws SQLException, NullPointerException

Scope

public

Description

Gets the content type of the data in the data source (that is, the MIME type of the media data).

Parameter

None.

Returns

This method returns the MIME type or content type of the data in the data source.

Exceptions

java.sql.SQLException

java.lang.NullPointerException

Usage

try{
     DataSource dataSource = new DataSource(audioObj);
     .
     .
     .
     String dataStr = dataSource.getContentType( );
}
catch(SQLException e){
     .
     .
     .
}
catch(NullPointerException np){
     .
     .
     .
}


getContentLength( ) Method

Format

public int getContentLength( )
throws SQLException, NullPointerException

Scope

public

Description

Gets the content length of the server-side media data in the data source.

Parameter

None.

Returns

This method returns the content length of the data in the data source.

Exceptions

java.sql.SQLException

java.lanf.NullPointerException

Usage

try{
     DataSource dataSource = new DataSource(audioObj);
     .
     .
     .
     int i = dataSource.getContentLength( );
}
catch(SQLException e){
     .
     .
     .
}

catch(NullPointerException np){
     .
     .
     .
}


getDataInFile( ) Method

Format

public void getDataInFile(String fileName)
throws SQLException, FileNotFoundException, IOException, NullPointerException

Scope

public

Description

Places the server-side media data into the file and returns the file name to be passed into the media player.

The file name passed should be without extension; the extension will be automatically added depending on the format.

Parameter

fileName

The file name where the media data will be stored.

Returns

None.

Exceptions

java.sql.SQLException

java.io.FileNotFoundException

java.io.IOException

java.lanf.NullPointerException

Usage

try{
     DataSource dataSource = new DataSource(audioObj);
     .
     .
     .
     dataSource.getDataInFile("ds.dat");
}
catch(SQLException e){
     .
     .
     .
}
catch(FileNotFoundException fnf){
     .
     .
     .
}
catch(IOException io){
     .
     .
     .
}
catch(NullPointerException np){
     .
     .
     .
}

where:


getData( ) Method

Format

public byte[ ] getData( )
throws SQLException, NullPointerException, OutOfMemoryError

Scope

public

Description

Gets the server-side media data as a byte array.

Parameter

None.

Returns

This method returns the media data as a byte array.

Exceptions

java.sql.SQLException

java.lang.NullPointerException

java.lang.OutOfMemoryError

Usage

try{
     DataSource dataSource = new DataSource(audioObj);
     .
     .
     .
     byte[ ] mediaData = dataSource.getData( );
}
catch(SQLException e){
     .
     .
     .
}
catch(NullPointerException np){
     .
     .
     .
}


getDataInStream( ) Method

Format

public InputStream getDataInStream( )
throws SQLException, NullPointerException

Scope

public

Description

Returns the server-side media data as an InputStream object.

Parameter

None.

Returns

This method returns the media data as a byte array.

Exceptions

java.sql.SQLException

java.lang.NullPointerException

Usage

try{
     DataSource dataSource = new DataSource(audioObj);
     .
     .
     .
     InputStream mediaStream = dataSource.getDataInStream( );
}
catch(SQLException e){
     .
     .
     .
}

catch(NullPointerException np){
     .
     .
     .
}


getSourceInformation( ) Method

Format

public String getSourceInformation( )
throws NullPointerException

Scope

public

Description

Returns the corresponding data source type information for the media data in the format protocol://location/name.

Parameter

None.

Returns

This method returns the source information in the format protocol://location/name.

Exceptions

java.lang.NullPointerException

Usage

try{
     DataSource dataSource = new DataSource(audioObj);
     .
     .
     .
     String sourceStr = dataSource.getSourceInformation( );
}
catch(nullPointerException np){
     .
     .
     .
}


setSourceInformation( ) Method

Format

public void setSourceInformation(String srcType, String srcLocation,
                                 String srcName)
throws NullPointerException

Scope

public

Description

Sets the source information attribute in the ORDSource object of the media object, given the source type, location, and name.

Parameters

srcType

The type of the source (FILE or HTTP, for example).

srcLocation

The location of the source.

srcName

The name of the source.

Returns

None.

Exceptions

java.lang.NullPointerException

Usage

try{
     DataSource dataSource = new DataSource(audioObj);
     .
     .
     .
     dataSource.setSourceInformation("HTTP", "directory1", "file");
}
catch(NullPointerException np){
     .
     .
     .
}

where:


loadData( ) Method

Format

public boolean loadData(String fileName)
throws SQLException, FileNotFoundException, IOException, NullPointerException

Scope

public

Description

Loads media data from a given file into a server-side media object designated by the corresponding media locator parameters.

Parameter

fileName

The name of the file from which to load the data.

Returns

This method returns true if loading is successful; false otherwise.

Exceptions

java.sql.SQLException

java.io.FileNotFoundException

java.io.IOException

java.lang.NullPointerException

Usage

try{
     DataSource dataSource = new DataSource(audioObj);
     .
     .
     .
     if(dataSource.loadData("file")){
          system.out.println("Loading is successful");
     }
}
catch(SQLException e){
     .
     .
     .
}
catch(FileNotFoundException fnf){
     .
     .
     .
}
catch(IOException io){
     .
     .
     .
}
catch(NullPointerException np){
     .
     .
     .
}

where:




Prev

Next
Oracle
Copyright © 1999 Oracle Corporation.

All Rights Reserved.

Library

Product

Contents

Index