Search This Blog

Thursday, September 29, 2016

Upload a file to SFTP using java

package com.sftp;

import java.io.File;
import java.io.FileInputStream;

import com.jcraft.jsch.Channel;
import com.jcraft.jsch.ChannelSftp;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.Session;

/**
 * @author drvijay
 */

public class SFTPcallInJava
{

public static void main ( String [] args )
{
String SFTPHOST = "192.168.7.99";
int SFTPPORT = 2121;
String SFTPUSER = "vijayjava";
String SFTPPASS = "vijaytest123";
String SFTPWORKINGDIR = "/www/";

Session session = null;
Channel channel = null;
ChannelSftp channelSftp = null;

try
{
JSch jsch = new JSch ();
session = jsch.getSession ( SFTPUSER, SFTPHOST, SFTPPORT );
session.setPassword ( SFTPPASS );
java.util.Properties config = new java.util.Properties ();
config.put ( "StrictHostKeyChecking", "no" );
session.setConfig ( config );
session.connect ();
channel = session.openChannel ( "sftp" );
channel.connect ();
channelSftp = (ChannelSftp) channel;
channelSftp.cd ( SFTPWORKINGDIR );
File f = new File ( "D:/Temp/aamlog.txt" );
channelSftp.put ( new FileInputStream ( f ), f.getName () );
}
catch ( Exception ex )
{
ex.printStackTrace ();
}

}

}



NOTE - Add jsch-0.1.54.jar

Tuesday, September 20, 2016

STEPS FOR INSTALLING AND CONFIGURING THE APACHE SOLR IN TOMCAT x.x

STEPS FOR INSTALLING AND CONFIGURING THE APACHE SOLR
====================================================


1. copy the solr.war file and place into somewhere in the machine

2. copy the 'solr' folder which contains all cores , and place into some where in machine

3. add 'solr.xml' file  in "tomcat server\conf\Cataline\localhost\"

example: X:\apache-tomcat-8.0.32\conf\Catalina\localhost\solr.xml

4. in 'solr.xml' file we have to specify the path of 'solr.war' and 'solr' folder of cores.

           a)docBase for 'solr.war'  file
           b)environment value for 'solr' folder of cores


solr.xml
---------------



 

-------------



5. Run the tomcat server

  ex:localhost:8080

6. Run the solr admin console

  ex:localhost:8080/solr


7. You will get dashboard of 'solr'  and left side of main page you will get all the cores, which we have from 'solr' folder as specified point number 2.

8. the select the 'query result' and 'execute'



NOTE: Core we have to create manually  , and index the data with datatype manually into each cores.


by
naren


Hit Counter


View My Stats