Using User Name And Password
To connect using your Salesforce user name and password, you must specify the following connection properties:
UID
PWD
You might also need to specify the following connection properties:
Endpoint
, if you are not using the connector's default endpoint ofhttps://www.salesforce.com/services/Soap/u/48.0
.SecurityToken
, if it is required by your Salesforce instance and you have not appended the security token to your password.
If your application prompts you for a user name and a password when you connect to your Salesforce.com data using the Simba Salesforce JDBC Connector, then type your user name and password in the appropriate fields.
For an example that demonstrates how to specify a user name and a password using the connection URL, see Building the Connection URL.
Examples Using a Connection URL
The following is an example connection URL for connecting to Salesforce using User Name and Password:
jdbc:salesforce://localhost;UID=simba;PWD=simba
The following is an example connection URL for connecting to Salesforce using User Name, Password, and Token.
jdbc:salesforce://localhost;UID=simba;PWD=simba;Token=8xz3rM47r3QeUNj28Xs3525UM
Example Connecting to a Standard Salesforce Instance
The following code demonstrates how to set connection properties to connect to a standard Salesforce instance using a user name and password:
// --- DEFINE PROPERTIES FOR THE CONNECTION ---
Properties ConnectionProperties = new Properties();
ConnectionProperties.setProperty("UID", "user@demo.com");
ConnectionProperties.setProperty("PWD", "simba[token]");
// --- END PROPERTIES ---
Example Connecting to a Salesforce Sandbox
As another example, the following code demonstrates how to set connection properties to connect to a sandbox system using a user name and password.
To connect to a sandbox, use this endpoint: https://test.salesforce.com/services/Soap/u/48.0
. You must also append the sandbox name to your user name using this format: [UserName].[SandboxName]
// --- DEFINE PROPERTIES FOR THE CONNECTION ---
Properties ConnectionProperties = new Properties();
ConnectionProperties.setProperty("UID", "user@demo.com.MySandbox");
ConnectionProperties.setProperty("PWD", "simba[token]");
ConnectionProperties.setProperty("Endpoint",
"https://test.salesforce.com/services/Soap/u/48.0");
// --- END PROPERTIES ---