Salesforce Connector for JAVA How to Get Profiles
Introduction
In this article we will delve deeper into Salesforce and JAVA integration, and will learn how to get profiles. We are continuing from where we left off. By this time, you must have installed ODBC PowerPack, created ODBC Data Source, and configured authentication settings in your Salesforce account .
So, let's not waste time and begin.
Use Query Builder to generate SQL query
-
The first thing you have to do is open Query Builder:
ZappySys API Driver - SalesforceAmazon Ads Connector can be used to get Amazon advertisements using Amazon Advertisements API, download various advertisement-related reports.SalesforceDSN
-
Then simply select the Get Profiles endpoint (action).
-
Continue by configuring the Required parameters. You can also set optional parameters too.
-
Move on by hitting Preview Data button to preview the results.
-
If you see the results you need, simply copy the generated query:
-
That's it! You can use this query in JAVA.
Let's not stop here and explore SQL query examples, including how to use them in Stored Procedures and Views (virtual tables) in the next steps.
SQL query examples
Use these SQL queries in your JAVA data source:
How to Get Profiles
SELECT * FROM Profiles
get_profiles endpoint belongs to
Profiles
table(s), and can therefore be used via those table(s).
Get Profiles in JAVA
-
Java code to get the data:
"jdbc:sqlserver://localhost:5000;databasename=SalesforceDSN;user=john;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) {} } } }
More actions supported by Salesforce Connector
Learn how to perform other actions directly in JAVA with these how-to guides:
- Get Beta Report
- Get Report
- Test Connection
- Make Generic API Request
- Make Generic API Request (Bulk Write)