Oracle8i interMedia Audio, Image, and Video Java Client User's Guide and Reference Release 8.1.5 A67296-01 |
|
The Oracle8i interMedia Audio, Image, and Video Java Client library contains information about the DataSource:
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.
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:
This section presents reference information on the DataSource object type methods. These methods are as follows:
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.
public boolean initCheck( )
public
Checks whether or not the DataSource object is initialized.
None.
This method returns true if the object is initialized; false otherwise.
None.
DataSource dataSource = new DataSource(audioObj); . . . if(dataSource.initCheck( )){ system,out.println("The object is initialized."); }
public void setMediaLocator(String tableName, String columnName, String condition) throws NullPointerException
public
Sets the media locator parameters of the data source.
The name of the table to which the data source will be bound.
The name of the column to which the data source will be bound.
The select condition on the table, used to identify the row to which the data source will be bound.
None.
java.lang.NullPointerException
try{ DataSource dataSource = new DataSource(audioObj); . . . dataSource.setMediaLocator("audioTable", "song", "songID = 3"); } catch(NullPointerException np){ . . . }
where:
public void setConnection(Connection the_connection) throws NullPointerException
public
Sets the connection to the data source.
The connection parameter.
None.
java.lang.NullPointerException
try{ DataSource dataSource = new DataSource(audioObj); . . . dataSource.setConnection(connection); } catch(NullPointerException np){ . . . }
where:
public String getContentType( ) throws SQLException, NullPointerException
public
Gets the content type of the data in the data source (that is, the MIME type of the media data).
None.
This method returns the MIME type or content type of the data in the data source.
java.sql.SQLException
java.lang.NullPointerException
try{ DataSource dataSource = new DataSource(audioObj); . . . String dataStr = dataSource.getContentType( ); } catch(SQLException e){ . . . } catch(NullPointerException np){ . . . }
public int getContentLength( ) throws SQLException, NullPointerException
public
Gets the content length of the server-side media data in the data source.
None.
This method returns the content length of the data in the data source.
java.sql.SQLException
java.lanf.NullPointerException
try{ DataSource dataSource = new DataSource(audioObj); . . . int i = dataSource.getContentLength( ); } catch(SQLException e){ . . . } catch(NullPointerException np){ . . . }
public void getDataInFile(String fileName) throws SQLException, FileNotFoundException, IOException, NullPointerException
public
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.
The file name where the media data will be stored.
None.
java.sql.SQLException
java.io.FileNotFoundException
java.io.IOException
java.lanf.NullPointerException
try{ DataSource dataSource = new DataSource(audioObj); . . . dataSource.getDataInFile("ds.dat"); } catch(SQLException e){ . . . } catch(FileNotFoundException fnf){ . . . } catch(IOException io){ . . . } catch(NullPointerException np){ . . . }
where:
public byte[ ] getData( ) throws SQLException, NullPointerException, OutOfMemoryError
public
Gets the server-side media data as a byte array.
None.
This method returns the media data as a byte array.
java.sql.SQLException
java.lang.NullPointerException
java.lang.OutOfMemoryError
try{ DataSource dataSource = new DataSource(audioObj); . . . byte[ ] mediaData = dataSource.getData( ); } catch(SQLException e){ . . . } catch(NullPointerException np){ . . . }
public InputStream getDataInStream( ) throws SQLException, NullPointerException
public
Returns the server-side media data as an InputStream object.
None.
This method returns the media data as a byte array.
java.sql.SQLException
java.lang.NullPointerException
try{ DataSource dataSource = new DataSource(audioObj); . . . InputStream mediaStream = dataSource.getDataInStream( ); } catch(SQLException e){ . . . } catch(NullPointerException np){ . . . }
public String getSourceInformation( ) throws NullPointerException
public
Returns the corresponding data source type information for the media data in the format protocol://location/name.
None.
This method returns the source information in the format protocol://location/name.
java.lang.NullPointerException
try{ DataSource dataSource = new DataSource(audioObj); . . . String sourceStr = dataSource.getSourceInformation( ); } catch(nullPointerException np){ . . . }
public void setSourceInformation(String srcType, String srcLocation, String srcName) throws NullPointerException
public
Sets the source information attribute in the ORDSource object of the media object, given the source type, location, and name.
The type of the source (FILE or HTTP, for example).
The location of the source.
The name of the source.
None.
java.lang.NullPointerException
try{ DataSource dataSource = new DataSource(audioObj); . . . dataSource.setSourceInformation("HTTP", "directory1", "file"); } catch(NullPointerException np){ . . . }
where:
public boolean loadData(String fileName) throws SQLException, FileNotFoundException, IOException, NullPointerException
public
Loads media data from a given file into a server-side media object designated by the corresponding media locator parameters.
The name of the file from which to load the data.
This method returns true if loading is successful; false otherwise.
java.sql.SQLException
java.io.FileNotFoundException
java.io.IOException
java.lang.NullPointerException
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: