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 > JDBC DataSource


JDBC DataSource Code


package com.daffodilwoods.demo.simple;

import com.daffodilwoods.replicator.dataSources.JDBCDataSource;
import com.daffodilwoods.replicator.server.Replicator;
import com.daffodilwoods.replicator.utils.RepException;

/**
 * This is Sample application which show The replication of one data base into
 * another data base. SQL Server is taken in this sample as source data base as
 * well target data base
 */
public class SampleJBDCDataSource  {

    // Properties for Source
    private String databaseServerName = "daffodil";
    private String portNo = "1433";
    private String databaseName = "Northwind";
    private String userName = "sa";
    private String password = "hrhk";
    private String dataSourceName = "abc";
    private String dataSourceClassName = "com.microsoft.jdbcx.sqlserver.SQLServerDataSource";
    private String replicationHome = "D:/RepHome";
    
    // General properties
    private String tableNames[] = { "dbo.Categories" };
    
    /* Making Instance of Replicator and setting major properties */
    public Replicator getReplicatorInstance() throws RepException {
        Replicator repServer = new Replicator();
        repServer.setReplicationHome("D:/server");
        return repServer;
    }
    
    /*
     * Making JDBCDataSource
     *
     * @param userName    :    set the database user name
     * @param password    :    set the database password    
     * @param databaseName    :    set the databae name
     * @param portNo    :    set the port number of database
     * @param databaseServerName    :    set the database server name
     * @param dataSourceName    :    set the datasource name like source or target
     * @param dataSourceClassName    :    set the class name which you get the datasource.
     * @param replicationHome    :    set the replication Home for set he exception trace, schema  and data in XML.
     * @param tablesName    :    set the tables name which you want to enables.
     * @return JDBCDataSource
     */

    public JDBCDataSource getJDBCDataSource(String userName, String password,
            String databaseName, String portNo, String databaseServerName,
            String dataSourceName, String dataSourceClassName, String replicationHome,
            String[] tablesName) {

        JDBCDataSource dataSource;
        try {
            dataSource = new JDBCDataSource();
            dataSource.setUserName(userName);
            dataSource.setPassword(password);
            dataSource.setDatabaseName(databaseName);
            dataSource.setDatabasePortNo(portNo);
            dataSource.setDatabaseServerName(databaseServerName);
            dataSource.setDataSourceName(dataSourceName);
            dataSource.setDataSourceClassName(dataSourceClassName);
            dataSource.setReplicationHome(replicationHome);
            dataSource.setTable(tablesName);
            
            return dataSource;

        } catch (Exception e) {
            e.printStackTrace();

        }
        return null;

    }
}


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