Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!

Sanny kumar

Ranch Hand
+ Follow
since May 18, 2005
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Sanny kumar

Hi,

Can you please answer the questions?
1.What is the type of the �target� data member of the Thread class?
2.How is �target� used to support running direct subclass of the Thread class versus running class implementing Runnable interface?

Thanks
Santhosh
Hi Guys,

I have a simple question ejb.in stateful session if a client is accessing the resource s and now client is idle for 5 mins.at this stage the instance will be stored in passivate method.now client want to access the resources(using activate).now will the client get the same instance or different instance?
Hi Guys,

can you pleas explain the steps for creating webservices



Thanks
Santhosh
11 years ago
Hi Guys,

Can we use a java class in XSL?


Thanks
Santhosh
Hi Guys,

Can you please tell me how state is maintained in stateful session bean?

Whether Transaction attributes involved in Session bean / not?

Thanks in advance
Santhosh
Hi Guys,

can you please exaplain what is renderer concept?i m new to JSF..

JSF is multiple requests and multiple responses framework unlike sturts i.e one request and one response.am i right?please answer to my questions..

Thanks in advance
11 years ago
JSF
Hi Guys,
I m writing a java program to get the sequence of number if the from no and to num is given

example
if i give from 1 to 10
the o/p is:
1
2
3
4
5
6
7
8
9
10
this works fine but whn i enter 0001 to 0010
the o/p is same as of the above.
bt i wan to display the value as follows:
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
The sample program as follows:
import java.io.*;

public class Generator{

public static void main(String args[])
{
long arg1=Long.parseLong(args[0]);
long arg2=Long.parseLong(args[1]);


try {
BufferedWriter out = new BufferedWriter(new FileWriter("generate.csv"));
for(long i=arg1;i<=arg2;i++){

out.write("\""+i+"\"");
out.write("\r\n");
}
out.close();
} catch (IOException e) {
}



}
}

any suggestions?

Thanks in advance
Santhosh
11 years ago
Hi Guys,

I want to add +4 hours to the existing date and display in the text box..

the date format is 14-Sep-2006 10:58:17 PM

i want to add 4 hours and display in the text box..


any suggestions?


thanks and Regards
Santhos
Hi James,

Thanks for the code..i tried but i m unable to create multiple files.
the number is
the file number name is a1.txt
823
3232
232
233
3232
end number
the number is
the file number name is a2.txt
823
3232
232
233
3232
end number
the number is
the file number name is a3.txt
823
3232
232
233
3232
end number
the number is
the file number name is a4.txt
823
3232
232
233
3232
end number
the number is
the file number name is a5.txt
823
3232
232
233
3232
end number


my requirement is i want to create separate files if the string starts from "the number is" and ends with "end number" its one file..
ex:
the number is
the file number name is a5.txt
823
3232
232
233
3232
end number
this is one file with the file name a5.txt..vice versa i want to read the complete file and create separate files if the string starts with "the number is" and string ends with "end number"..

thanks in advance
San
11 years ago
Hi guys,

i m having problem with reading the large file and splitting the file inot multiple files..

the sample large file as follows:
================================
the number is
the file number name is a1.txt
823
3232
232
233
3232
end number
the number is
the file number name is a2.txt
823
3232
232
233
3232
end number
the number is
the file number name is a3.txt
823
3232
232
233
3232
end number
the number is
the file number name is a4.txt
823
3232
232
233
3232
end number
the number is
the file number name is a5.txt
823
3232
232
233
3232
end number

i want to create separate files reading the file.ex:in the above sample file it should create files if the line starts with the "number is--" and ends with "end number.." like this i want to create file reading the complete large file..
i m able to read the file but i m not able to write into files...
sample code as follos:
import java.io.*;

public class Pintest {

public static void main (String[] args) throws Exception {
Pintest f = new Pintest();
String pfile=args[0];
f.readMyFile(pfile);
}



void readMyFile(String file) {

try {
BufferedReader in = new BufferedReader(new FileReader(file));
String str;
int count=2;

while ((str = in.readLine()) != null) {
count++;
if(str.startsWith("the number is")){
int cnt=count+2;
BufferedWriter out = new BufferedWriter(new FileWriter("pin"+count+".pin"));
System.out.println(str);
in.readLine();
out.write(str);
}


}
in.close();
} catch (Exception e) {
}
}

}


here i m getting only one line output i.e.."the number is" in the every generate file..

thanks in advance
11 years ago
Hi guys,

i m having problem with reading the large file and splitting the file inot multiple files..

the sample large file as follows:
================================
the number is
the file number name is a1.txt
823
3232
232
233
3232
end number
the number is
the file number name is a2.txt
823
3232
232
233
3232
end number
the number is
the file number name is a3.txt
823
3232
232
233
3232
end number
the number is
the file number name is a4.txt
823
3232
232
233
3232
end number
the number is
the file number name is a5.txt
823
3232
232
233
3232
end number

i want to create separate files reading the file.ex:in the above sample file it should create files if the line starts with the "number is--" and ends with "end number.." like this i want to create file reading the complete large file..
i m able to read the file but i m not able to write into files...
sample code as follos:

[JCE: Added code tags]
[ August 31, 2006: Message edited by: Joe Ess ]
11 years ago
Hi Guys ,

I m strucked with sql query and i m nt getting correct output..

The table script,sample sql query and desired output as follows:

CREATE TABLE OPS_MASTER (
SLNO NUMBER,
COMP_CIRCLE VARCHAR2(10),
COMP_STATUS VARCHAR2(10),
ENTERED_DATE DATE,
CLOSED_DATE DATE)

The Testdata:
----------------
INSERT INTO OPS_MASTER ( SLNO, COMP_CIRCLE, COMP_STATUS, ENTERED_DATE,
CLOSED_DATE ) VALUES (
1, 'A', 'CLOSED', TO_Date( '07/11/2006 05:20:50 PM', 'MM/DD/YYYY HH:MI:SS AM'), TO_Date( '07/11/2006 08:20:50 PM', 'MM/DD/YYYY HH:MI:SS AM'));
INSERT INTO OPS_MASTER ( SLNO, COMP_CIRCLE, COMP_STATUS, ENTERED_DATE,
CLOSED_DATE ) VALUES (
2, 'B', 'OPEN', TO_Date( '07/11/2006 03:21:13 PM', 'MM/DD/YYYY HH:MI:SS AM'), TO_Date( '07/11/2006 08:21:13 PM', 'MM/DD/YYYY HH:MI:SS AM'));
INSERT INTO OPS_MASTER ( SLNO, COMP_CIRCLE, COMP_STATUS, ENTERED_DATE,
CLOSED_DATE ) VALUES (
3, 'A', 'OPEN', TO_Date( '07/11/2006 07:21:33 PM', 'MM/DD/YYYY HH:MI:SS AM'), TO_Date( '07/11/2006 08:21:33 PM', 'MM/DD/YYYY HH:MI:SS AM'));
INSERT INTO OPS_MASTER ( SLNO, COMP_CIRCLE, COMP_STATUS, ENTERED_DATE,
CLOSED_DATE ) VALUES (
4, 'B', 'CLOSED', TO_Date( '07/11/2006 01:21:51 PM', 'MM/DD/YYYY HH:MI:SS AM'), TO_Date( '07/11/2006 08:21:51 PM', 'MM/DD/YYYY HH:MI:SS AM'));
INSERT INTO OPS_MASTER ( SLNO, COMP_CIRCLE, COMP_STATUS, ENTERED_DATE,
CLOSED_DATE ) VALUES (
5, 'B', 'CLOSED', TO_Date( '07/11/2006 03:21:55 PM', 'MM/DD/YYYY HH:MI:SS AM'), TO_Date( '07/11/2006 08:21:55 PM', 'MM/DD/YYYY HH:MI:SS AM'));
INSERT INTO OPS_MASTER ( SLNO, COMP_CIRCLE, COMP_STATUS, ENTERED_DATE,
CLOSED_DATE ) VALUES (
6, 'A', 'CLOSED', TO_Date( '07/11/2006 02:22:03 PM', 'MM/DD/YYYY HH:MI:SS AM'), TO_Date( '07/11/2006 08:22:03 PM', 'MM/DD/YYYY HH:MI:SS AM'));
INSERT INTO OPS_MASTER ( SLNO, COMP_CIRCLE, COMP_STATUS, ENTERED_DATE,
CLOSED_DATE ) VALUES (
7, 'B', 'OPEN', TO_Date( '07/11/2006 07:22:15 PM', 'MM/DD/YYYY HH:MI:SS AM'), TO_Date( '07/11/2006 08:22:15 PM', 'MM/DD/YYYY HH:MI:SS AM'));
INSERT INTO OPS_MASTER ( SLNO, COMP_CIRCLE, COMP_STATUS, ENTERED_DATE,
CLOSED_DATE ) VALUES (
8, 'A', 'OPEN', TO_Date( '07/11/2006 11:22:22 AM', 'MM/DD/YYYY HH:MI:SS AM'), TO_Date( '07/11/2006 08:22:22 PM', 'MM/DD/YYYY HH:MI:SS AM'));
INSERT INTO OPS_MASTER ( SLNO, COMP_CIRCLE, COMP_STATUS, ENTERED_DATE,
CLOSED_DATE ) VALUES (
9, 'A', 'CLOSED', TO_Date( '07/11/2006 08:22:33 PM', 'MM/DD/YYYY HH:MI:SS AM'), TO_Date( '07/11/2006 08:22:33 PM', 'MM/DD/YYYY HH:MI:SS AM'));
INSERT INTO OPS_MASTER ( SLNO, COMP_CIRCLE, COMP_STATUS, ENTERED_DATE,
CLOSED_DATE ) VALUES (
10, 'B', 'OPEN', TO_Date( '07/11/2006 08:22:50 PM', 'MM/DD/YYYY HH:MI:SS AM'), TO_Date( '07/11/2006 08:22:50 PM', 'MM/DD/YYYY HH:MI:SS AM'));
commit;

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




The Required Output is:

Comp_circle|| <1 hr(Closed)|| B/W 1 to 2hrs(Closed)|| >=2hrs(Closed) || total(Closed)|| <1hr open || b/w 1 hr and 2 hrs (Open)|| >2hrs(Open)||Total(Open)
=================================
The sample query:
SELECT A.comp_circle,A.LESS_1,A.LESS_2,A.MORE_4,B.OPEN_1,B.OPEN_2,B.OPEN_4 FROM
(SELECT A.comp_circle,A.LESS_1,A.LESS_2,B.MORE_4 FROM
(SELECT A.comp_circle,A.LESS_2,B.LESS_1 FROM
(SELECT comp_circle,COUNT(comp_status) LESS_2 FROM OPS_MASTER WHERE
((CLOSED_DATE - ENTERED_DATE)*24 > 1 and (CLOSED_DATE - ENTERED_DATE)*24<=2)
and COMP_STATUS ='CLOSED' and TRUNC(ENTERED_DATE)=TRUNC(SYSDATE) AND
COMP_CIRCLE IN ('A','B') group by COMP_CIRCLE,COMP_STATUS) A,
(SELECT comp_circle,COUNT(comp_status) LESS_1 FROM OPS_MASTER WHERE
(CLOSED_DATE - ENTERED_DATE)*24 <= 1 and COMP_STATUS ='CLOSED' and
TRUNC(ENTERED_DATE)=TRUNC(SYSDATE) AND COMP_CIRCLE IN ('A','B') group by COMP_CIRCLE,COMP_STATUS) B
WHERE A.COMP_CIRCLE=B.COMP_CIRCLE(+)) A,
(SELECT comp_circle,COUNT(comp_status) MORE_4 FROM OPS_MASTER WHERE
(CLOSED_DATE - ENTERED_DATE)*24 > 2 and COMP_STATUS ='CLOSED' and
TRUNC(ENTERED_DATE)=TRUNC(SYSDATE) AND COMP_CIRCLE IN ('A','B') group by COMP_CIRCLE,COMP_STATUS) B WHERE A.COMP_CIRCLE=B.COMP_CIRCLE(+)) a,
(SELECT A.comp_circle,A.OPEN_1,A.OPEN_2,B.OPEN_4 FROM (SELECT A.comp_circle,A.OPEN_2,B.OPEN_1 FROM (SELECT comp_circle,COUNT(comp_status) OPEN_2 FROM OPS_MASTER WHERE
((SYSDATE-ENTERED_DATE)*24 > 1 and (SYSDATE-ENTERED_DATE)*24<=2) and COMP_STATUS ='OPEN' and TRUNC(ENTERED_DATE)=TRUNC(SYSDATE) AND COMP_CIRCLE IN ('A','B') group by COMP_CIRCLE,COMP_STATUS) A,
(SELECT comp_circle,COUNT(comp_status) OPEN_1 FROM OPS_MASTER WHERE (SYSDATE-ENTERED_DATE)*24 <= 1 and COMP_STATUS ='OPEN' and TRUNC(ENTERED_DATE)=TRUNC(SYSDATE) AND COMP_CIRCLE IN ('A','B') group by COMP_CIRCLE,COMP_STATUS) B WHERE A.COMP_CIRCLE=B.COMP_CIRCLE(+)) A,
(SELECT comp_circle,COUNT(comp_status) OPEN_4 FROM OPS_MASTER WHERE (SYSDATE-ENTERED_DATE)*24 > 2 and COMP_STATUS ='OPEN' and TRUNC(ENTERED_DATE)=TRUNC(SYSDATE) AND COMP_CIRCLE IN ('A','B') group by COMP_CIRCLE,COMP_STATUS) B WHERE A.COMP_CIRCLE=B.COMP_CIRCLE(+)) B WHERE A.comp_circle=B.comp_circle(+)
===================================

can any one help?
Hi Guys,
I m writing a java program to get the sequence of number if the from no and to num is given

example
if i give from 1 to 10
the o/p is:
1
2
3
4
5
6
7
8
9
10
this works fine but whn i enter 0001 to 0010
the o/p is same as of the above.
bt i wan to display the value as follows:
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
The sample program as follows:
import java.io.*;

public class Generator{

public static void main(String args[])
{
long arg1=Long.parseLong(args[0]);
long arg2=Long.parseLong(args[1]);


try {
BufferedWriter out = new BufferedWriter(new FileWriter("generate.csv"));
for(long i=arg1;i<=arg2;i++){

out.write("\""+i+"\"");
out.write("\r\n");
}
out.close();
} catch (IOException e) {
}



}
}

any suggestions?

Thanks in advance
Santhosh
11 years ago
Hi Guys,

I want to write afuncion to get the text boxes dynamically if the message contains PX(index of PX).
i have written a function but i m getting a a text box if the the message doesnt contain any index of PX.

the sample code as follows..

<script>
var htmlstr='';
function populate(par) {


var param;
var count=0;
var currNode;
htmlstr='';
XMLID.async = false;
XMLID.load("getdata.jsp?rtype="+par);

objNodeList = XMLID.getElementsByTagName("MSG");
if(objNodeList.length>0){
document.f1.msg.value = objNodeList.item(0).text;
}
objNodeList = XMLID.getElementsByTagName("PARAM");
if(objNodeList.length>0){
param = objNodeList.item(0).text;
var sparam=param.split(",");
if(sparam.length>0){
var msgs=document.f1.msg.value;
var s=0;
var e=0;
for(var i=0;i<sparam.length;i++){
e=msgs.indexOf('PX'+sparam[i].toUpperCase());
htmlstr+=msgs.substring(s,e)+"<input type=text name='"+sparam[i]+"'>";
s=e+sparam[i].length+2;

}
htid.innerHTML=htmlstr;
}
}


}

<body>
<tr>
<td width="268"><b>
<font face="Verdana" color="#4D6EB0" size="2">
Shortcode</font></b></td>
<td width="181">
<select size="1" name="shortcode" onChange="return populate(this.value)" style="color: #4D6EB0; font-size: 10pt; font-family: Verdana; font-weight: bold">
<option selected value="SELECT">---Select Shortcode---
</option>
<% while(rs.next()){%>
<option value="<%=rs.getString(1)%>"><%=rs.getString(1)%></option>
<%}%>
</select></td>
</tr>

<div id="htid"></div>


any suggestins?
Thanks in advance
Santhosh