Thursday, 25 August 2016

How to know the number of tables in a db schema

 SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'testSchema';
     Here "testSchema" is the schema name.

How to wait the ajax submission ,upto response not prepared.

The below is the code snipset.

$.ajax({
        url: $(this).attr('href'),
        type: 'GET',
        async: false,
        cache: false,
        timeout: 30000,

From above "async: false" is required to wait the response.

How to restrict form submission in jquery(Bassically when AJAX form submisssion)

  $("#emailAttach").unbind('submit');

   Here "emailAttach" is form name.
In ajax form submission ,if any javascript validation is there and want to return as false then unbind the form because ,after return false also the next line is execute in ajax form submission.

How to create batch file

 @echo off
java -cp "./image/AppProfileNov11.gif;Test.jar" com.ckt.SampleProgram
pause



Explanation:

   The above 3 line create batch file where ;                     |
  ./image/AppProfileNov11.gif : Image to add in the program.(optional, as per requirment)
  Test.jar : The application jar file name.                        |
  com.ckt.SampleProgram :  class name including package name.|


How to know the Mysql version

 SHOW VARIABLES LIKE  '%version%' ;
 SHOW VARIABLES LIKE  '%engine%' ; 

How to know my MySql port number

SHOW VARIABLES WHERE Variable_name = 'port'

Saturday, 9 July 2016

How to read file in javascript

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
        <style type="text/css">
            #filecontents {
                border:double;
                overflow-y:scroll;
                height:400px;
            }
        </style>
    </head>
    <body>
        <script>
            window.onload = function () {
                //Check the support for the File API support
                if (window.File && window.FileReader && window.FileList && window.Blob) {
                    var fileSelected = document.getElementById('txtfiletoread');
                    fileSelected.addEventListener('change', function (e) {
                        //Set the extension for the file
                        var fileExtension = /text.*/;
                        //Get the file object
                        var fileTobeRead = fileSelected.files[0];
                        //Check of the extension match
                        if (fileTobeRead.type.match(fileExtension)) {
                            //Initialize the FileReader object to read the 2file
                            var fileReader = new FileReader();
                            fileReader.onload = function (e) {
                                var fileContents = document.getElementById('filecontents');
                                fileContents.innerText = fileReader.result;
                            };
                            fileReader.readAsText(fileTobeRead);
                        }
                        else {
                            alert("Please select text file");
                        }

                    }, false);
                }
                else {
                    alert("Files are not supported");
                }
            };


        </script>
        Please Select text file of which contents are to be read:
        <input type="file" id="txtfiletoread" />
        <div>The File Contents are as below:</div>
        <div id="filecontents">
        </div>
    </body>
</html>