Salesforce Connector for JAVAIn this article you will learn how to quickly and efficiently integrate Salesforce data in JAVA. We will use high-performance Salesforce Connector to easily connect to Salesforce and then access the data inside JAVA. Salesforce Connector can be used to extract/load large amount of data from/in Salesforce.com without any programming. You can use simple Table mode or Query mode with full SOQL query language support (SOQL=Salesforce.com Object Query Language). Let's follow the steps below to see how we can accomplish that! Salesforce Connector for JAVA is based on ZappySys Salesforce Driver which is part of ODBC PowerPack. It is a collection of high-performance ODBC drivers that enable you to integrate data in SQL Server, SSIS, a programming language, or any other ODBC-compatible application. ODBC PowerPack supports various file formats, sources and destinations, including REST/SOAP API, SFTP/FTP, storage services, and plain files, to mention a few. |
Connect to Salesforce in other apps
|
Create Data Source in ZappySys Data Gateway based on Salesforce Driver
-
Download and install ZappySys ODBC PowerPack.
-
Search for gateway in start menu and Open ZappySys Data Gateway:
-
Go to Users Tab to add our first Gateway user. Click Add; we will give it a name tdsuser and enter password you like to give. Check Admin option and click OK to save. We will use these details later when we create linked server:
-
Now we are ready to add a data source. Click Add, give data source a name (Copy this name somewhere, we will need it later) and then select Native - ZappySys Salesforce Driver. Finally, click OK. And it will create the Data Set for it and open the ZS driver UI.
-
Now, we need SalesForce Connection. Lets create it.
-
Now, When you see DSN Config Editor with zappysys logo first thing you need to do is change default DSN Name at the top and Click on Preview Tab, Select Table from Tables Dropdown or you can enter or modify a SOQL query and click on Preview Data.
This example shows how to write simple SOQL query (Salesforce Object Query Language). It uses WHERE clause. For more SOQL Queries click here.
SOQL is similar to database SQL query language but much simpler and many features you use in database query may not be supported in SOQL (Such as JOIN clause not supported). But you can use following Queries for Insert, Update, Delete and Upsert(Update or Insert record if not found).SELECT * FROM Account WHERE Name like '%Oil%' -
Click OK to finish creating the data source
Read data in Java from the DSN
-
Java code to get the data:
"jdbc:sqlserver://localhost:5000;databasename=SalesforceDSN;user=tdsuser;password=test" -
When you run the code it will make the API call and read the data:
-
Here is Java program's code in text format:
//Step-1: Install ZappySys ODBC PowerPack and Configure Data Gateway //Step-2:Assuming the Microsoft SQL Server JDBC Driver is in below folder //C:\Program Files\Microsoft Jdbc Driver 6.0 for SQL Server\sqljdbc_6.0\enu\auth\x64 package padaone; import java.sql.*; public class zappy { public static void main(String[] args) { // Create a variable for the connection string. String connectionUrl = "jdbc:sqlserver://localhost:5000;databasename=SalesforceDSN;user=test;password=test"; // Declare the JDBC objects. Connection con = null; Statement stmt = null; ResultSet rs = null; try { // Establish the connection. Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); con = DriverManager.getConnection(connectionUrl); // Create and execute an SQL statement that returns some data. String SQL = "SELECT Country , SUM(UnitPrice * Quantity) Total " + "FROM value " + "GROUP BY Country " + "WITH (SRC='https://services.odata.org/V3/Northwind/Northwind.svc/Invoices?$format=json')"; stmt = con.createStatement(); rs = stmt.executeQuery(SQL); // Iterate through the data in the result set and display it. while (rs.next()) { System.out.println(rs.getString(1) + " " + rs.getString(2)); } } // Handle any errors that may have occurred. catch (Exception e) { e.printStackTrace(); } finally { if (rs != null) try { rs.close(); } catch (Exception e) {} if (stmt != null) try { stmt.close(); } catch (Exception e) {} if (con != null) try { con.close(); } catch (Exception e) {} } } }
Conclusion
In this article we showed you how to connect to Salesforce in JAVA and integrate data without any coding, saving you time and effort. We encourage you to download Salesforce Connector for JAVA and see how easy it is to use it for yourself or your team.
If you have any questions, feel free to contact ZappySys support team. You can also open a live chat immediately by clicking on the chat icon below.
Download Salesforce Connector for JAVA Documentation
More integrations
Other connectors for JAVA
Other application integration scenarios for Salesforce
How to connect Salesforce in JAVA?
How to get Salesforce data in JAVA?
How to read Salesforce data in JAVA?
How to load Salesforce data in JAVA?
How to import Salesforce data in JAVA?
How to pull Salesforce data in JAVA?
How to push data to Salesforce in JAVA?
How to write data to Salesforce in JAVA?
How to POST data to Salesforce in JAVA?
Call Salesforce API in JAVA
Consume Salesforce API in JAVA
Salesforce JAVA Automate
Salesforce JAVA Integration
Integration Salesforce in JAVA
Consume real-time Salesforce data in JAVA
Consume real-time Salesforce API data in JAVA
Salesforce ODBC Driver | ODBC Driver for Salesforce | ODBC Salesforce Driver | SSIS Salesforce Source | SSIS Salesforce Destination
Connect Salesforce in JAVA
Load Salesforce in JAVA
Load Salesforce data in JAVA
Read Salesforce data in JAVA
Salesforce API Call in JAVA