MS-SQL-Server/sybase driver options. |
|
For further details about the driver, please refer to the jTDS project page. The properties below must be added to the URL connection string.
The URL format for jTDS is:
jdbc:jtds:<server_type>://<server>[:<port>][/<database>][;<property>=<value>[;...]]
where <server_type> is one of either 'sqlserver'
or 'sybase' (their meaning is quite obvious), <port>
is the port the database server is listening to (default is 1433 for SQL
Server and 7100 for Sybase) and <database> is the database
name -- JDBC term: catalog -- (if not specified, the user's default database
is used). The set of properties supported by jTDS is:
The JTDS driver for MS-SQL-Server/Sybase supports the following options:
TDS (default - "8.0" for SQL Server;
"5.0" for Sybase)VARCHARs are limited to 255 characters). As a conclusion,
you must set this property to "4.2" when connecting
to SQL Server 6.5 or Sybase. You should not set this value to
"7.0" or "8.0") when connecting to any
version of Sybase as these are SQL Server specific protocols. Further, you
should not set this value to "5.0") when connecting
to any version of SQL Server as this is a Sybase specific protocol.cachemetadata (default - false)true will cause the driver to cache column meta data for
SELECT statements. Caching the meta data will reduce the processing
overhead when reusing statements that return small result sets that
have many columns but may lead to unexpected errors if the database
schema changes after the statement has been prepared. Use with care.
Only applicable to SQL Server (there is no prepareSQL=3 mode for
Sybase).
charset (default - the character set the server was installed
with)CHAR/VARCHAR/TEXT values.
Applies for characters from the extended set (codes 128-255). For
NCHAR/NVARCHAR/NTEXT values
doesn't have any effect since these are stored using Unicode.domaindomain parameter is present but no user name and
password are provided, jTDS uses its native Single-Sign-On library
and logs in with the logged Windows user's credentials (for this to
work one would obviously need to be on Windows, logged into a domain,
and also have the SSO library installed -- consult README.SSO in the
distribution on how to do this).instanceappName (default - "jTDS")progName (default - "jTDS")wsid (default - the client host name)macAddress (default - "000000000000")sendStringParametersAsUnicode (default - true)lastUpdateCount (default - true)true only the last update count will be returned by
executeUpdate(). This is useful in case you are updating
or inserting into tables that have triggers (such as replicated tables);
there's no way to make the difference between an update count returned
by a trigger and the actual update count but the actual update count
is always the last as the triggers execute first. If false
all update counts are returned; use getMoreResults() to
loop through them.prepareSQL (default - 3 for SQL Server,
1 for Sybase)| Value | Description |
|---|---|
0 | SQL is sent to the server each time without any preparation, literals are inserted in the SQL (slower) |
1 | Temporary stored procedures are created for each unique SQL statement and parameter combination (faster) |
2 | sp_executesql is used (fast) |
3 | sp_prepare and sp_cursorprepare are used in conjunction with sp_execute and sp_cursorexecute (faster, SQL Server only) |
packetSize (default - 4096 for TDS 7.0/8.0;
512 for TDS 4.2/5.0)tcpNoDelay (default - true)true to enable TCP_NODELAY on the socket;
false to disable it.lobBuffer (default - 32768)Blob data and chars for Clob
data.maxStatements (default - 500)0 will disable statement caching.
A value of Integer.MAX_VALUE (2147483647)
will enable fast caching (uses less memory and has no overhead
associated with removing statements); the cache will never release
any cached statements, so although experience has shown that this is
usually not a problem with most applications, use with care.loginTimeout (default - 0)namedPipe is true and loginTimeout
is non-zero, the value of loginTimeout is used for the retry
timeout when "All pipe instances are busy" error messages are received while
attempting to connect to the server. If namedPipe is
true and loginTimeout is zero (the default), a
value of 20 seconds is used for the named pipe retry timeout.socketTimeout (default - 0)namedPipe (default - false)true, named pipe communication is used to
connect to the database instead of TCP/IP sockets. When the
os.name system property starts with "windows"
(case-insensitive), named pipes (both local and remote) are accessed
through the Windows filesystem by opening a RandomAccessFile
to the path. When the SQL Server and the client are on the same machine,
a named pipe will usually have better performance than TCP/IP sockets
since the network layer is eliminated. Otherwise the
JCIFS library is used. JCIFS
provides a pure Java named pipe implementation and uses NTLM
authentication, so the domain parameter is required.instance parameter (which changes
the named pipe URL), but it does not currently support the named pipe at
a location other than /sql/query on the server. The
port parameter is ignored if set.xaEmulation (default - true)true, emulate XA distributed transaction
support, when set to false use experimental true
distributed transaction support. True distributed transaction support
is only available for SQL Server 2000 and requires the installation
of an external stored procedure in the target server (see the
README.XA file in the distribution for details).ssl (default - off)| Value | Description |
|---|---|
off | SSL is not request or used; this is the default |
request | SSL is requested; if the server does not support it then a plain connection is used |
require | SSL is requested; if the server does not support it then an exception is thrown |
authenticate | Same as require except the server's certificate must be signed by a trusted CA |
batchSize (default - 0 for SQL Server;
1000 for Sybase)useCursors (default - false)Statements per Connection it
is preferable to have server-side cursors instead; these will allow
the driver to request only a limited number of rows at a time
(controllable through the fetchSize property of a
Statement). This means extra request-response cycles,
but less caching by the driver.true. With Sybase a usual forward-only read-only cursor
is created.bufferMaxMemory (default - 1024)Statement gets to buffer at
least <bufferMinPackets> to memory before this
limit is enforced. This means that this limit can and will usually be
exceeded.Statement while another Statement
belonging to the same Connection still hasn't processed all its
results. These situations can be avoided in most cases by setting the
useCursors property, but this will also affect
performance.bufferMinPackets.bufferMinPackets (default - 8)Statement will buffer at least this many
packets before being forced to use a temporary file if the
<bufferMaxMemory> is reached, to ensure good
performance even when one Statement caches a very large
amount of data.Statement while another Statement
belonging to the same Connection still hasn't processed all its
results. These situations can be avoided in most cases by setting the
useCursors property, but this will also affect
performance.bufferMaxMemory.useLOBs (default - true)getObject()) to LOBs or
Java types (String and byte[]). The default
JDBC type constant returned is also controlled by this property:
Types.BLOB for IMAGE and Types.CLOB for
TEXT/NTEXT when true, Types.LONGVARBINARY
for IMAGE and Types.LONGVARCHAR for TEXT/NTEXT when
false.getObject() (e.g. when using JSTL or other frameworks),
as Blob and Clob don't implement
toString() (both because it's not required and because
it can easily lead to OutOfMemoryErrors in unexpected
situations, such as when logging data). The default setting of
true has the advantage that the amount of data that is
cached in memory for a large object can be controlled via the
lobBuffer property; a setting of false will
still use the Blob and Clob implementations
internally but the values will be materialized to memory when
getObject() is called, possibly leading to memory
issues.