Home      DB      Replicator      CRM      Solutions  
 
Daffodil Replicator
 
Explore Replicator (OS)
 

Product Overview
Download Daffodil Replicator (E)
Getting Started Guide
User Guide
Features
How it Works?
Usage Scenarios
Usage Examples
Recommended JDBC Drivers
Replicator Class Reference
Sample Java Code
Error Messages
Daffodil Replicator (E) FAQ
Daffodil Replicator (E) BLOG
User Forum
Buy
 
Sample Java Code > Replication DataSource


Replication DataSource Code


package com.daffodilwoods.demo.simple;

import com.daffodilwoods.ftp.server.FTPParameters;
import com.daffodilwoods.replicator.client.webservice.ReplicationDataSource;
import com.daffodilwoods.replicator.dataSources.JDBCDataSource;
import com.daffodilwoods.replicator.utils.RepException;
import com.daffodilwoods.webservices.server.WebServiceServerProperties;

public class SampleReplicationDataSource {

    // parameters of  replication datasource
    private static String databaseServerName = "localhost";
    private static String portNo = "1433";
    private static String databaseName = "source";
    private static String userName = "sa";
    private static String password = "hrhk";
    private static String dataSourceName = "source";
    private static String dataSourceClassName = "com.microsoft.jdbcx.sqlserver.SQLServerDataSource";
    private static String replicationHome = "D:/source1";
    private static String systemName = "169.254.182.164";
    private static int webServicePort = 1050;
    private static int ftpPort = 2050;
    private static String[] tableNames = { "dbo.client" };

    public static void main(String[] args) throws RepException {
        ReplicationDataSource replicationDataSource = ReplicationDataSource.getSharedInstance();
        SampleReplicationDataSource.configureReplicationDataSource(replicationDataSource);
        
        SampleJBDCDataSource sampleJdbcDataSource = new SampleJBDCDataSource();
        JDBCDataSource jdbcDataSource = sampleJdbcDataSource.getJDBCDataSource(userName,
                password, databaseName, portNo, databaseServerName,
                dataSourceName, dataSourceClassName, replicationHome, tableNames);
        try {
            replicationDataSource.addDataSource(jdbcDataSource);
            replicationDataSource.start();
        }
        catch (Exception ex) {
            ex.printStackTrace();
        }

    }

    //Configure the replication datasource
    public static void configureReplicationDataSource(ReplicationDataSource replicationClient) {
        WebServiceServerProperties webClientProperties = new WebServiceServerProperties();
        webClientProperties.setPort(webServicePort);
        FTPParameters parameters = new FTPParameters();
        parameters.setHostName(systemName);
        parameters.setRootDir(replicationHome);
        parameters.setPort(ftpPort);
        replicationClient.setFTPServerParameters(parameters);
        replicationClient.setWebServicesProperties(webClientProperties);
    }
}

 
  ©2008 Daffodil Software Ltd. Contact Us | Disclaimer | Sitemap