Quantcast
Channel: Primavera Online Interaction » PMDB
Viewing all articles
Browse latest Browse all 92

prim23796:How to connect to the SDK through JDBC connection

$
0
0
Solution ID: prim23796
How to connect to the SDK through JDBC connection
Status: Reviewed
Version(s): 3.5.1, 4.0, 4.1, 5.0



Problem: How to connect to the SDK through JDBC connection
Fix:

To connect to the SDK via a JDBC connection, you will need to use the JDBC-ODBC bridge


import java.sql.Connection;
import java.sql.DriverManager;


/***********************
* Connecting to SDK via JDBC *
***********************/
public class PrimaveraTest {


 


// Set the Database URL to be jdbc:odbc:<<DSN NAME>>
private static String url = “jdbc:odbc:PrimaveraSDK”;
private static String username = “admin”;
private static String password = “admin”;



public static void main(String[] args) throws Exception {


try{


    // Load the JDBCODBC driver included with 1.4.x JDK’s
   
Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”);
    System.out.println(“Connecting to ” + url + ” with username/password = “+username+”/”+password);
    System.out.println(“Found Driver”);


    //Make a connection the the database URL, send username and password
    Connection conn = DriverManager.getConnection(url, username, password);
    System.out.println(“Connected to Primavera”);


    conn.close();
    conn = null;
    System.out.println(“Disconnected from Primavera”);

}


catch(java.lang.ClassNotFoundException e) {


    System.out.println(“SQL Driver not found “);
    e.printStackTrace();
}


}
 


The integration API can also be used to connect Java applications to the PMDB.


DISCLAIMER: The code listed above is provided for the convenience of the User and is not provided under warranty or supported as part of Primavera System Inc.’s Maintenance and Support Program. Users who implement the code do so at their own risk. Primavera Systems Inc. will not be responsible for any problems or data loss resulting from the use of this application.  


Viewing all articles
Browse latest Browse all 92

Trending Articles