Pages

Sunday, November 24, 2013

Work with PHP and MsSQL

http://msdn.microsoft.com/en-us/library/cc296170.aspx

Tuesday, November 12, 2013

Creating Routines in Talend

package routines;
import java.util.Date;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;


public class calculateTime {

    /**
     * helloExample: not return value, only print "hello" + message.
     *
     *
     * {talendTypes} String
     *
     * {Category} User Defined
     *
     * {param} string("world") input: The string need to be printed.
     *
     * {example} helloExemple("world") # hello world !.
     */
    public static void helloExample(String message) {
        if (message == null) {
            message = "World"; //$NON-NLS-1$
        }
        System.out.println("Hello " + message + " !"); //$NON-NLS-1$ //$NON-NLS-2$
    }
   
    public static String printCurrentTime() {
        Date dNowj1 = new Date();
        SimpleDateFormat ftj1 = new SimpleDateFormat ("E yyyy.MM.dd 'at' hh:mm:ss a zzz");
       
        return ftj1.format(dNowj1);
    }
   
    public static String getCurrentTime() {
        Date dNowj1 = new Date();
        SimpleDateFormat ftj1 = new SimpleDateFormat ("yy/MM/dd HH:mm:ss");
       
        return ftj1.format(dNowj1);
    }
   
    public static String getTimeDiff(String dateStart,String dateStop) {
       
        // Custom date format
        SimpleDateFormat format = new SimpleDateFormat("yy/MM/dd HH:mm:ss"); 

        Date d1 = null;
        Date d2 = null;
       
        try {
            d1 = format.parse(dateStart);
            d2 = format.parse(dateStop);
        } catch (ParseException e) {
            e.printStackTrace();
        }        

        // Get msec from each, and subtract.
        long diff = d2.getTime() - d1.getTime();
        long diffSeconds = diff / 1000%60;        
        long diffMinutes = diff / (60 * 1000)%60;        
        long diffHours = diff / (60 * 60 * 1000)%60;    
       
        String timeDiff = diffHours+":" + diffMinutes+":"+ diffSeconds;
        return timeDiff;
    }
   
    public static void wtireLogs(String FilePath, String LogContents) {
        File file = new File(FilePath);
         
        try {
            FileWriter fileWriter = new FileWriter(file,true);
            BufferedWriter bufferFileWriter = new BufferedWriter(fileWriter);
            fileWriter.append(LogContents);
            bufferFileWriter.close();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}

Open source Charts build easily

Tuesday, August 20, 2013

Talend- source file row count



((Integer)globalMap.get("tFileExcelSheetInput_2_NB_LINE"))

Removing the special chaters from a string using user defined function using PHP

1) Function
DELIMITER //
CREATE DEFINER=`platformuser`@`localhost` FUNCTION `fn_RemoveSpecialChars`(`pString` CHAR(50)) RETURNS char(50) CHARSET latin1
    DETERMINISTIC
BEGIN
  DECLARE i, len SMALLINT DEFAULT 1;
  DECLARE CleanString varchar(1000) DEFAULT '';
  DECLARE c CHAR(1);
  DECLARE regx INT(1);

  IF pString IS NULL
  THEN
    RETURN "";
  END IF;

  SET len = LENGTH( pString );
  REPEAT
    BEGIN
      SET c = MID( pString, i, 1 );
      SELECT c REGEXP '[^a-zA-Z0-9 /t/-/_]' into regx;
     
      IF c="" THEN
          SET CleanString=CONCAT(CleanString,' ');
      ELSEIF regx =0 THEN
        SET CleanString=CONCAT(CleanString,c);
      END IF;    
     
      SET i = i + 1;
    END;
  UNTIL i > len END REPEAT;
   RETURN CleanString;
END//
DELIMITER ;

---------------------------------------------------------------------------
output

 SELECT fn_RemoveSpecialChars('welcone world !#@#@');

 Result: welcome world

Thursday, July 18, 2013

How to Solve Port 80 Problems When Running Apache on Windows

There are a number of well-known Windows programs which use port 80:
IIS
The most likely culprit is Microsoft Internet Information Server. You can stop the service from the command line on Windows 7/Vista:
net stop was /y
or XP:
net stop iisadmin /y
SQL Server Reporting Services
SSRS can remain active even if you uninstall SQL Server. To stop the service:
  1. Open SQL Server Configuration Manager.
  2. Select “SQL Server Services” in the left-hand pane.
  3. Double-click “SQL Server Reporting Services”.
  4. Hit Stop.
  5. Switch to the Service tab and set the Start Mode to “Manual”.
Skype
Irritatingly, Skype can switch to port 80. To disable it, select Tools > Options > Advanced > Connection then uncheck “Use port 80 and 443 as alternatives for incoming connections”.

What’s Using Port 80?

Further detective work is necessary if IIS, SSRS and Skype are not to blame. Enter the following on the command line:
netstat -ao
The active TCP addresses and ports will be listed — locate the line with local address “0.0.0.0:80″ and note the PID value.
Now right-click the task bar and select Start Task Manager. Navigate to the Processes tab and, if necessary, click View > Select Columns… to ensure “PID (Process Identifier)” is checked. You can now locate the PID you noted above. The description and properties should help you determine which application is using the port.
The Task Manager allows you to kill the process, but be a little wary about doing that — especially if it’s “NT Kernel & System”.

Microsoft-HTTPAPI/2.0

NT Kernel & System is an essential service. Stopping it will probably stop Windows in a blue-screeny-like way. Therefore, enter the following at the command line:
telnet 127.0.0.1 80
If you’re faced with a blank screen, type “GET” and hit return. The chances are, you’ll see a line stating that Microsoft-HTTPAPI/2.0 is listening on port 80. If that’s the case, open Services from Administrative Tools and locate “Web Deployment Agent Service”. Stop the service and set it’s startup type to “Manual”.
The Web Deployment Agent Service is deployed with WebMatrix and was the cause of my woes. It may also be distributed with other applications installed using Microsoft’s Web Platform Installer.
That caused me a few frustrating hours so I hope it solves your Apache or WAMP start-up problems.

Wednesday, July 10, 2013

kill a Windows process from the command line with taskkill

The ability to perform tasks from a system’s command line allows those tasks to be used in batch files. This recipe describes several uses of taskkill to terminate Windows processes.

If you know the name of a process to kill, for example notepad.exe, use the following command from a command prompt to end it:
taskkill /IM notepad.exe

This will cause the program to terminate gracefully, asking for confirmation if there are unsaved changes. To forcefully kill the same process, add the /F option to the command line. Be careful with the /F option as it will terminate all matching processes without confirmation.
To kill a single instance of a process, specify its process id (PID). For example, if the desired process has a PID of 827, use the following command to kill it:
taskkill /PID 827

Using filters, a variety of different patterns can be used to specify the processes to kill. For example, the following filter syntax will forcefully kill all processes owned by the user Quinn:
taskkill /F /FI "USERNAME eq Quinn"