The composition of the SQL Server database connection string

Source: Internet
Author: User
Tags driver manager failover sql server express

DB driver
The following drivers are common:

    • Odbc

ODBC, open Database Connectivity, is an integral part of the database in the Microsoft Open Service Architecture (Wosa,windows Open Services Architecture), which establishes a set of specifications and provides a set of standard APIs (application programming interfaces) for database access. These APIs use SQL to accomplish most of their tasks. ODBC itself also provides support for the SQL language, which allows users to send SQL statements directly to ODBC.

    • OLE DB

OLE DB is a strategic, system-level programming interface for Microsoft that manages data across an organization. OLE DB is an open specification built on top of the ODBC functionality. ODBC is specifically developed for accessing relational databases, and OLE DB is used to access relational and non-relational sources of information, such as host Isam/vsam and hierarchical databases, e-mail and file system storage, text, graphics and geographic data, and custom business objects. OLE DB defines a set of COM interfaces that encapsulate various database management system services and allow the creation of software components to implement those services. OLE DB components include data providers (containing and performing data), data consumer (usage data), and service components (processing and transmitting data, such as query processors and cursor engines). OLE DB interfaces help to integrate components smoothly, so that OLE DB component vendors can quickly deliver high-quality OLE DB components to the market. In addition, OLE DB contains a "bridge" that connects to ODBC, providing consistent support for the various ODBC-relational database drivers that are currently in use.

    • Jdbc

JDBC (Java Data Base Connectivity,java database connection) is a Java API for executing SQL statements that provides unified access to a variety of relational databases, consisting of a set of classes and interfaces written in the Java language. JDBC provides a benchmark to build more advanced tools and interfaces that enable database developers to write database applications, while JDBC is a trademark name.

Comparison

Currently, Microsoft's ODBC API is probably the most widely used programming interface for accessing relational databases. It can connect almost all of the databases on almost any platform. Why doesn't Java use ODBC? The answer to this question is that Java can use ODBC, but it is best to use the Jdbc-odbc Bridge with the help of JDBC, which we'll talk about later. Now the question has become: "Why do I need JDBC"? The answer is obvious: ODBC is not intended to be used directly in Java because it uses the C-language interface. Calling local C code from Java has many drawbacks in terms of security, implementation, robustness, and automatic portability of programs. Literal translation from the ODBC C API to the Java API is undesirable. For example, Java does not have pointers, but ODBC has a wide range of pointers (including a very error-prone pointer "void *"). You can think of JDBC as an ODBC that is transformed into an object-oriented interface, and the object-oriented interface is easier for Java programmers to accept.
ODBC is difficult to learn. It mixes simple and advanced features, and its options are extremely complex even for simple queries. In contrast, JDBC tries to ensure simplicity of simple functionality while allowing advanced functionality when necessary. Enabling the "pure Java" mechanism requires Java APIs such as JDBC. If you use ODBC, you must manually install the ODBC Driver Manager and drivers on each client computer. If you write the JDBC driver completely in Java, the JDBC code can be automatically installed, ported, and secured on all Java platforms, from network computers to mainframes.
In summary, the JDBC API is a natural Java interface for basic SQL abstractions and concepts. It is built on ODBC, not from zero. As a result, programmers familiar with ODBC will find JDBC very easy to use. JDBC retains the basic design features of ODBC; in fact, both interfaces are based on the X/open SQL CLI (call-level interface). The biggest difference between them is that JDBC is based on Java style and benefits and is optimized for ease of use.
Currently, Microsoft has introduced new Api:rdo, ADO, and Ole DB outside of ODBC. These designs are similar in many ways to JDBC, i.e. they are object-oriented database interfaces and are based on classes that can be implemented on ODBC. But in these interfaces, we do not see special features that allow us to choose them instead of ODBC, especially if the ODBC driver has established a better market. They add an ornament to ODBC at best.

Database link String Daquan

SQL Server

    • SQL Native Client ODBC Driver

Standard secure connection
Driver={sql Native Client}; server=myserveraddress; Database=mydatabase; Uid=myusername; Pwd=mypassword;

Connected by a letter
Driver={sql Native Client}; Server=myserveraddress;database=mydatabase; Trusted_connection=yes;
"Integrated Security=sspi" is the same as "Trusted_connection=yes".

Connect to an instance of SQL Server
The expression for the specified server instance is the same as other SQL Server connection strings.
Driver={sql Native Client}; Server=myservername/theinstancename;database=mydatabase; Trusted_connection=yes;

Specify User name and password
Oconn.properties ("Prompt") = adPromptAlways driver={sql Native Client}; Server=myserveraddress;database=mydatabase;

Using Mars (multiple active result sets)
Driver={sql Native Client}; Server=myserveraddress;database=mydatabase; Trusted_connection=yes; Mars_connection=yes;
"Multipleactiveresultsets=true" and "Mars_connection=yes" are the same.
Use ADO 2.0 as a module for Mars. The Mars does not support ADO 1.0 and ADO 1.1.

Verifying network data
Driver={sql Native Client}; Server=myserveraddress;database=mydatabase; Trusted_connection=yes; Encrypt=yes;

Connect to a local SQL Server Express instance using the Attach local database file
Driver={sql Native Client}; server=./sqlexpress; Attachdbfilename=c:/asd/qwe/mydbfile.mdf; Database=dbname; Trusted_connection=yes;
Why do I use the database parameter? If a database with the same name is already attached, SQL Server will not be reattached.

Connect to a local SQL Server Express instance by using a database file in the attached local data folder
Driver={sql Native Client}; server=./sqlexpress; attachdbfilename=| Datadirectory|mydbfile.mdf; Database=dbname; Trusted_connection=yes;
Why do I use the database parameter? If a database with the same name is already attached, SQL Server will not be reattached.

Database Mirroring
Data source=myserveraddress; Failover partner=mymirrorserver;initial catalog=mydatabase;integrated security=true;

    • SQL Native Client OLE DB Provider

Standard connection
PROVIDER=SQLNCLI; server=myserveraddress; Database=mydatabase; Uid=myusername; Pwd=mypassword;

Connected by a letter
PROVIDER=SQLNCLI; server=myserveraddress; Database=mydatabase; Trusted_connection=yes;

Connecting to an instance of SQL Server
The expression for the specified server instance is the same as other SQL Server connection strings.
PROVIDER=SQLNCLI; Server=myservername/theinstancename; Database=mydatabase; Trusted_connection=yes;

Use your account and password
Oconn.properties ("Prompt") = adPromptAlways oConn.Open "PROVIDER=SQLNCLI; Server=myserveraddress;database=mydatabase;

Using Mars (multiple active result sets)
PROVIDER=SQLNCLI; Server=myserveraddress;database=mydatabase; Trusted_connection=yes; Marsconn=yes;
"Multipleactiveresultsets=true" and "Mars_connection=yes" are the same.
Use ADO 2.0 as a module for Mars. The Mars does not support ADO 1.0 and ADO 1.1.

Verifying network data
PROVIDER=SQLNCLI; server=myserveraddress; Database=mydatabase; Trusted_connection=yes; Encrypt=yes;

Connect to a local SQL Server Express instance using the Attach local database file

PROVIDER=SQLNCLI; server=./sqlexpress; Attachdbfilename=c:/asd/qwe/mydbfile.mdf; Database=dbname; Trusted_connection=yes;

Connect to a local SQL Server Express instance by using a database file in the attached local data folder

PROVIDER=SQLNCLI; server=./sqlexpress; attachdbfilename=| Datadirectory|mydbfile.mdf; Database=dbname; Trusted_connection=yes;

Database Mirroring
Data source=myserveraddress; Failover Partner=mymirrorserver; Initial catalog=mydatabase;integrated security=true;

    • SqlConnection (. NET)

Standard connection
Data source=myserveraddress; Initial catalog=mydatabase; User Id=myusername; Password=mypassword;

Standard Security Alternative syntax
Server=myserveraddress;database=mydatabase; User Id=myusername; Password=mypassword; Trusted_connection=false;

Trusted connections
Data source=myserveraddress;initial catalog=mydatabase;integrated Security=sspi;

Trusted Connection Alternative syntax
Server=myserveraddress;database=mydatabase; Trusted_connection=true;

Connect to an instance of SQL Server
The expression for the specified server instance is the same as other SQL Server connection strings.
Server=myservername/theinstancename;database=mydatabase; Trusted_connection=true;

Secure connection from the WinCE device
Data source=myserveraddress; Initial catalog=mydatabase; Integrated Security=sspi; User Id=mydomain/myusername; Password=mypassword;
Can only be used for CE equipment.

connection with an IP address
Data source=190.190.200.100,1433; Network library=dbmssocn;initial catalog=mydatabase; User Id=myusername; Password=mypassword;

Using Mars (multiple active result sets)
Server=myserveraddress;database=mydatabase; Trusted_connection=true; Multipleactiveresultsets=true;
Use ADO 2.0 as a module for Mars. The Mars does not support ADO 1.0 and ADO 1.1.

Connect to a local SQL Server Express instance using the Attach local database file
server=./sqlexpress; Attachdbfilename=c:/asd/qwe/mydbfile.mdf; Database=dbname; Trusted_connection=yes;

Connect to a local SQL Server Express instance by using a database file in the attached local data folder
server=./sqlexpress; attachdbfilename=| Datadirectory|mydbfile.mdf; Database=dbname; Trusted_connection=yes;

Use a user instance on a SQL Server Express instance
Data source=./sqlexpress;integrated security=true; attachdbfilename=| Datadirectory|/mydb.mdf; User instance=true;

Database Mirroring
Data source=myserveraddress; Failover partner=mymirrorserver;initial catalog=mydatabase;integrated security=true;

Asynchronous processing
server=myserveraddress; Database=mydatabase; Integrated security=true; asynchronous processing=true;

Composition of the SQL Server database connection string

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.