Intégration avec d'autres applications > Adaptateurs Info*Engine > JDBC Adapter Guide > JDBC Webject Library > Put-Clob-Stream
  
Put-Clob-Stream
Description
Stores character data in an object attribute or table column.
Definition
CLOB is an acronym for Character Large Object. A CLOB column stores single-byte fixed-width character objects such as text documents that must be stored in a database but cannot be interpreted within the database itself.
Syntax
<ie:webject name="Put-Clob-Stream" type="ACT">
<ie:param name="ATTRIBUTE" data="attribute_with_clob_data"/>
<ie:param name="BLOB_COUNT" data="number_of_BLOBs"/>
<ie:param name="CLASS" data="tablename"/>
<ie:param name="CONNECTION_ATTEMPT_INTERVAL" data="interval"/>
<ie:param name="CONNECTION_ATTEMPTS" data="attempts"/>
<ie:param name="DBUSER" data="dbuser_name"/>
<ie:param name="FILENAME" data="local_file_name"/>
<ie:param name="GROUP_OUT" data="group"/>
<ie:param name="INSTANCE" data="instance"/>
<ie:param name="PASSWD" data="dbpassword"/>
<ie:param name="WHERE" data="where_clause"/>
</ie:webject>
Parameters
Required
Select
Optional
ATTRIBUTE
FILENAME
BLOB_COUNT
CLASS
CONNECTION_ATTEMPTS
INSTANCE
CONNECTION_ATTEMPT_INTERVAL
WHERE
DBUSER
GROUP_OUT
PASSWD
ATTRIBUTE
Specifies the attribute or column in the database table in which to store the character data. This parameter is required.
BLOB_COUNT
Specifies how many BLOBs to deliver to the webject. Specifying a value of 0 results in no BLOBs being delivered. Specifying a value of more than 0 results in up to that specified number of BLOBs being delivered. For example, if this parameter is specified with a value of 5, then no more than five BLOBs are delivered to the webject.
The default behavior for this parameter is that all remaining BLOBs are delivered to the webject. This parameter is optional.
CLASS
Identifies the table name in which to store the character data. This parameter is required.
CONNECTION_ATTEMPTS
Defines the maximum number of times to attempt establishing a connection to an adapter before returning an error. The default value is 1. This parameter is optional.
If multiple INSTANCE parameter values are specified, the value of CONNECTION_ATTEMPTS defines the maximum number of times to iterate through the list of adapter instances.
CONNECTION_ATTEMPT_INTERVAL
Defines the amount of time, in seconds, to delay between connection attempts. The default value is 60 seconds. This parameter is optional.
If multiple INSTANCE parameter values are specified, the value of CONNECTION_ATTEMPT_INTERVAL defines the number of seconds to wait between the attempts to iterate through the entire list of adapter instances.
DBUSER
Specifies the name to use when logging in to the data repository. If this parameter is specified in this webject, the webject value takes precedence over any value specified in the credentials mapping settings or in the adapter LDAP entry. If this parameter is not specified here, it must be specified in the credentials mapping settings or in the adapter LDAP entry. For more information about credentials mapping, see the section Credentials Mapping.
FILENAME
Specifies a fully-qualified path for the file in which the character data is to be stored. For additional information on uploading files, see the section Info*Engine User’s Guide. If a file is not uploaded through the browser, then this parameter must be specified.
GROUP_OUT
Identifies the group returned by the webject. This parameter is optional.
INSTANCE
Specifies the name of the adapter that executes the webject. Adapter names are defined when the adapter is configured for use in your Info*Engine environment. This parameter is required.
In order to provide the ability to connect to other adapters if a specific adapter is not available, this parameter can be multi-valued. Info*Engine attempts to connect to the adapters in the order given. If the first adapter specified is not available, the next adapter listed is tried, and so on, until a connection is made. If a connection cannot be established with any listed adapter, an error is returned.
In conjunction with this parameter, you can include two other parameters: CONNECTION_ATTEMPTS and CONNECTION_ATTEMPT_INTERVAL.
PASSWD
Specifies the password to use when logging in to the data repository. If this parameter is specified in this webject, the webject value takes precedence over any value specified in the credentials mapping settings or in the adapter LDAP entry. If this parameter is not specified here, it must be specified in the credentials mapping settings or in the adapter LDAP entry. For more information about credentials mapping, see the section Credentials Mapping.
WHERE
Specifies search criteria for the database table row in which to store the character data. The value for this parameter is specified as an SQL-formatted where clause. This parameter is required.
Example
The following example documents PutClobStream.jsp located in the Windchill installation directory:
codebase/infoengine/jsp/examples/JDBCAdapter/examples
In this example, the UploadClob.jsp file, located in the same examples directory, provides the input form necessary for providing the appropriate parameter values for this example and should be run to execute PutClobStream.jsp.
The input form contains the following fields:
The JDBC Adapter Instance field should specify the INSTANCE parameter value appropriate to your installation.
The Name field specifies the location where the file containing CLOB data is to be stored.
The File field specifies the full path for the file that contains the CLOB data.
The MIME Type field identifies the MIME type. If the input value for this field is uploaded, it can be fetched from the database for the given name while downloading the CLOB content.
When the form is submitted, PutClobStream.jsp is called. The data specified on the form provides the parameter values for the webjects.
<%@page language="java" session="false"
errorPage="IEError.jsp"%>

<%@ taglib uri="http://www.ptc.com/infoengine/taglib/core"
prefix="ie" %>

<html>
<head>
<title> CLOB Upload</title>
</head>
<BODY>
<H2> Upload File</H2>
<form method="POST" action="PutClobStream.jsp">
<TABLE>
<tr>
<td align=right>
<B>JDBC Adapter Instance: </B>
</td>
<td>
<INPUT name="instance" type="text" size=50>
</td>
</tr>
<tr>
<td align=right>
<B>Name: </B>
</td>
<td>

<INPUT name="filename" type="text" size=50>
</td>
</tr>
<tr>
<td align=right>
<B>File: </B>
</td>
<td>
<INPUT name="file" type="text" size=50>
</td>
</tr>
<tr>
<td align=right>
<b>MIME Type:</b>
</td>
<td>
<input name="mimetype" type="text" size=50>
</td>
</tr>
<tr>
<td>
</td>
<td align=left>
<INPUT name="submit" type="submit" value="Submit"
id=button>
</td>
</tr>
</table>
</form>
</body>
</html>
In the following PutClobStream.jsp, the Do-Sql webject creates the location in the CLOBTEST table where the file containing CLOB data is to be placed. This location is based on the value you entered into the Name field of the input form.
The values you specified for the File and MIME Type fields when executing UploadClob.jsp are also inserted into the FILENAME and MIMETYPE table columns. The Put-Clob-Stream webject then puts the file specified in the File field of the input form into the FILECONTENT column of the CLOBTEST table, in the location specified in the Name field.
<%@page language="java" session="false"
errorPage="IEError.jsp"%>

<%@taglib uri="http://www.ptc.com/infoengine/taglib/core"
prefix="ie"%>

<html>
<head><title>Put-Clob-Stream Webject</title>
<BASE>
</head>
<body>
<h1>Put-Clob-Stream Webject:</h1>
<ie:unit>
<ie:webject name="Do-Sql" type="ACT">
<ie:param name="INSTANCE" data="${FORM[]instance[]}"
default="jdbcAdapter" />
<ie:param name="CLASS" data="CLOBTEST"/>
<ie:param name="SQL" data="INSERT INTO CLOBTEST
VALUES('${FORM[]filename[]}',null,'${FORM[]file[]}',${F
ORM[]mimetype[]})"/>
<ie:param name="GROUP_OUT" data="temp" />
</ie:webject>
<ie:failure>
<!-- No failure processing -->
</ie:failure>
</ie:unit>
<ie:webject name="Put-Clob-Stream" type="ACT">
<ie:param name="INSTANCE" data="${FORM[]instance[]}"
default="jdbcAdapter"/>
<ie:param name="ATTRIBUTE" data="FILECONTENT"/>
<ie:param name="CLASS" data="CLOBTEST"/>
<ie:param name="WHERE"
data="NAME='${FORM[]filename[]}'"/>
<ie:param name="FILENAME" data="${FORM[]file[]}"/>
<ie:param name="GROUP_OUT" data="PutClob"/>
</ie:webject>
<%
String file = request.getParameter ("file");
%>
<b><i><%=file %></i> Uploaded to Database</b>
</body>
</html>