In order to use the ESP JDBC driver, you must connect to a cluster, retrieve a session ID from ESP, and use it as the argument for the JDBC user connection parameter. The code sample below demonstrates this procedure.
// Create a URI and credentials to connect to the cluster. Uri serverURI = new Uri.Builder("esp://nstackxp2:9786/default/csv_poll_test").create(); Credentials creds = new Credentials.Builder(Credentials.Type.NONE).create(); System.out.println(serverURI); // Connect to the cluster Project project = s_sdk.getProject(serverURI, creds); project.connect(WAIT_TIME_60000_MS); // Get the session ID after connecting. String theSessionID = SDK.getSessionId(serverURI, creds); System.out.println("The Session ID: " + theSessionID); // Query the cluster for the project host and port. Deployment dep = project.getCurrentDeployment(); int sqlPort = dep.getSqlPort(); String host = dep.getHost(); System.out.println("SqlPort = " + sqlPort); //Server server = s_sdk.getServer(serverURI , creds); //server.connect(); Jdbc3SimpleDataSource source = new Jdbc3SimpleDataSource(); source.setServerName("localhost"); source.setDatabaseName("database"); source.setUser(theSessionID); source.setPassword(""); source.setPortNumber(sqlPort); Connection con = null; try { con = source.getConnection(); // Use the connection. } catch (SQLException e) { // Log any errors. }