ArcGIS 9.3 does not provide a geoprocessing tool for creating ArcSDE
connection files (.sde files). Some of you have requested such a tool for security
reasons - typically because you do not want .sde connection files hanging
around on machines. Rather, you want to automatically create a connection file
in a temporary location, use it in your script or model, and then delete it
within the process you are running. Others need the ability to create .sde files
on the fly because the connection properties, such as what version to connect to,
are not known at the start of the process. Having to stop the process for someone
to manually create the .sde file with the correct properties really isn't an
option anyone wants to entertain.
The attached .zip file (download .zip file) contains a java class (CreateSDEConnFile) and a
python script (CreateSDEConnFile.py) to create
ArcSDE connection files on the fly. Download and unzip the file. Be sure to
unzip the file into a folder that does not contain spaces. For example:
E:\SDE Conn sample (incorrect - contains spaces)
E:\SDEConnectionSample (correct - no spaces)
Java must be installed
You must have Java installed in order to use the files included in the .zip file.
Most likely, Java is installed on your machine -- it gets installed by many websites.
You can check by examining your installed programs list. You can install java by
visiting java.com.
Setting JAVA_HOME
In order for CreateSDEConnFile.py file to execute, you must have the JAVA_HOME
system environment variable set to the location of the java install directory.
On Windows XP, right-click "My Computer" on your desktop, click the Advanced tab, and click the
"Environment Variables" button. If the JAVA_HOME environment variable doesn't exist,
create it by clicking the "New" button.
(On my machine, JAVA_HOME = C:\Program Files\Java\jre1.6.0_07)
About CreateSDEConnFile.py Python script
CreateSDEConnFile.py is a sample script.
You will need to modify it to include details about your ArcSDE configuration and security needs.
There is no associated geoprocessing script tool for CreateSDEConnFile.py -- you will have to
create your own script tool for use in ModelBuilder (See An overview of creating script tools in the web help for
more information about creating script tools.)
Arguments to the CreateSDEConnFile java class
String sConFileDir = args[0]; //Folder path to store the .sde file.
String sConFile = args[1]; //.sde file name. include the .sde extension.
pConnProps.setProperty("SERVER", args[2]); //ArcSDE Server name.
pConnProps.setProperty("INSTANCE", args[3]); //ArcSDE port number.
pConnProps.setProperty("USER", args[4]); //ArcSDE user name.
pConnProps.setProperty("PASSWORD", args[5]); //ArcSDE password.
pConnProps.setProperty("VERSION", args[6]); //Version to connect to.
pConnProps.setProperty("DATABASE", args[7]); //Database to connect to.
zip file
Download zip file