数据库连接之jtds介绍(待翻译)

2008-02-23 09:38:33来源:互联网 阅读 ()

新老客户大回馈,云服务器低至5折

Getting Started

What are the class names of the Driver, DataSource, ConnectionPoolDataSource and XADataSource implementations?

InterfacejTDS ImplementationJava.sql.Drivernet.sourceforge.jtds.JDBC.Driverjavax.sql.DataSourcenet.sourceforge.jtds.jdbcx.JtdsDataSourcejavax.sql.ConnectionPoolDataSourcenet.sourceforge.jtds.jdbcx.JtdsDataSourcejavax.sql.XADataSourcenet.sourceforge.jtds.jdbcx.JtdsDataSource

^ top ^

What is the URL format used by jTDS?

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:

user (required)
User name to use for login. When using getConnection(String url, String user, String password) it's not required to set this property as it is passed as parameter, but you will have to set it when using getConnection(String url, Properties info) or TdsDataSource.
password (required)
Password to use for login. When using getConnection(String url, String user, String password) it's not required to set this property as it is passed as parameter, but you will have to set it when using getConnection(String url, Properties info) or TdsDataSource.
TDS (default - "8.0" for SQL Server; "5.0" for Sybase)
The version of TDS to be used. TDS (Tabular Data Stream) is the protocol used by Microsoft SQL Server and Sybase to communicate with database clients. jTDS can use TDS 4.2, 5.0, 7.0 and 8.0. Version 4.2 is used by SQL Server 6.5 and Sybase 10. Version 5.0 is used with Sybase 11 onwards. Version 7.0 is used by SQL Server 7.0; this protocol also works with SQL Server 2000. Version 8.0 is used by SQL Server 2000 and SQL Server 2005.
Newer database server versions usually understand older protocol versions. This means that SQL Server 7.0 can be used with TDS 4.2, but the limitations of the protocol apply regardless of the server version (e.g. when using TDS 4.2 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.
Currently jTDS automatically falls back from 8.0 to 7.0 (if used with SQL Server 7.0) and from 5.0 to 4.2 (with Sybase 10) so specifying the value for this parameter is only necessary for SQL Server 6.5.
cachemetadata (default - false)
When used with prepareSQL=3, setting this property to 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)
Very important setting, determines the byte value to character mapping for 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.
domain
Specifies the Windows domain to authenticate in. If present and the user name and password are provided, jTDS uses Windows (NTLM) authentication instead of the usual SQL Server authentication (i.e. the user and password provided are the domain user and password). This allows non-Windows clients to log in to servers which are only configured to accept Windoes authentication.
If the domain 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).

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:最新网站挂qq代码(php,asp,js)

下一篇:Java咖啡馆(11):Java插件技术