The connection string properties can be specified in various ways:
-
As name=value properties in the connection URL when you connect by using the DriverManager class.
-
As name=value properties in the Properties parameter of the Connect method in the DriverManager class.
-
As values in the appropriate setter method of the data source of the driver. For example:
datasource.setServerName(value) datasource.setDatabaseName(value)
Property names are case-insensitive, and duplicate property names are resolved in the following order:
-
API arguments (such as user and password)
-
Property collection
-
Last instance in the connection string
In addition, unknown values are allowed for the property names, and their values are not validated by the JDBC driver for case sensitivity.
Synonyms are allowed and are resolved in order, just as are duplicate property names.
The following table lists all the currently available connection string properties for the JDBC driver.
Property | Type | Default | Description |
---|---|---|---|
applicationName |
String [<=128 char] |
null |
The application name, or "Microsoft SQL Server 2005 JDBC Driver" if no name is provided. Used to identify the specific application in various SQL Server profiling and logging tools. |
databaseName, database |
String [<=128 char] |
null |
The name of the database to connect to. If not stated, a connection is made to the default database. |
disableStatementPooling |
boolean ["true"|"false"] |
true |
Only the value "true" is currently supported. If set to "false," an exception will occur. |
failoverPartner |
String [<=128 char] |
null |
The name of the failover server used in a database mirroring configuration. This property is used for an initial connection failure to the principal server; after you make the initial connection, this property is ignored. Must be used in conjunction with database property. |
instanceName |
String [<=128 char] |
null |
The SQL Server 2000 or SQL Server 2005 instance name to connect to. When it is not specified, a connection is made to the default instance. For the case where both the instanceName and port are specified, see the notes for port. |
integratedSecurity |
boolean ["true"|"false"] |
false |
Set to "true" to indicate that Windows credentials will be used by SQL Server to authenticate the user of the application. If "true," the JDBC driver searches the local computer credential cache for credentials that have already been provided at the computer or network logon. If "false," the username and password must be supplied. Note:
This connection property is only supported on Microsoft Windows operating systems.
|
lastUpdateCount |
boolean ["true"|"false"] |
true |
A "true" value only returns the last update count from an SQL statement passed to the server, and it can be used on single SELECT, INSERT, or DELETE statements to ignore additional update counts caused by server triggers. Setting this property to "false" causes all update counts to be returned, including those returned by server triggers. |
lockTimeout |
int |
-1 |
The number of milliseconds to wait before the database reports a lock time-out. The default behavior is to wait indefinitely. If it is specified, this value is the default for all statements on the connection. Note that |
loginTimeout |
int [>=0..65535] |
0 |
The number of seconds the driver should wait before timing out a failed connection. A zero value indicates no time-out value. A non-zero value is the number of seconds the driver should wait before timing out a failed connection. |
packetSize |
int [512..32767] |
4096 |
The network packet size used to communicate with SQL Server, specified in bytes. If this property is set to a value outside the acceptable range, an exception will occur. |
password |
String [<=128 char] |
null |
The database password. |
portNumber, port |
int [>=0..65535] |
1433 |
The port where SQL Server is listening. If the port number is specified in the connection string, no request to sqlbrowser is made. When the port and instanceName are both specified, the connection is made to the specified port. However, the instanceName is validated and an error is thrown if it does not match the port. Important:
We recommend that the port number always be specified, as this is more secure than using sqlbrowser.
|
selectMethod |
String ["direct"|"cursor"] |
direct |
If this property is set to "cursor," a database cursor is created for each query created on the connection for TYPE_FORWARD_ONLY and CONCUR_READ_ONLY cursors. This property is typically required only if the application generates very large result sets that cannot be fully contained in client memory. When this property is set to "cursor," only a limited number of result set rows are retained in client memory. The default behavior is that all result set rows are retained in client memory. This behavior provides the fastest performance when the application is processing all rows. |
sendStringParametersAsUnicode |
boolean ["true"|"false"] |
true |
Set to "false" to specify that prepared parameters for character data are sent as ASCII instead of Unicode. This parameter can improve performance for character data index lookup on non-Unicode, SQL Server 2000, or SQL Server 2005 tables. For example, ASCII row keys can be compared directly without the overhead of conversion from Unicode. For more information, see the Microsoft discussion at |
serverName, server |
String |
null |
The computer running SQL Server. |
userName, user |
String [<=128 char] |
null |
The database user. |
workstationID |
String [<=128 char] |
null |
The workstation ID, or "WSID Not Available" if none is available. Used to identify the specific workstation in various SQL Server profiling and logging tools. |
xopenStates |
boolean ["true"|"false"] |
false |
Set to "true" to specify that the driver returns XOPEN-compliant state codes in exceptions. The default is to return SQL 99 state codes. |