How do I connect to a spatial database? __ Database

Source: Internet
Author: User

"Summary" This article describes how to use Arccatalog and C # code to connect Oracle ARCSDE space databases.

For ARCSDE management and development, you must first know how to connect to a spatial database. Connecting to ArcSDE actually consists of two types: three-layer mode and two-layer mode. The three-tier mode is that the client connects directly to the ARCSDE service, and then the ARCSDE service processes the connection to the spatial database. The second-tier mode is also called direct-connection mode, direct connection, where the client connects directly to the spatial database. The second-tier model has better flexibility, but the client load is increased; The client is almost without load in the three-tier mode, but the ARCSDE service needs to be configured and managed on the server.

Consider using a two-tier connection in the following situations: lazy to manage the ARCSDE service requires less server load to connect to the ARCSDE personal database

Consider using the three-tier connection mode in the following situations: Client machine resources are not consistent with server distributions lazy Configure server connections for each client

The following shows how to connect the ARCSDE database in a two-layer direct connection via Arccatalog

1, click the "Start/arcgis/arccatalog" menu, start the Arccatalog software. Locate the database Connections menu in the left navigation tree and select. When the menu is selected, the Right Detail window displays the existing connection (as shown in Figure 2.1).

Figure 2.1 Configuration database connection (i)

2, double-click "Add Space Database Connection", the system displays the Database Configuration dialog box (as shown in Figure 2.2). Fill in the service, user name, and password in turn, and click on the "OK" button.

Figure 2.2 Configuration database connection (ii)

Note that if the use of oracle10g, then the service must be filled out "sde:oracle10g", if the use of oracle9i, then the service must be completed "sde:oracle9i." The user name is the user name configured in the database. The password uses "Password@db_net_service_name". For example:

User name: User1

Password: password1@dbname1

The default connection to version is "SDE." DEFAULT, you can select a change to select a version name if you need to connect to another version. You can also use the test Connection button to test the correctness of the configuration.

3. Modify the connection name and press ENTER (as shown in Figure 2.3). Double-click the connection name to connect to the database at a later time. If you click the right mouse button on the connection, you can see the Properties menu, and you can see the name in the form:

C:/Documents and Settings/hexy/application Data/esri/arccatalog/test1@dbname.sde

In fact, all the configuration information for the entire connection has been stored in the SDE file, and the program code can also use the file directly to connect to the database.

Figure 2.3 Configuration database Connection (iii)

The following shows how to connect to a spatial database through program code (C # language). As you can see, the program code settings are similar to the use of the Arccatalog metabase connection, and you need to set the user name (user1), password (password1), database name (DBNAME1), server address (localhost), instance name (sde:o racle10g), version number (Sde.default).

String userName = "user1", Password = "Password1", Userdbname = "dbname1";

ESRI. ArcGIS.esriSystem.IPropertySet PropertySet = new ESRI. ArcGIS.esriSystem.PropertySetClass ();

Propertyset.setproperty ("SERVER", "LOCALHOST");

Propertyset.setproperty ("INSTANCE", "sde:oracle10g");

Propertyset.setproperty ("USER", userName);

string pwd = password + "@" + userdbname;

Propertyset.setproperty ("PASSWORD", PWD);

Propertyset.setproperty ("VERSION", "SDE.") DEFAULT ");

ESRI. ArcGIS.Geodatabase.IWorkspaceFactory factory = new ESRI. ArcGIS.DataSourcesGDB.SdeWorkspaceFactoryClass ();

Iworkspace ws = Factory. Open (propertyset, 0);

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.