Supported with:
Library dependencies: System, SystemUI, Geometry, Display, Server, Output, Geodatabase, GISClient, DataSourcesFile

Additional library information: Contents, Object Model Diagram

The DataSourcesGDB library contains the implementation of the GeoDatabase application programming interface (API) for the database data sources. These data sources include Microsoft Access, file geodatabases, and any relational database management system (RDBMS) supported by ArcSDE.
The DataSourcesGDB library is not extended by developers.

See the following sections for more information about this namespace:

Geodatabase workspace factory objects

The major objects within DataSourcesGDB are workspace factories and the Data Server Manager. A workspace factory object is a dispenser of workspaces and allows a client to connect to a workspace specified by a set of connection properties. A workspace represents a database or a data source that contains one or more datasets. Examples of datasets include tables, feature classes, and relationships. DataSourcesGDB has workspace factories for connecting to Microsoft Access, file geodatabase, and ArcSDE data sources.
Workspace factories are creatable, singleton objects; a singleton object can only be instantiated once in a process. Each workspace factory maintains a pool of currently connected, active workspaces that are being referenced by the application. Connection properties are specified using a PropertySet object and can be saved to a connection file. See the following illustration of geodatabase workspace factory objects:


An AccessWorkspaceFactory is used to connect to a Microsoft Access database. The following code example shows how to connect to an Access database:
// Create an instance of AccessWorkspaceFactory.
AccessWorkspaceFactory accessFactory = new AccessWorkspaceFactory();

// Open the workspace.
Workspace ws = new Workspace(accessFactory.openFromFile(
    "../LinearReferencing/PITT.mdb", 0));


A FileGDBWorkspaceFactory is used to connect to a file geodatabase. A file geodatabase is denoted by the .gdb extension as opposed to Access workspaces, which is denoted by the .mdb extension. The following code example shows how to connect to a file geodatabase:
// Create an instance of FileGDBWorkspaceFactory.
FileGDBWorkspaceFactory wsFactory = new FileGDBWorkspaceFactory();

// Open the workspace.
Workspace fws = new Workspace(wsFactory.openFromFile(
    "../arcgis/ArcTutor/Map/airport.gdb", 0));


A ScratchWorkspaceFactory is used to connect to a temporary database stored in Microsoft Access. These workspaces are commonly used to hold the results of a selection set. This workspace factory is fundamentally different than the AccessWorkspaceFactory in the following ways:
A new type of scratch workspace factory was added at ArcGIS 9.2 that uses a file geodatabase instead of an Access database. The new scratch workspace factory, FileScratchWorkspaceFactory, does not replace the existing ScratchWorkspaceFactory but is meant to take advantage of file geodatabases because it is cross platform (can be used across different operating systems).
The following code example shows how to create a scratch workspace to use as part of a table select:
// Create the ScratchWorkspaceFactory.
ScratchWorkspaceFactory factory = new ScratchWorkspaceFactory();

// Create the ScratchWorkspace.
Workspace sws = new Workspace(factory.createNewScratchWorkspace());

// Use the ScratchWorkspace in a table select.
SelectionSet selSet = new SelectionSet(,
    esriSelectionOption.esriSelectionOptionNormal, sws));


A SdeWorkspaceFactory is used to connect to an ArcSDE database. ISetDefaultConnectionInfo and ISetDefaultConnectionInfo2 are used to specify the username, password, and version of connections to ArcSDE workspaces when those parameters are not specified by the connection properties. This is important if you want to save a connection file that does not persist this information.
IRemoteDatabaseWorkspaceFactory is used to maintain connection files. These files, which store the connection properties used to connect to ArcSDE workspaces, commonly have the .sde extension.
The following code example uses SdeWorkspaceFactory to connect to an ArcSDE database and prints all of the datasets in that database:
// Create a PropertySet object that will contain all of the
// ArcSDE connection parameters. 
PropertySet propSet = new PropertySet();

// Create the SdeWorkspaceFactory.
SdeWorkspaceFactory sdeFact = new SdeWorkspaceFactory();
// Populate the property set with the connection parameters.
propSet.setProperty("SERVER", "pine");
propSet.setProperty("INSTANCE", "9192");
propSet.setProperty("DATABASE", "");
propSet.setProperty("USER", "map");
propSet.setProperty("PASSWORD", "map");
propSet.setProperty("VERSION", "sde.DEFAULT");

// Open the ArcSDE workspace using the connection PropertySet.
Workspace ws = new Workspace(, 0));

// Get the collection of dataset names in the database and display their names.
IEnumDatasetName dsNames = ws.getDatasetNames(esriDatasetType.esriDTAny);

IDatasetName name =;
while (name != null){
    name =;

Data Server Manager

The Data Server Manager is used to access and administer one or more geodatabases stored on a data server using ArcSDE direct connect. You can also create WorkspaceNames from which you can open up workspaces to these geodatabases.
The following code example shows how to connect to a geodatabase in a personal ArcSDE for Structured Query Language (SQL) server using the Data Server Manager:
DataServerManager dsm = new DataServerManager();



WorkspaceName wsname = (WorkspaceName)dsm.createWorkspaceName("Landbase", 


An InMemoryWorkspaceFactory is used to connect to a temporary workspace which is stored in memory. These workspaces are commonly used to hold the results of an analysis operation or to hold objects in memory before persisting them to disk. When the last reference to the workspace is released, the workspace is destroyed and the memory released.
Feature classes contained within InMemory workspaces support the full geodatabase model.  They can be used in conjunction with cursors, selections, and so on. However, InMemory workspaces do not support all aspects of the geodatabase model—advanced datasets, such as topology and geometric networks are not supported. The following code example shows how to create a feature class in an InMemory workspace.  
// Create an InMemory workspace factory.
IWorkspaceFactory workspaceFactory = new InMemoryWorkspaceFactory();

// Create an  InMemory geodatabase.
IWorkspaceName workspaceName = workspaceFactory.create("", "MyWorkspace", null, 0);

// Cast for IName.
IName name = (IName)workspaceName;

// Open a reference to the Access workspace through the name object.
IWorkspace inmemWor = new IWorkspaceProxy(;

// Cast the IWorkspace to a FeatureWorkspace.
IFeatureWorkspace featWork = new IFeatureWorkspaceProxy(inmemWor);

// Create the fields collection and fields for the feature class.
Fields flds = new Fields();

GeometryDef gdef = new GeometryDef();
ISpatialReference sr = new UnknownCoordinateSystem();
sr.setDomain(34.0,  - 118.0, 35.0,  - 120.0);

Field fld = new Field();

Field fld1 = new Field();


// Create the feature class.
FeatureClass fc = new FeatureClass(featWork.createFeatureClass("strikes", flds, null,
    null, com.esri.arcgis.geodatabase.esriFeatureType.esriFTSimple, "Shape", ""));