Skip to content

lucarota/salesforce-jdbc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

313 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Salesforce JDBC Driver

The Salesforce JDBC driver enables Java applications to connect to Salesforce data services using standard, database-independent Java code. It is an open-source JDBC driver written in pure Java that communicates over the SOAP/HTTP(S) protocol.

The primary purpose of this driver is to retrieve data from Salesforce services for data analysis. It is particularly optimized for use with the Eclipse BIRT engine.

This project is a fork of the original repository, which had compatibility issues with IntelliJ IDEA. This version addresses those limitations by implementing:

  • Table and column name filtering
  • Case-insensitive handling for table and column names
  • Metadata support for queries, allowing IntelliJ to correctly process results

Watch the demo video

Watch the demo video

Supported Versions

  • Salesforce Partner API: Version 64.0
  • Java: Java 17

Getting the Driver

You can download the latest driver JAR file from the Releases page.

Supported Features

  1. Native SOQL Queries

    SELECT Id, Account.Name, Owner.Id, Owner.Name FROM Account;
    
    -- The * wildcard expands to the first 100 fields of the root entity
    SELECT * FROM Account;
  2. Nested Queries

  3. INSERT and UPDATE Statements Supported functions for value calculation:

    • NOW()
    • GETDATE()

    Example:

    INSERT INTO Account(Name, Phone) VALUES 
     ('Account01', '555-123-1111'),
     ('Account02', '555-123-2222');
     
    INSERT INTO Contact(FirstName, LastName, AccountId) 
       SELECT Name, Phone, Id 
       FROM Account
       WHERE Name LIKE 'Account0%';
    
    UPDATE Contact SET LastName = 'Updated_Now_' + NOW()
       WHERE AccountId IN (
           SELECT Id FROM Account WHERE Phone = '555-123-1111' AND CreatedDate > '{ts 2020-01-01 00:10:12Z}'
       );
  4. DELETE Statements

    DELETE FROM Opportunity WHERE Name LIKE 'Pushed Out Insightor Opp%';

    Example of response

  5. Request Caching Supports local caching in two modes:

    • Global: Cached results are accessible to all system users within the JVM session.
    • Session: Caching is isolated to each Salesforce connection session.

    Cache duration is limited to the JVM lifespan or a maximum of 1 hour. Enable caching using a query prefix:

    • Global cache mode:
      CACHE GLOBAL SELECT Id, Name FROM Account
    • Session cache mode:
      CACHE SESSION SELECT Id, Name FROM Account

Maven Dependency

Add the following dependency to your pom.xml:

<dependency>
    <groupId>it.rotaliano.salesforce</groupId>
    <artifactId>salesforce-jdbc</artifactId>
    <version>2.0.0</version>
</dependency>

Connection Configuration

Driver Class Name

it.rotaliano.jdbc.salesforce.ForceDriver

JDBC URL Format

jdbc:rotaliano:salesforce://[;propertyName1=propertyValue1[;propertyName2=propertyValue2]...]

You can connect using either User/Password or Session ID.

1. User and Password

jdbc:rotaliano:salesforce://;user=myname@companyorg.com;password=passwordandsecretkey

Note: The password must be a concatenation of your Salesforce password and security token.

2. Session ID

jdbc:rotaliano:salesforce://;sessionId=uniqueIdAssociatedWithTheSession

Note: User and password parameters are ignored if sessionId is provided.

Configuration Properties

Property Description Default Value
user Login username.
password Login password concatenated with the security token.
sessionId Unique ID associated with an active session.
loginDomain Top-level domain for login requests. Set to test.salesforce.com for sandbox environments. login.salesforce.com
https Use HTTP instead of HTTPS if set to false. true
api API version to use. 64
client Client ID to use. Empty
insecurehttps Allow invalid SSL certificates. false

IDE Configuration

Eclipse BIRT

  1. Follow the guide on How to add a JDBC driver.

  2. Set configuration properties using property binding in the data source editor.

    BIRT Data Source

    Refer to the [Salesforce JDBC report sample](docs/birt/Salesforce JDBC sample.rptdesign) for a complete example.

IntelliJ IDEA

  1. Follow the guide on How to add a JDBC driver.

  2. Configure the JDBC URL with the necessary properties.

    Example URL:

    jdbc:rotaliano:salesforce://dev@Local.org:123456@localorg.localhost.internal.salesforce.com:6109?https=false&api=61.0
    

    Ensure you verify your access type (HTTP/HTTPS) and API version.

    IntelliJ supports autocomplete for SOQL queries: Autocomplete SOQL

Troubleshooting

WSDL Issues

To update partners.wsdl:

  1. Clone and build force-wsc.
  2. Run the following command:
    java -jar target/force-wsc-50.0.0-uber.jar blt/app/main/core/shared/submodules/wsdl/src/main/wsdl/partner.wsdl sforce-partner.jar
  3. Copy com.sforce.soap to the driver source.

Version History

See CHANGELOG.md.

Contributing

We welcome contributions! Please review the following guides:

Also, consider sponsoring this project! ✌️

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

No description, website, or topics provided.

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Sponsor this project

Packages

 
 
 

Contributors

Languages