Need platform independent java code for TNS PING
Hi, I am able to ping server /ip address. but unable to ping some TNS entry.
There is one way to ping TNS entry using System command, but that will make my code platform dependent. i want platform independent code.. need code help for TNS Ping to database server.. here are my code:
---Code for server / Ip address ping:---------
package DBM;
import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
import oracle.net.TNSAddress.*;
public class PingServer
public static void main(String[] args)
System.out.println(" Server Pinging Starts...");
ArrayList<String> list=new ArrayList<String>();
list.add("g5u0660c.atlanta.hp.com");
list.add("g1u1675c.austin.hp.com");
list.add("gvu1785.atlanta.hp.com");
list.add("10.130.14.109");
list.add("10.130.0.173");
list.add("DESCRIPTION = (SDU = 32768) (enable = broken) (LOAD_BALANCE = yes) (ADDRESS = (PROTOCOL = TCP)(HOST = gvu1515.atlanta.hp.com)(PORT = 1525))(ADDRESS = (PROTOCOL = TCP)(HOST = gvu1785.atlanta.hp.com)(PORT = 1525)");
list.add("IDSENGI");
//This Ipadd variable is used to convert the arraylist into String
String ipadd="";
try
for(String s: list)
ipadd=s;
// InetAddress is class.in this class getByName()is used to take only string parameter.
InetAddress inet = InetAddress.getByName(ipadd);
//InetAddress inet1 =InetAddress.getAllByName("IDESENGP");
System.out.println("Sending Ping Request to " + ipadd);
//in InetAddress call IsReachabe(3000)method is used to ping the server IP and if ping is successfully then return true otherwise false.
//IsReachable()take time in millisecond and return type is boolean.
System.out.println("Host is reachable: "+inet.isReachable(3000));
System.out.println("Server Pinging program is working fine........");
catch (UnknownHostException e)
System.err.println("Host does not exists");
catch (IOException e)
System.err.println("Error in reaching the Host");
----Code for TNS ping using system host----
package DBM;
import java.io.*;
public class doscmd
public static void main(String args[])
try
Process p=Runtime.getRuntime().exec("cmd /c tnsping IDSENGP");
p.waitFor();
BufferedReader reader=new BufferedReader(new InputStreamReader(p.getInputStream()));
String line=reader.readLine();
while(line!=null)
System.out.println(line);
line=reader.readLine();
catch(IOException e1) {}
catch(InterruptedException e2) {}
System.out.println("Done");
The above two codes are working absolutely fine... but need TNS ping program is platform dependent..we need to deploy it in both windows, unix...
Please help.
You don't need to install another JDK, just use the api from 1.2 and you should be fine. You can even use the 1.4 jdk to compile as if it were 1.2 by using the -target option in javac.
Similar Messages
-
If any one has java code for any video compression algorithm
i need a complete java code for video compression step by step
i need a complete java code for video compression step by step
-
I Need Java code for following Algorithm
* I Need Java code for following algorithm. Kindly any one help.
1. Read the contents (ideas and its corresponding scores) from two files named as 'a' and 'b'.
2. Stored the file 'a' contents in array a[].
3. Stored the file 'b' contents in array b[].
4. compare both files like
if(a.equals(b[j])
Writing the common idea and add the score from file 'a' and 'b'.
else
write the uncommon idea and its score..
For example :
Form Agents.txt
action,65
architecture,85
eco-,15
essay,30
form,85
form,85
link,40
tangent,25
Form Agents1.txt
Black holes,69
essay,78
Herewith i have above mentioned two files named as Form Agents and Form Agents1.
Form Agents has eight fields
Form Agents1 has two fields
--> 'essay' is common in two files, so store the idea 'essay' and add the score from Form Agents score is '30' and Form Agents1 has 78 (essay 108).
Finally it stores idea in another file with uncommon fields also.
Please help us.We have tried with following code.
But we cant add the scores.
For Example:
Form Agents.txt --> has "essay,30"
Form Agents1.txt --> has "essay,78"
Result is: essay,108
Finally it stores idea in another file with uncommon fields also.
So Any one pls correct the following code.
try
DataOutputStream o1=new DataOutputStream(new
FileOutputStream("C:\\Interfaces\\interfaces\\temp\\BlackBoard\\My Design
World\\Project\\Material\\art\\System Agents\\Form Agents\\CandidateResponses\\Form
Agents.txt"));
//Reading the contents of the files
BufferedReader br= new BufferedReader(new InputStreamReader(new
FileInputStream("C:\\Interfaces\\interfaces\\temp\\BlackBoard\\My Design
World\\Project\\Material\\art\\System Agents\\Form Agents\\Ideological\\Form
Agents.txt")));
BufferedReader br1= new BufferedReader(new InputStreamReader(new
FileInputStream("C:\\Interfaces\\interfaces\\temp\\BlackBoard\\My Design
World\\Project\\Material\\art\\System Agents\\Form Agents\\Related\\Form
Agents.txt")));
while((s=br.readLine())!=null)
s1+=s+"\n";
while((s2=br1.readLine())!=null)
s3+=s2+"\n";
int numTokens = 0;
StringTokenizer st = new StringTokenizer(s1);
String[] a = new String[10000];
String[] br_n=new String[10000];
int i=0;
while (st.hasMoreTokens())
s2 = st.nextToken();
a=s2.substring(0,s2.length()-3);
s6=s2.substring(s2.length()-2);
br_n[i]=s6;
i++;
numTokens++;
int numTokens1 = 0;
StringTokenizer st1 = new StringTokenizer (s3);
String[] b = new String[10000];
String[] br1_n=new String[1000];
int j=0;
while (st1.hasMoreTokens())
s4 = st1.nextToken();
b[j]=s4.substring(0,s4.length()-3);
s7=s4.substring(s4.length()-2);
br1_n[j]=s7;
j++;
numTokens1++;
int x=0;
for(int m=0;m<a.length;m++)
for(int n=0;n<b.length;n++)
if(a[m].equalsIgnoreCase(b[n])){
int sc=Integer.parseInt(br_n[m]);
int sc1=Integer.parseInt(br1_n[n]);
int score=sc+sc1;
o.writeBytes(a[m]+","+score+"\n");
break;
else
o.writeBytes(a[m]+","+br_n[m]+"\n");
break;
}catch(Exception e){} -
I need java code for chating application
i need java code for chating application. plz help me
GANGINENI wrote:
i need java code for chating application. plz help meGIYF.
[http://today.java.net/pub/a/today/2006/10/05/instant-messaging-for-jabber-with-smack.html|http://today.java.net/pub/a/today/2006/10/05/instant-messaging-for-jabber-with-smack.html]
File under: lern2Google -
Hard drive died. Cannot uninstall CS3 to remove copy registration. Need to reinstall on new laptop with windows 7 64 bit system, Need to get activation code for CS3 Web Premium.
Thank you Bob.
Just to clarify - in terms of backing up one set of these, would that just be so I had it on disk and didn't need to re-download from Adobe if the installation got corrupted somehow? Or do I need a backup for some other reason?
Thanks -
Provide the java code for the following scenario.
Hi Experts,
I have tried with all the combinations for this scenario. As per my understanding i require java code for the following scenario
so that it becomes easy........
I require a Message mapping for this Logic.
In the Source there are 4 fields and, the Target side, the fields should appear like this.
Source Structure- File
Record
|-> Header
Order_No
Date
|-> Item
Mat_No
Quantity
Target Structure-IDoc
IDoc
|-> Header
|-> Segment
Delivery_Order_No
Recv_Date
|-> Item
|-> Segment
Delivery_Order_No
Material_Num
Recv_Quantity.
The Logic is for every Order number an IDOC is generated.And if the Material num matches then the quantity should be added. and important note is that the material numbers are different for every order number. That means if a material number is 2 in the order number A. Then the material number can never be 2 in any of the order numbers.Here is the following with an example for the above scenario.
For example:-
we have
Source Structure- File
Order-no Date Mat_No Quantity
1 01/02/2011 A 10
1 01/02/2011 B 15
1 01/02/2011 A 10
2 01/02/2011 C 10
2 01/02/2011 C 10
3 01/02/2011 D 20
3 01/02/2011 D 10
3 01/02/2011 E 25
Target Structure-IDoc
Delivery_Order_No Recv_Date Material_Num Recv_Quantity
1 01/02/2011 A 20
1 01/02/2011 B 15
2 01/02/2011 C 20
3 01/02/2011 D 30
3 01/02/2011 E 25
So for this example total of 5-Idocs created. That means for this example if Order_No is 1 When the Mat_No is A the quantity gets added. For this Scenario 1 IDoc with four Fields 2 in Header(Delivery_Order_No, Recv_Date) and 2 in Item(Material_Num, Recv_Quantity) is generated by adding the quantity field in the Target Side. Similarly if Order_No is 1 when the Mat_No is B then separate IDoc is generated with four Fields 2 in Header(Delivery_Order_No, Recv_Date) and 2 in Item(Material_Num, Recv_Quantity) in the Target Side. Similarly, if Order_No is 2 when the Mat_No is C, an IDoc is generated with four Fields 2 in Header(Delivery_Order_No, Recv_Date) and 2 in Item(Material_Num, Recv_Quantity) by adding the quantity field in the Target Side. ike wise the process goes on upto 3.Kindly do the needy..
Kindly provide the java code.
Thanq very much in advance..what i have understood from ur example is that u want to generate an idoc for unique combination of Order-no and Mat_No
if yes then chk the below mapping..
change the context of Order_No, Date, Mat_No and Quantity to Record (right click-> context)
1)
Order-no
----------------------concat[;]---sort----splitbyvalue(valuechanged)-----collapse context---IDoc
Mat_No
2)
Order-no
--------concat[;]---sort----splitbyvalue(value changed)---collapse context---UDF1--splitbyvalue(each value)--Delivery_Order_No
Mat_No
3)
Order-no
-----------concat[;]---sortbykey----------------------- \
Mat_No / \
Date--------------- / \
----------------------------------------------------------FormatByExample-----collapsecontext---splitbyvalue(each value)----Recv_Date
Order-no /
-----------concat[;]---sort----splitbyvalue(value changed)
Mat_No
4)
Order-no
--------concat[;]---sort----splitbyvalue(value changed)---collapse context-UDF2--splitbyvalue(each value)--Material_Num
Mat_No
5)
Order-no
-----------concat[;]---sortbykey
Mat_No /
Quantity --------------- /
----------------------------------------------------------FormatByExample-----SUM(under statistic)----Recv_Quantity
Order-no
-----------concat[;]---sort----splitbyvalue(value changed)
Mat_No
UDF1:
String [] temp= a.split(";");
return temp[0];
UDF2:
String [] temp= a.split(";");
return temp[1]; -
Creating Java code for the function module
Hi Colleagues,
I have a fuction module in ABAP system. Now I want to Generate java code for the FM.
I cam to know that we can achive that using AXIS, By getting the XML file for the fuction module and generate Java
Class file using that XML file.
Can any one tell me how to achive it.
Or any other way to do that?
Please provide you valid suggestions.
Regards,
SathyaHi,
You can integrate axis2 in eclipse. I think you have to find the plugin for that.
After that you can let axis generate the jave code (stubs and proxies) for your web service via the wsdl file.
Kind Regards,
Robin -
java code for intrusion detection system
hi
how can i write a java code for intrusion detection system wireless network (steps)
help please whith any documentation , exemples , name of packages thank youhi
anyone have code source java projet of an IDS intrusion detection system for VANET and thank you -
Hi,
Here are the steps to reproduce the problem with the examplesWebApp application
bundled with wlserver6.0(sp2):
Product: Weblogic server 6.0 (sp2)
Browser: IE 5.0
1. Add index.jsp as the welcome file in WEB-INF/web.xml
2. Create index.jsp as below:
<%
response.sendRedirect("index.html");
return;
%>
<html>
<head>
<title>Index JSP file</title>
</head>
<body>
<font color="red">This is index.jsp file </font>
</body>
</html>
3. Create index.html as below:
<html>
<head>
<title>Index HTML file</title>
</head>
<body>
<font color="red">This is index.html file </font>
</body>
</html>
4. Run the examples server and make sure examplesWebApp is deployed on the examples
server using the console
5. Access the URL http://localhost:7001/examplesWebApp
The page will display a compilation error as below:
C:\bea\wlserver6.0\config\examples\applications\examplesWebApp\WEB-INF\_tmp_war_examplesServer_examplesServer_examplesWebApp\jsp_servlet\_index.java:89:
unreachable statement
out.print("\r\n<html>\r\n<head>\r\n<title>Simple html</title>\r\n</head>\r\n<body>\r\n<font
color=\"red\">This is index.jsp page</font>\r\n</body>\r\n</html>\r\n");
^
and a look at the generated java code for index.jsp (_index.java) will reveal
the erroneous code snippet below in the jsp service method:
try { // error page try block
//[ /index.jsp; Line: 1]
response.sendRedirect("index.html"); //[ /index.jsp; Line: 2]
return; //[ /index.jsp; Line: 3]
out.print("\r\n<html>\r\n<head>\r\n<title>Simple html</title>\r\n</head>\r\n<body>\r\n<font
color=\"red\">This is index.jsp page</font>\r\n</body>\r\n</html>\r\n");
} catch (Exception __ee) {
while (out != null && out != _originalOut) out = pageContext.popBody();
pageContext.handlePageException(__ee);
The above web application works fine in Tomcat 3.2.X environment. The Weblogic
server 6.0 servlet engine should not generate the "out.println()" corresponding
to the html section of index.jsp. The moment it sees the "return", it should stop
processing further.
Can someone from Weblogic support team please verify this and let me know when
this bug will be fixed?
One interesting thing I noticed was when we last tried weblogic 6.0 at its beta
stage, it worked fine after we put in a special patch jar file called "redirectfix.jar"
we received from weblogic team but somehow it got re-introduced by the time it
was released!!
We are planning to migrate our product from tomcat 3.2.x to weblogic 6.0. Our
product has a lot of pages with such conditional {response.sendRdirect("page.jsp");return;}
blocks. We would really appreciate a faster response form weblogic team.
Thanks in advance.
sam...
Sam Palanisamy
Senior Software Engineer
Manage.com
2345 N. First Street First Floor
San Jose CA 95131
Why should it stop when it sees a return? Is that in the spec?
Peace,
Cameron Purdy
Tangosol Inc.
<< Tangosol Server: How Weblogic applications are customized >>
<< Download now from http://www.tangosol.com/download.jsp >>
"Sam Palanisamy" <[email protected]> wrote in message
news:[email protected]...
>
> Hi,
>
> Here are the steps to reproduce the problem with the examplesWebApp
application
> bundled with wlserver6.0(sp2):
>
> Product: Weblogic server 6.0 (sp2)
> Browser: IE 5.0
>
> 1. Add index.jsp as the welcome file in WEB-INF/web.xml
>
> 2. Create index.jsp as below:
> <%
> response.sendRedirect("index.html");
> return;
> %>
> <html>
> <head>
> <title>Index JSP file</title>
> </head>
> <body>
> <font color="red">This is index.jsp file </font>
> </body>
> </html>
>
> 3. Create index.html as below:
> <html>
> <head>
> <title>Index HTML file</title>
> </head>
> <body>
> <font color="red">This is index.html file </font>
> </body>
> </html>
>
> 4. Run the examples server and make sure examplesWebApp is deployed on the
examples
> server using the console
>
> 5. Access the URL http://localhost:7001/examplesWebApp
>
> The page will display a compilation error as below:
>
C:\bea\wlserver6.0\config\examples\applications\examplesWebApp\WEB-INF\_tmp_
war_examplesServer_examplesServer_examplesWebApp\jsp_servlet\_index.java:89:
> unreachable statement
> out.print("\r\n<html>\r\n<head>\r\n<title>Simple
html</title>\r\n</head>\r\n<body>\r\n<font
> color=\"red\">This is index.jsp page</font>\r\n</body>\r\n</html>\r\n");
> ^
>
> and a look at the generated java code for index.jsp (_index.java) will
reveal
> the erroneous code snippet below in the jsp service method:
>
> try { // error page try block
>
> //[ /index.jsp; Line: 1]
> response.sendRedirect("index.html"); //[ /index.jsp; Line: 2]
> return; //[ /index.jsp; Line: 3]
> out.print("\r\n<html>\r\n<head>\r\n<title>Simple
html</title>\r\n</head>\r\n<body>\r\n<font
> color=\"red\">This is index.jsp page</font>\r\n</body>\r\n</html>\r\n");
> } catch (Exception __ee) {
> while (out != null && out != _originalOut) out =
pageContext.popBody();
> pageContext.handlePageException(__ee);
> }
>
> The above web application works fine in Tomcat 3.2.X environment. The
Weblogic
> server 6.0 servlet engine should not generate the "out.println()"
corresponding
> to the html section of index.jsp. The moment it sees the "return", it
should stop
> processing further.
>
> Can someone from Weblogic support team please verify this and let me know
when
> this bug will be fixed?
>
> One interesting thing I noticed was when we last tried weblogic 6.0 at its
beta
> stage, it worked fine after we put in a special patch jar file called
"redirectfix.jar"
> we received from weblogic team but somehow it got re-introduced by the
time it
> was released!!
>
> We are planning to migrate our product from tomcat 3.2.x to weblogic 6.0.
Our
> product has a lot of pages with such conditional
{response.sendRdirect("page.jsp");return;}
> blocks. We would really appreciate a faster response form weblogic team.
>
> Thanks in advance.
> sam...
> Sam Palanisamy
> Senior Software Engineer
> Manage.com
> 2345 N. First Street First Floor
> San Jose CA 95131
>
>
-
Determining free disk space in a platform independent "java-like" way?
how can i determine free disk space in a platform independent "java-like" way?
Search the forum "free disk space".
-
Hello, i need a free java editor for rtf file !
hello, i need a free java editor for rtf file , that its compatible
with wordpad of windows, i have tried some of it but they are not compatible ,
example: not mantain the tabs and the formattings of the text.
Thankshello, i need a free java editor for rtf file , that
its compatible
with wordpad of windows, i have tried some of it but
they are not compatible ,
example: not mantain the tabs and the formattings of
the text.
ThanksWhy are you using rtf files? .java files are plain text with no formatting info. -
How to convert these java codes (for a feedback) to javabean?
Can anyone please help me to convert these java codes (for feedback) to javabean using the MVC Model-View-Controller pattern design?
<%
//instantiate variables
Connection con = null;
Statement stmt = null;
Statement stmt2 = null;
ResultSet rs = null;
String queryString;
int newInBoxMsg = 0;
int newSentMsg = 0;
int newSavedMsg = 0;
int newTrashCanMsg = 0;
String currentUserID = 1+"";
String adminID = 1+""; //change this ID to your adminID in the db
try
//Load the JDBC driver
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
//Get the connection getConnection("access driver", "userID", "password")
con = DriverManager.getConnection("jdbc:odbc:FREN_DB","","");
stmt = con.createStatement();
//sql statements: create, update, query
Calendar cl = Calendar.getInstance();
%>
<%
if(request.getMethod()=="POST"){
int y = stmt.executeUpdate("INSERT into Feedback(`whom`, `msg`, `date`)"
+" values ('"+currentUserID+"', '"+request.getParameter("date")+"', '"
request.getParameter("msg")"')");
int x = stmt.executeUpdate("INSERT into MailBox(`whom`, `who`, `mailheader`, `mailbody`, `date`)"
+" values ('"+adminID+"', '"+currentUserID+"', 'Feedback', 'We have received your feedback and we will respond to you as soon as possible', '"+request.getParameter("date")+"')");
out.println("Feedback Sent!");
else {
%>
<form name="compose" method="POST" action="Feedback.jsp">
<input name="date" type="hidden" value="<% out.println(cl.get(cl.DAY_OF_MONTH)+"/"+cl.get(cl.MONTH)+"/"+cl.get(cl.YEAR)); %>" maxlength="20">
<p>Your Feedback</p>
<p>
<textarea name="msg" cols="50" rows="10"></textarea>
</p>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
</form>
<%
}catch(Exception e) {
System.out.println(e);
%>Okay, first suggestion is to never create database connections in JSP/Servlet. SInce you mentioned MVC, JSP is the View, and a servlet can be the controller to process requests and redirect accordingly.
This piece of code should be in a class invoked from the model layer (business logic components) preferably with some abstraction. Maybe you should search around for DAO pattern. That might give you an idea. -
Java code for converting EDI file to XML file
Dear friends,
Can you please help me in getting the java code for converting to EDI file to XML file.Hi,
You can convert the EDI file to XML in any of the ways
1) Using third party seeburger adapters
2) Conversion agent
3) Stylus studio.
I think using java code it will be very difficult.
Thnx
Chirag -
I need Java code for a simple graphical hit counter for a webpage
I was wondering if anybody out there could send me some code for a simple graphical hit counter for a webpage. All the sites that I've visited are garbage and of no use to me. Please help me.
ColinNot as easy as you'd imagine with applets. You need some way to store the hits, usually through a file on the server. That's not gonna happen in a hurry for 2 reasons -
- Applets can't read/write files
- Your web server usually won't let you run programs on their machine (ie, programs that listen for socket connections from applets, then load/read/write/close a file).
In short, no, there is no simple java solution (that I know of).
Cheers,
Radish21 -
Java code for BAPI_SalesOrder_getlist_Input
Hi Experts,
I have done sales order using bapi in web dynpro. I have complete all my design part related to this like context mapping, model binding etc an all are working fine, now i have to write some java code in the Implementaion tab.,
I have taken fields for this BAPI
1-Output · Return
Output · SalesOrders
Customer_Number
Document_Date
Document_Date_To
Sales_Organization
I have wriiten something but, i am not sure as i do not have java background.
so please help me out this issue or send me some documets on this topic.
thanks & regards,
Iqbal AhmadHi,
This is the best thread to find all the flow and no need to write more code.
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/202f1dfb-74db-2910-e48e-a7430c317df9.
U can add the followng code n the init method of any view or custom controller
wdContext.nodeControllernodename().bind(new FnModule());
// pass the nput.
try{
WdContext.CurrentControllerNodeElement().modelObject().execute();
wdContext.nodeOutput().invalidate();
close the brace and
catch(Excepton e)
e.prntStacTrace();
close the trace.
Thans
Lohi
Message was edited by:
Lohitha M
Maybe you are looking for
-
Hai guys, I need to find out which field in Accounts Payable cube relates to Check Number ( Vendor paying by checques ). Can anybody help me out? Thanks.
-
Row conditional rendering in report
Hi all, does somebody help me about conditional row rendering in a report? For example, I have this table : name role dovik user admin admin I would like to display the rows with a role 'admin' in red, and the ones with a role 'user' in green.
-
ExportFile with linked pdf ... Is it a bug ?
Hi, I'm facing a very strange behaviour with exportFile and linked PDF in inDesign cs 5.5 and 5 on mac and pc. I have a script simply doing an exportFile to png on all images contained in a inDesign file. Everything works well, except if user click i
-
So I plugged my iPhone 4s into my computer to charge it and when it was done charging I fallowed all the steps to unplug it. However when I went into my music all my music was gone except for my purchased music and all of my ringtones were were gone
-
OWL support in Oracle products
I have an OWL ontology(fully validated and created using Protege) that I would like to store into Oracle Spatial RDF. Does Oracle support this capability? If so, what are procedures, is there documentation that describes the procedures and the capabi