OPENJPA-1248: Add limited support of LOB streaming on SQL Server; wording corrections.

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@895453 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Milosz Tylenda 2010-01-03 17:55:35 +00:00
parent e5d2bd435f
commit c6459391c8
3 changed files with 57 additions and 5 deletions

View File

@ -16,21 +16,27 @@
*/
package org.apache.openjpa.jdbc.sql;
import java.io.InputStream;
import java.io.Reader;
import java.sql.Blob;
import java.sql.Clob;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;
import java.util.Set;
import org.apache.openjpa.jdbc.kernel.JDBCStore;
import org.apache.openjpa.jdbc.kernel.exps.FilterValue;
import org.apache.openjpa.kernel.Filters;
import org.apache.openjpa.jdbc.schema.Column;
import org.apache.openjpa.kernel.Filters;
import org.apache.openjpa.lib.util.Localizer;
import org.apache.openjpa.meta.JavaTypes;
import org.apache.openjpa.util.StoreException;
/**
* Dictionary for MS SQLServer.
* Dictionary for Microsoft SQL Server.
*/
public class SQLServerDictionary extends AbstractSQLServerDictionary {
@ -277,4 +283,38 @@ public class SQLServerDictionary extends AbstractSQLServerDictionary {
}
return recoverable;
}
/**
* Obtain an {@link InputStream} by using {@link ResultSet#getBlob(int)} and
* {@link Blob#getBinaryStream()}.
* Unfortunately this will load entire BLOB into memory.
* The alternative {@link ResultSet#getBinaryStream(int)} provides true streaming but
* the stream can be consumed only as long as {@link ResultSet} is open.
*/
@Override
public InputStream getLOBStream(JDBCStore store, ResultSet rs, int column) throws SQLException {
Blob blob = rs.getBlob(column);
if (blob == null) {
return null;
}
return blob.getBinaryStream();
}
/**
* Obtain a {@link Reader} by using {@link ResultSet#getClob(int)} and
* {@link Clob#getCharacterStream()}.
* Unfortunately this will load entire CLOB into memory.
* The alternative {@link ResultSet#getCharacterStream(int)} provides true streaming but
* the stream can be consumed only as long as {@link ResultSet} is open.
*/
@Override
public Reader getCharacterStream(ResultSet rs, int column) throws SQLException {
Clob clob = rs.getClob(column);
if (clob == null) {
return null;
}
return clob.getCharacterStream();
}
}

View File

@ -2501,7 +2501,7 @@ version is 8.3-603)
</listitem>
<listitem>
<para>
SQLServer 2005
SQL Server 2005
</para>
</listitem>
</itemizedlist>
@ -2825,6 +2825,11 @@ Oracle
PostgreSQL
</para>
</listitem>
<listitem>
<para>
SQL Server
</para>
</listitem>
</itemizedlist>
<para>
See <xref linkend="supported_databases"/> for possible database-specific

View File

@ -863,7 +863,7 @@ Using the Sun JDBC-ODBC bridge to connect is not supported.
</title>
<example id="example_props_sqlserver">
<title>
Example properties for Microsoft SQLServer
Example properties for Microsoft SQL Server
</title>
<programlisting>
openjpa.ConnectionDriverName: com.microsoft.sqlserver.jdbc.SQLServerDriver
@ -937,6 +937,13 @@ generated values with SQL Server you should use GenerationType.IDENTITY,
GenerationType.TABLE, or GenerationType.AUTO.
</para>
</listitem>
<listitem>
<para>
The use of <link linkend="ref_guide_streamsupport">LOB streaming</link> is limited.
When reading LOB data from the database, the Microsoft SQL Server driver will
actually load all the data into memory at the same time.
</para>
</listitem>
</itemizedlist>
</section>
</section>
@ -1062,7 +1069,7 @@ to any value greater than zero will enable streaming result sets.
<para>
The use of <link linkend="ref_guide_streamsupport">LOB streaming</link> is limited.
When reading LOB data from the database, the MySQL JDBC driver will actually
load all the data in memory at the same time.
load all the data into memory at the same time.
</para>
</listitem>
</itemizedlist>