Salesforce API create Account using Java

java -classpath wsc-22.jar com.sforce.ws.tools.wsdlc enterprise.wsdl enterprise.jar
[WSC][wsdlc.run:312]Created temp dir: /var/folders/3c/dkbqr41s7jg91g5lcgr4yf300000gn/T/wsdlc-temp-1879025999780229243-dir
[WSC][wsdlc.:79]Generating Java files from schema ...
[WSC][wsdlc.:79]Generated 521 java files.
[WSC][wsdlc.compileTypes:262]Compiling to target 1.6... 
[WSC][wsdlc.compileTypes:262]Compiled 524 java files.
[WSC][wsdlc.:89]Generating jar file ... enterprise.jar
[WSC][wsdlc.:89]To include runtime classes in the generated jar please set system property standalone-jar=true
[WSC][wsdlc.:89]Generated jar file enterprise.jar
[WSC][wsdlc.run:312]Delete temp dir: /var/folders/3c/dkbqr41s7jg91g5lcgr4yf300000gn/T/wsdlc-temp-1879025999780229243-dir
[WSC][wsdlc.run:312]Set system property del-temp-dir=false to not delete temp dir.
java -classpath wsc-22.jar com.sforce.ws.tools.wsdlc partner.wsdl partner.jar
[WSC][wsdlc.run:312]Created temp dir: /var/folders/3c/dkbqr41s7jg91g5lcgr4yf300000gn/T/wsdlc-temp-5611591302274755311-dir
[WSC][wsdlc.:79]Generating Java files from schema ...
[WSC][wsdlc.:79]Generated 164 java files.
[WSC][wsdlc.compileTypes:262]Compiling to target 1.6... 
[WSC][wsdlc.compileTypes:262]Compiled 167 java files.
[WSC][wsdlc.:89]Generating jar file ... partner.jar
[WSC][wsdlc.:89]To include runtime classes in the generated jar please set system property standalone-jar=true
[WSC][wsdlc.:89]Generated jar file partner.jar
[WSC][wsdlc.run:312]Delete temp dir: /var/folders/3c/dkbqr41s7jg91g5lcgr4yf300000gn/T/wsdlc-temp-5611591302274755311-dir
[WSC][wsdlc.run:312]Set system property del-temp-dir=false to not delete temp dir.
package com.thysmichels;

import com.sforce.soap.partner.*;
import com.sforce.soap.partner.sobject.*;
import com.sforce.ws.*;

public class ForcedotcomAWS {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		//Create a new connectionconfig to your Salesforce Org
		ConnectorConfig sfconfig = new ConnectorConfig();
		//Use your salesforce username = email
	    sfconfig.setUsername("username");
	    //Use your saleforce password with your security token look like: passwordjeIzBAQKkR6FBW8bw5HbVkkkk
	    sfconfig.setPassword("passwordsecuritytoken");
	 
	    PartnerConnection partnercon = null;
	    
	    try {
	    	 
	        // create a salesforce connection object with the credentials supplied in your connectionconfig
	        partnercon = Connector.newConnection(sfconfig);
	   
	        // create a new salesforce account record
	        SObject account = new SObject();
	        account.setType("Account");
	        account.setField("Name", "Thys Account");
	        account.setField("Description", "This is a new account");
	        account.setField("Phone", "4084213771");
	        account.setField("Website", "http://thysmichels.com");
	        //	safe account object
	        SaveResult[] sfaccountresults = partnercon.create(new SObject[] { account });
	        System.out.println("Created Account: " + sfaccountresults[0].getId());
 } catch (ConnectionException e) {
	        // TODO Auto-generated catch block
	        e.printStackTrace();
	      }

	}
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: