ArcGIS 10.1 如何连接数据库(转载)
ArcGIS 10.1如何连接数据库 最近在使用ArcGIS 10.1的数据库,在使用的过程中发现了跟以往不太一样的地方,在这里将自己的心得和想法跟大家分享一下(使用Postgresql),根据使用过程,我将内容分为两个部分(这两个部分,是我在使用完分出来的,并重新整理,
ArcGIS 10.1如何连接数据库
最近在使用ArcGIS 10.1的数据库,在使用的过程中发现了跟以往不太一样的地方,在这里将自己的心得和想法跟大家分享一下(使用Postgresql),根据使用过程,我将内容分为两个部分(这两个部分,是我在使用完分出来的,并重新整理,其中穿插我自己的想法,欢迎大家跟我们一起交流。),10.1已经不需要安装arcgis sde了,可以通过工具直接在Oracle上建立空间数据库,并且直接链接。
如何使用直连方式连接数据库
1, ArcGIS 10.1 统一了数据库连接,也就是不区分是空间数据库连接还是通过OLEDB方式的关系型数据库连接
左图为10.1下的截图,右图为10.0下的截图
2, 在Catalog中只能采用直连方式;
3, ArcGIS 10.1版本中,Esri提供的安装介质不在包含Postgresql(以前的是包含的);
4, 安装Postgresql,官方给的软件要求是64位数,而且所有的企业级数据库都是64位(这应该和Server有关系吧,因为Server 10.1是纯64位,在桌面软件的DatabaseSupport目录中给出的几个dll都是64位,这几个dll 后面会用到,官方给的软件需求如下:
Database |
Supported Operating Systems |
Minimum OS Version |
Maximum OS Version |
PostgreSQL 9.0.5 (64-bit) |
Red Hat Enterprise Linux Server 5 (64-bit) |
Update 7 |
|
Red Hat Enterprise Linux Server 6 (64-bit) |
|||
SUSE Linux Enterprise Server 11 (64-bit) |
SP1 |
||
Windows Server 2003 Standard, Enterprise, and Datacenter (64-bit [EM64T]) |
SP2 |
SP2 |
|
Windows Server 2008 R2 Standard, Enterprise, and Datacenter (64-bit [EM64T]) |
SP1 |
5, 配置PostgreSQL的客户端。因为直连方式要求ArcSDE的客户端必须安装数据库的客户端类库,所以首先需要获取PostgreSQL的客户端。ArcGIS Desktop是32位软件,需要的是32位的PostgreSQL类库。找到PostgreSQL的客户端,或者在别的机器上将32位的 libeay32.dll, libiconv-2.dll, libintl-8.dll, libpq.dll, and ssleay32.dll文件拷贝到Desktop 安装目录的bin目录下;
6, 拷贝 st_geometry.dll,将Desktop 安装目录下的DatabaseSupport/PostgreSQL/Windows64(看到64了吧)目录下,拷贝st_geometry.dll文件到PostgreSQL的lib目录。在PostgreSQL中创建Geodatabase时必须用到此类库;
7, 配置pg_hba.conf,修改PostgreSQ 的pg_hba.conf文件,添加“host all all 0.0.0.0/0 md5”(关于该文件的配置,可以参阅相关资料);
8, 在安装完SDE后,发现没有以往的post界面,在10.1中,对于创建企业级Geodatabase都采用工具箱中提供的工具,换句话说,以前的post被Toolbox中的一堆工具替代;
9, 创建地理数据库
10.1在创建地理数据库的时候,提供了三个,Oracle,SQL Server和Postgresql,我们用这个工具创建地理数据库,这个过程相当于早起的POST过程,创建数据库并写入一堆系统表等,创建界面如下图:
创建成功后就可以在pgAdmin中看到sde这个数据库,并且看到很多系统表,如下图:
10, 连接地理数据(直连);
在上面说了ArcGIS 10.1对数据库连接做了统一,那如何判断是关系型数据库还是空间数据库呢?其实这点并不难,因为在创建空间数据库的时候,我们同时创建了用户名和密码,那么用这个用户名连接,并选择创建的这个数据库,那么这个数据库就是空间数据库,连接界面如下图:
连接成功后,我在数据库里创建了要素数据集添加了几个数据,做了一个拓扑分析(做这个的目的不是为了做拓扑,而是为了验证能否做拓扑分析,所以拓扑分析的结果我们不做讨论),结果如下:
同理,做了一个几何网络,效果如下:
现在我们想一个问题,上面我们使用的是直连的方式访问数据库,大家觉得是否缺少什么呢?我们会想以前如何使用数据库的,首先装了关系型数据库(Postgresql),这一步我们有了,然后就是安装ArcGIS SDE for postgresql,这一步我们没有,然后就是创建数据库,连接数据库。从整个过程来看,我们没有安装SDE,那为什么也可以创建空间数据库呢?
这也是我自己发现的一个,在开始的时候,我的确是安装了SDE,但是我发现这个安装不想ArcGIS 10 或者之前的弹出一个post的界面,装了之后什么反应都没有,我去安装目录下看了看,发现这个安装其实就是解压了一些东西,而我的空间数据库还没有建立呢?再后来发现连接数据库的时候,没有服务这个选项,当初我就觉得这个安装跟我连接数据库没有关系,于是卸载了,根据:http://resources.arcgis.com/en/help/main/10.1/index.html#/Setting_up_a_geodatabase_in_PostgreSQL/002p00000001000000/仔细看了一遍,发现这个过程的确不安装SDE是可以的,跟售后的同事确认了下,得出的结论:如果是使用直连方式,ArcGIS 10.1 是不用安装SDE的任何组件。新的问题来了,我们知道在以前的版本中SDE还有一种方式就是服务连接,那如何使用服务连接呢?
如果细心的话,我们可以发现在安装SDE的时候,有两个组件让我们安装:
根据组件右边的描述,我们知道这个安装就是针对服务连接的,也就是说如果要使用服务方式连接,就需要安装SDE,如何创建服务,如何使用服务连接(我们明显看到连接中根本就没有服务这个选项)就是我们下来要讨论的问题。
如何使用服务的方式连接数据库
服务连接的额外步骤
- 安装ArcSDE for PostgreSQL 10.1;
- 修改ArcSDE安装目录中services.sde文件和Windows中的hosts文件,分别增加“esri_sde 5151/tcp”记录;
-
创建ArcSDE服务。分别键入以下两个命令以完成在注册表中创建服务的工作:
sdeservice -o create -d POSTGRESQL,postgresql-x64-9.0
sdeservice -o register -d POSTGRESQL,postgresql-x64-9.0 -r ADMIN_DATABASE -v sde - 启动服务。可以用“sdemon –o start”命令或从Windows服务面板中启动ArcSDE服务;
- 创建连接。在catalog中只能创建直连服,因此需要使用新的Create ArcSDE Connection File GP工具来创建ArcSDE服务连接文件。创建成功后,在catalog中找到这个连接双击就可以打开。
通过这个工具,如果我们的数据库是ArcGIS 10 或者之前的,并且采用服务的方式,那么在使用10.1的时候,应该用这个工具吧(没有测试,根据向下兼容,我自己猜想)

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Go language is an efficient, concise and easy-to-learn programming language. It is favored by developers because of its advantages in concurrent programming and network programming. In actual development, database operations are an indispensable part. This article will introduce how to use Go language to implement database addition, deletion, modification and query operations. In Go language, we usually use third-party libraries to operate databases, such as commonly used sql packages, gorm, etc. Here we take the sql package as an example to introduce how to implement the addition, deletion, modification and query operations of the database. Assume we are using a MySQL database.

Apple's latest releases of iOS18, iPadOS18 and macOS Sequoia systems have added an important feature to the Photos application, designed to help users easily recover photos and videos lost or damaged due to various reasons. The new feature introduces an album called "Recovered" in the Tools section of the Photos app that will automatically appear when a user has pictures or videos on their device that are not part of their photo library. The emergence of the "Recovered" album provides a solution for photos and videos lost due to database corruption, the camera application not saving to the photo library correctly, or a third-party application managing the photo library. Users only need a few simple steps

Hibernate polymorphic mapping can map inherited classes to the database and provides the following mapping types: joined-subclass: Create a separate table for the subclass, including all columns of the parent class. table-per-class: Create a separate table for subclasses, containing only subclass-specific columns. union-subclass: similar to joined-subclass, but the parent class table unions all subclass columns.

How to use MySQLi to establish a database connection in PHP: Include MySQLi extension (require_once) Create connection function (functionconnect_to_db) Call connection function ($conn=connect_to_db()) Execute query ($result=$conn->query()) Close connection ( $conn->close())

To handle database connection errors in PHP, you can use the following steps: Use mysqli_connect_errno() to obtain the error code. Use mysqli_connect_error() to get the error message. By capturing and logging these error messages, database connection issues can be easily identified and resolved, ensuring the smooth running of your application.

HTML cannot read the database directly, but it can be achieved through JavaScript and AJAX. The steps include establishing a database connection, sending a query, processing the response, and updating the page. This article provides a practical example of using JavaScript, AJAX and PHP to read data from a MySQL database, showing how to dynamically display query results in an HTML page. This example uses XMLHttpRequest to establish a database connection, send a query and process the response, thereby filling data into page elements and realizing the function of HTML reading the database.

PHP is a back-end programming language widely used in website development. It has powerful database operation functions and is often used to interact with databases such as MySQL. However, due to the complexity of Chinese character encoding, problems often arise when dealing with Chinese garbled characters in the database. This article will introduce the skills and practices of PHP in handling Chinese garbled characters in databases, including common causes of garbled characters, solutions and specific code examples. Common reasons for garbled characters are incorrect database character set settings: the correct character set needs to be selected when creating the database, such as utf8 or u

Through the Go standard library database/sql package, you can connect to remote databases such as MySQL, PostgreSQL or SQLite: create a connection string containing database connection information. Use the sql.Open() function to open a database connection. Perform database operations such as SQL queries and insert operations. Use defer to close the database connection to release resources.
