Thursday, 17 October 2013

Getting Xml Tag Values using Stack in Java (Applicable to HTML tags) - Parsing



Method Functionality
  •  This method is used to parse the given XML / HTML Entry containing tags.
  •  The values inside the tags are pushed into the Stack.
  •  You can retrieve the values later from the stack by knowing the depth of the Element
Input
<student>
         <name>Nijin</name>
         <college>SSN</college>
         <city>Chennai</city>
</student>

Output
[Nijin, SSN,Chennai]

Program
public String getValueFromXmlKey(String xmlEntry, int pos){
String value= null;
boolean tagDetected = false;

Stack<String> stack = new Stack<String>();

//Converting String to char Array
char[] xmlEntryArray = xmlEntry.toCharArray();

String elements = "";
for(char c:xmlEntryArray){
if(tagDetected==false){
if(c=='<'){ //Searching for opening tag
tagDetected = true;
if(elements!=""){
stack.push(elements);
}
elements = "";
}
else{
elements += c;
}
}
else{
if(c=='>'){ //Searching for closing tag
tagDetected = false;
}
}
}
System.out.println(stack.get(pos));
return stack.get(pos);
}

Wednesday, 16 October 2013

String is immutable in Java

String has a concat(String) method which is used for concatenating.

Illustration
String string1 = "Java";
string1.concat("Programming");
System.out.println(string1);

So, guess what will be string1?

JavaProgramming ??
No!!

Its, still Java
Because Strings are immutable in Java

Sunday, 13 October 2013

JDBC-ODBC Connectivity [MS Access]

Procedure
1.Go to Control Panel
2.Click Administrative Tools -- Click Data Sources(ODBC)
3. Now ODBC Data Source Administrator Dialog Box gets opened.
4. Now click System DSN, a dialog box appears and then click Add..
5. Create New Data Source dialog box gets opened and then click Driver Do Microsoft Access (*.mdb) and click Finish.
6. When you click finish, ODBC Microsoft Access Setup gets opened
Fill the following information
Data Source Name: MyDatabase (note:any name, which you will be calling in your program)
Description: <anything>
7. Click Select and locate your mdb file
8. Click OK for all opened dialog boxes. You have successfully created a connection for MS-ACCESS

Oracle Forms Customization

Objective
To create Forms for Banking Application Using Oracle 10g Forms as front end and Oracle 10g as backend.

Table Structure
Table 1.

trans_detrails(trans_id,acc_no,cust_name,acc_type,trans_type,trans_date,trans_amt) where acc_no is account reference,account type=[savings,current],transaction type=[deposit,withdraw]

Table 2.

account(acc_no,balance)

Software Requirements
[1] Oracle Forms 10G
[2] Oracle 10G

Continue