In the Platform you should select Oracle & Redhat
How to install apache in CentOS Terminal
Install Apache Server in Terminal CentOS
yum install httpd
Check Status of Apache Server
/etc/init.d/httpd status
Start Apache Server
/etc/init.d/httpd start
Start MySQL Terminal
/etc/init.d/service mysqld start
Check Status of MySQL
/etc/init.d/service mysqld status
How to bind event to newly added Form Element
Javascript Code
Please Note – this doesnt work with old version of js File
$('document').ready(function(){
$('#cboCity').live("change", function(){
alert('Hi there');
});
$('#btnChange').on("click", function(){
changeCities();
});
});
function changeCities()
{
strSelect = "<select id='cboCity' name='cboCity'><option>Chennai</option><option>Mumbai</option></select>";
$('#City').html(strSelect);
}
HTML Code
<input id="btnChange" type="button" name="btnChange" value="Change Me" /></pre> <table> <tbody> <tr> <td> <div id="City"> <select id="cboCity" name="cboCity"><option>Chennai</option><option>Mumbai</option><option>Delhi</option><option>Kolkatta</option><option>Andrapradesh</option> </select> </div> </td> </tr> </tbody> </table>
Getting Records from Multiple Result sets in PHP
Table Structure
CREATE TABLE Areas(AreaName VARCHAR(255),
PinCode VARCHAR(255))
INSERT INTO Areas(AreaName, PinCode)
VALUES('Teynampet', '6000018'),
('Ramapuram', '6000089'),
('TNagar', '6000017'),
('Mylapore', '6000014'),
('Gopalapuram', '6000087')
Procedure which returns multiple result sets
DROP PROCEDURE IF EXISTS mp_test1; CREATE PROCEDURE mp_test1() BEGIN SELECT AreaName FROM Areas; SELECT PinCode FROM Areas; END
Procedure Call
CALL mp_test1()
PHP Code To retrieve Records from Multiple Resultsets
$mysqli = new mysqli('localhost', 'root', '', 'test','3306');
$query = "CALL mp_test1()";
$i = 0;
if ($mysqli->multi_query($query))
{
do {
/* store first result set */
if ($result = $mysqli->use_result())
{
$j = 0;
while ($row = $result->fetch_row())
{
$arrResult[$i][$j] = $row[0];
$j++;
}
$result->close();
}
if($mysqli->more_results())
{
$i = $i + 1;
}
} while ($mysqli->next_result());
}
print "";
print_r($arrResult);
Building Dynamic Query in Mysql Stored Procedure
Table Structure
CREATE TABLE Areas(AreaName VARCHAR(255),
PinCode VARCHAR(255))
INSERT INTO Areas(AreaName, PinCode)VALUES
('Teynampet', '6000018'),
('Ramapuram', '6000089'),
('TNagar', '6000017'),
('Mylapore', '6000014'),
('Gopalapuram', '6000087')
Stored Procedure
DROP PROCEDURE IF EXISTS mp_test;
CREATE PROCEDURE mp_test(IN pArea VARCHAR(255))
BEGIN
SET @Query = '';
SET @City = '';
SET @Query = 'SELECT PinCode FROM Areas';
IF pArea != '' THEN
SET @City = CONCAT(' WHERE AreaName = "', pArea, '"');
END IF;
SET @Query = CONCAT(@Query, @City);
PREPARE stmt FROM @Query;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
END
JQuery DOM Functions
How to Get the Fist Tag within List of Tags
$(this).parent().find('.TickImgCont');
Effect of extends and Object over constructor and parent class
How Static and Constructor will work when class is Extended
public class Main2 extends A
{
public static void main(String args[])
{
}
}
class A extends B
{
A()
{
System.out.println("I am A Constrctor");
}
static
{
System.out.println("I am Static Method");
}
{
System.out.println("Empty");
}
}
class B
{
B()
{
System.out.println("I am B Constrctor");
}
}
OP:I am Static Method
How Static and Constructor will work when class object is Created
public class Main2 extends A
{
public static void main(String args[])
{
A objA = new A();
}
}
class A extends B
{
A()
{
System.out.println("I am A Constrctor");
}
static
{
System.out.println("I am Static Method");
}
{
System.out.println("Empty");
}
}
class B
{
B()
{
System.out.println("I am B Constrctor");
}
}
OP:I am Static Method
I am B Constrctor
Empty
I am A Constrctor
How to store CSV in hidden Field Javascript
How to Store CSV Ids in Hidden Field
Script
function AddProjectId(pProjectId)
{
var arrProjectIds = new Array();
var strComma = '';
csvProjectIds = $('#hdnInterestedProjectIds').val();
csvProjectIds = $.trim(csvProjectIds);
if (csvProjectIds != '')
{
arrProjectIds = csvProjectIds.split(', ');
lngArrLength = arrProjectIds.length;
} else {
lngArrLength = 0;
}
if (arrProjectIds.indexOf(pProjectId) != 0) {
if (lngArrLength > 0)
strComma = ', ';
csvProjectIds = csvProjectIds + strComma + pProjectId;
}
$('#hdnInterestedProjectIds').val(csvProjectIds);
}
function RemoveProjectId(pProjectId)
{
csvProjectIds = $('#hdnInterestedProjectIds').val();
csvNewProjectIds = '';
arrProjectids = csvProjectIds.split(', ');
arrNewProjectIds = new Array();
lngArrLength = arrProjectids.length;
for (i = 0; i < lngArrLength; i++)
{
if (arrProjectids[i] != pProjectId)
{
arrNewProjectIds.push(arrProjectids[i]);
}
}
for (i = 0; i < arrNewProjectIds.length; i++)
{
strComma = '';
if ((csvNewProjectIds != '') && (arrNewProjectIds.length != (arrNewProjectIds.length - 1)))
strComma = ', ';
csvNewProjectIds = csvNewProjectIds + strComma + arrNewProjectIds[i];
}
$('#hdnInterestedProjectIds').val(csvNewProjectIds);
}
<input type=”hidden” name=”hdnInterestedProjectIds” id=”hdnInterestedProjectIds”/>
Working with javascript Arrays
How to Split CSV into array
csvProjectIds = '1,2,3,4';
arrProjectIds = csvProjectIds.split(',');
Output
arrProjectIds[0] = 1
arrProjectIds[1] = 2
arrProjectIds[2] = 3
arrProjectIds[3] = 4
How to Find Element is in Array
csvProjectIds = '1,2,3,4';
arrProjectIds = csvProjectIds.split(',');
alert(arrProjectIds.indexOf('1'));
Output
0
The indexOf Returns 0 incase the element is in the array or
-1 if not in the array
Initiation Order
What would be the Output
public class Main
{
static
{
System.out.println("My Name is Mugil");
}
}
OP: My Name is Mugil
followed by exception in Main
public class Main
{
static
{
System.out.println("My Name is Mugil");
}
public static void main(String args[])
{
{
System.out.println("What is your Name");
}
}
}
OP: My Name is Mugil
What is your Name
public class Main
{
public static void main(String args[])
{
{
System.out.println("What is your Name");
}
}
}
OP: What is your Name
4.What is the order they are processed
public class Main
{
public static void main(String args[])
{
{
ClassA objA = new ClassA();
System.out.println("What is your Name");
}
}
}
class ClassA
{
static
{
System.out.println("I am in ClassA Static");
}
ClassA()
{
System.out.println("I am in ClassA Constrctor");
}
{
System.out.println("I am in ClassA");
}
}
OP:I am in ClassA Static
I am in ClassA
I am in ClassA Constrctor
What is your Name
Static blocks are initiated at first followed by Constructor followed by classA and content in empty class.
5.How to Use Object to invoke function in Class
public class Main2
{
public static void main(String args[])
{
new A().showName();
}
}
class A
{
public void showName()
{
System.out.println("Hi there");
}
}
OP : Hi there
6.How to Find Class of object
public class Main3
{
public static void main(String[] args)
{
ClasB objB = new ClasB();
if(objB instanceof ClasB)
{
System.out.println(objB.getClass().getName());
}
}
}
class ClasB
{
}