How to retrieve DSN's in java
Hi, Is it possible to retrieve a list of the ODBC DSN's (Data Source Name's) created on my local machine(XP-Pro) without using JNI?
Thanx all.
Pitty it can't be done using purly java.
@RealHowTo
Thanx it worx perfectly.
May I ask:
How could I create a DSN from java?
I remember reading something a while back on a class called VendorDataSource (I think).
This class is supplied by the Vendor of the Odbc. I have looked but cannot find it.
Do you know where I can find and download the class or do you know of any alternatives?
Thanx again
Similar Messages
-
How to retrieve the java object in a proxy service in osb -- Plz help
Hi all,
I have a singleton java class which runs whenever the weblogic server gets started and store the output in its object. I need to access this java object from a proxy service in osb.
We tried using java call out and retrieved that object but we couldn't know how to parse that object into XML.
We are not sure of using the java call out in osb to solve this purpose because whenever we use a java callout, that particular java code will run which is not the case of singleton class.
So kindly help us how to retrieve the java object which holds the output without running the java code every time because its already run and holding the output in its object.
Regards
Prabhuhere the doc http://download.oracle.com/docs/cd/E13159_01/osb/docs10gr3/userguide/context.html#wp1106656
but I guess you are already at the stage of getting a POJO in a first Java Callout and passing the POJO to a second Java Callout, which should then return it to OSB as a XMLObject.
My recommendation is to write a Java function which returns a XMLObject and uses a XMLCursor to populate it with the values of the POJO.
An XMLObject returned to the OSB is automatically transformed in a "XML" variable (which in reality is represented as a XMLObject in the Pipeline context)
Here some code sample:
http://www.javamonamour.org/2010/09/how-to-create-xmlobject-using-xmlcursor.html -
How to retrieve data from MDM using java API
hi experts
Please explain me the step by step procedure
how to retrieve data from MDM using java API
and please tell me what are the
important classes and packages in MDM Java API
thanks
ramuHi Ramchandra,
You can refer to following links
MDM Java API-pdf
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/2d18d355-0601-0010-fdbb-d8b143420f49
webinr of java API
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/89243c32-0601-0010-559d-80d5b0884d67
Following Fourm Threads will also help.
Java API
Java API
Re: usage of java API ,
Matching Record
Need Java API for Matching Record
Thanks and Regards,
Shruti.
Edited by: Shruti Shah on Jul 16, 2008 12:35 PM -
How to retrieve a node using xpath in java
Hi,
I need to make an application in which on click of a button an xml is
displayed on the browser.
Now when a user selects a node in the xml then i need the xpath of the selected node for some processing.
How to retrieve the xpath.
I am using Struts framework.There is not a specific method for achieving this.
You can store the whole xml document into a defined
structure. And get the needed xpath by some index.Yes i know that i'll need to store the file.
But my XML is fixed and the same XML is used everytime.
Now the structure of the XML is like it has same named nodes inside the parent node.
example :
<Human>
<Person>
<Person></Person>
<Person>
<Person><name>fsfsdsdf</name></Person>
</Person>
</Person>
<Human>
Now if the user selects the person node which contains name node then how to get the XPATH.
Can u help regarding the same........ -
How to retrieve the segment label setting of a Pie graph by java sdk?
hello,
there is a special setting for a pie graph: you can determine whether to show the segement label in a pie chart by checking the "show segment label" control under values, data, and categogy.
my question is, how to fetch the setting by java sdk?
thx.It doesn't look like this is accessible through the SDK. Unfortunately the SDK doesn't have a lot of access to the charting component. You would want to look at the RAS SDK guide for what you do have access to.
-
How to retrieve multiple data from table and represent it in jsp page
Hi
The below JavaScript code is used to add row in the table when I want to add multiple row data into table for single entry no field.
<html> function addRow()
i++;
var newRow = document.all("tblGrid").insertRow();
var oCell = newRow.insertCell();
oCell.innerHTML = "<input name='srno"+i+"' type='text' id='srno"+i+"' size=10>";
oCell = newRow.insertCell();
oCell.innerHTML = "<input name='itmcd"+i+"' type='text' id='itmcd"+i+"' size='10'>";
oCell = newRow.insertCell();
oCell.innerHTML = "<input name='itmnm"+i+"' type='text' id='itmnm"+i+"' size='15'>";
oCell = newRow.insertCell();
oCell.innerHTML = "<input name='indentqty"+i+"' type='text' id='indentqty"+i+"' size='10'>";
oCell = newRow.insertCell();
oCell.innerHTML = "<input name='uom"+i+"' type='text' id='uom"+i+"' size='10'><input type='hidden' name='mcode"+i+"'id='mcode"+i+"'>";
oCell = newRow.insertCell();
oCell.innerHTML = "<input name='packqty"+i+"' type='text' id='packqty"+i+"' size='10'>";
oCell = newRow.insertCell();
oCell.innerHTML = "<input name='packuom"+i+"' type='text' id='packuom"+i+"' size='10'><input type='hidden' name='pack"+i+"' id='pack"+i+"'>";
oCell = newRow.insertCell();
oCell.innerHTML = "<input name='rate"+i+"' type='text' id='rate"+i+"' size='10'>";
oCell = newRow.insertCell();
oCell.innerHTML = "<input name='dor"+i+"' type='text' id='dor"+i+"' size='0' onClick='"+putdate(this.name)+"'>";
oCell = newRow.insertCell();
oCell.innerHTML = "<input name='bccode"+i+"' type='text' id='bccode"+i+"' size='10'></td><input type='hidden' name='bcc"+i+"' id='bcc"+i+"'>";
oCell = newRow.insertCell();
oCell.innerHTML = "<input name='cccode"+i+"' type='text' id='cccode"+i+"' size='10'></td><input type='hidden' name='ccc"+i+"' id='ccc"+i+"'>";
oCell = newRow.insertCell();
oCell.innerHTML = "<input name='remark2"+i+"' type='text' id='remark2"+i+"' size='20'>";
oCell = newRow.insertCell();
oCell.innerHTML = "<input type='button' value='Delete' onclick='removeRow(this);' />";
// oCell = newRow.insertCell();
// oCell.innerHTML = "<input type='button' value='Clear' onclick='clearRow(this);' />";
}<html> Then this data are send to the next Servlet for adding into two table.
My header portion data are added into one table which added only one row in table. while footer section data are added into the no of rows in another table dependent on No. of
Rows added into jsp page.
Here is an code for that logic.
<html>
ArrayList<String> mucode = new ArrayList<String>();
ArrayList<Integer> serials = new ArrayList<Integer>();
ArrayList<Integer> apxrate = new ArrayList<Integer>();
ArrayList<Integer> srname = new ArrayList<Integer>();
ArrayList<String> itcode = new ArrayList<String>();
ArrayList<String> itname = new ArrayList<String>();
ArrayList<Integer> iqnty = new ArrayList<Integer>();
ArrayList<String> iuom = new ArrayList<String>();
ArrayList<Integer> pqnty = new ArrayList<Integer>();
ArrayList<String> puom1 = new ArrayList<String>();
ArrayList<Integer> arate = new ArrayList<Integer>();
ArrayList<String> rdate = new ArrayList<String>();
ArrayList<String> bcs = new ArrayList<String>();
ArrayList<String> ccs = new ArrayList<String>();
ArrayList<String> remarkss = new ArrayList<String>();
//ArrayList<Integer> qtyrecs = new ArrayList<Integer>();
//ArrayList<String> dors = new ArrayList<String>();
//ArrayList<String> remarks = new ArrayList<String>();
String entryn = request.getParameter("entryno");
String rows = request.getParameter("rows");
out.println(rows);
//String Entryno = request.getParameter("entryno");
// out.println(Entryno);
int entryno = 0,reqqty = 0,srno = 0,deprequest = 0,rowcount = 0;
if(!Entryno.equals("")){
entryno = Integer.valueOf(Entryno);
if(!rows.equals("")){
rowcount = Integer.valueOf(rows);
for(int i=1;i<=rowcount;i++){
if(request.getParameter("srno"+i)!=null){
serials.add(Integer.valueOf(request.getParameter("srno"+i).trim()));
out.println(serials.size());
for(int i=1;i<=rowcount;i++){
if(request.getParameter("srno"+i)!=null){
srname.add(Integer.valueOf(request.getParameter("srno"+i).trim()));
out.println(srname.get(0));
for(int i=1;i<=rowcount;i++){
if(request.getParameter("itmcd"+i)!=null){
itcode.add(request.getParameter("itmcd"+i).trim());
} //out.println(itcode.get(i));
for(int i=1;i<=rowcount;i++){
if(request.getParameter("itmnm"+i)!=null){
itname.add(request.getParameter("itmnm"+i).trim());
}//out.println(itname.get(i));
for(int i=1;i<=rowcount;i++){
if(request.getParameter("indentqty"+i)!=null){
iqnty.add(Integer.valueOf(request.getParameter("indentqty"+i).trim()));
for(int i=1;i<=rowcount;i++){
if(request.getParameter("uom"+i)!=null){
iuom.add(request.getParameter("uom"+i).trim());
}//out.println(iuom.get(i));
for(int i=1;i<=rowcount;i++){
if(request.getParameter("mcode"+i)!=null){
mucode.add(request.getParameter("mcode"+i).trim());
for(int i=1;i<=rowcount;i++){
if(request.getParameter("packqty"+i).equals("")){
pqnty.add(0);
}else
pqnty.add(Integer.valueOf(request.getParameter("packqty"+i).trim()));
for(int i=1;i<=rowcount;i++){
if(request.getParameter("pack"+i)!=null){
puom1.add(request.getParameter("pack"+i).trim());
}else
puom1.add("");
for(int i=1;i<=rowcount;i++){
if(request.getParameter("rate"+i).equals("")){
arate.add(0);
}else
arate.add(Integer.valueOf(request.getParameter("rate"+i).trim()));
/* for(int i=1;i<=rowcount;i++){
if(request.getParameter("rate"+i)!=null){
arate.add(Integer.valueOf(request.getParameter("rate"+i).trim()));
for(int i=1;i<=rowcount;i++){
if(request.getParameter("dor"+i)!=null){
try{
rdate.add(dashdate.format(slashdate.parse(request.getParameter("dor"+i).trim())));
}catch(ParseException p){p.printStackTrace();}
}else
{ rdate.add("");}
for(int i=1;i<=rowcount;i++){
if(request.getParameter("bcc"+i)!=null){
bcs.add(request.getParameter("bcc"+i).trim());
}out.println(bcs.get(0));
for(int i=1;i<=rowcount;i++){
if(request.getParameter("ccc"+i)!=null){
ccs.add(request.getParameter("ccc"+i).trim());
}out.println(ccs.get(0));
for(int i=1;i<=rowcount;i++){
out.println("remark2");
if(request.getParameter("remark2"+i)!=null){
remarkss.add(request.getParameter("remark2"+i).trim());
}out.println(remarkss.get(0));
ArrayList<String> Idate = new ArrayList<String>();
for(int i=1;i<=rowcount;i++){
if(request.getParameter("dateindent"+i)!=null){
try{
Idate.add(dashdate.format(dashdate.parse(request.getParameter("dateindent"+i).trim())));
}catch(ParseException p){p.printStackTrace();}
String Rdate = dashdate.format(new java.util.Date());
String tdate = dashdate.format(new java.util.Date());
// String Indentdate = dashdate.format(new java.util.Date());
// String ApprovedT1 = dashdate.format(new java.util.Date());
// String ApprovedT2 = dashdate.format(new java.util.Date());
// String ApprovedT1=" ";
//String ApprovedT2="";*/
String ApprovedT1= dashdate.format(new java.util.Date());
out.println (ApprovedT1);
String ApprovedT2=dashdate.format(new java.util.Date());
out.println(ApprovedT2);
String Indentdate=(dashdate.format(slashdate.parse(request.getParameter("dateindent").trim())));
out.println(Indentdate);
String Cocode ="BML001";
out.println(Cocode);
String Deptcode = request.getParameter("dept1");
out.println(Deptcode);
String Empcode = request.getParameter("emp");
out.println(Empcode);
String Refno =request.getParameter("rtype");
out.println(Refno);
String Divcode = request.getParameter("todiv1");
out.println(Divcode);
String Usercode = "CIRIUS";
String Whcode = request.getParameter("stor");
out.println(Whcode);
// String Itemgroupcode = request.getParameter("");
String Itemgroupcode ="120000";
out.println(Itemgroupcode);
String Supplytypecode = request.getParameter("stype");
out.println(Supplytypecode);
String Delcode = request.getParameter("deliverycode");
out.println(Delcode);
String Itemclass="WS";
out.println(Itemclass);
// String Itemclass = request.getParameter("iclass");
// out.println(Itemclass);
String unitcode = request.getParameter("uni");
out.println(unitcode);
String Todivcode = request.getParameter("todiv1");
out.println(Todivcode);
String Appxrate = request.getParameter("rate");
out.println(Appxrate);
String Srno = request.getParameter("srno");
out.println(Srno);
/* String Indqty = request.getParameter("indentqty");
out.println(Indqty);*/
String Itemcode = request.getParameter("itmcd");
out.println(Itemcode);
String Othersp = request.getParameter("remark1");
out.println(Othersp);
String Reqdt = request.getParameter("dor");
out.println(Reqdt);
String Munitcode = request.getParameter("mcode");
out.println(Munitcode);
String Packqty = request.getParameter("packqty");
out.println(Packqty);
String Packuom = request.getParameter("pack");
out.println(Packuom);
String Remark2 = request.getParameter("remark2");
out.println(Remark2);
String BC = request.getParameter("bcc");
out.println(BC);
String CC = request.getParameter("ccc");
out.println(CC);
try{
st=connection.createStatement();
connection.setAutoCommit(false);
String sql="INSERT INTO PTXNINDHDR(COCODE,DEPTCODE,EMPCODE,APPROVEDT1,APPROVEDT2,INDDT,ENTRYNO,REFNO,REMARKS,DIVCODE,USERCODE,WHCODE,ITEMGROUPCODE,SUPTYPECODE,DELCODE,UNITCODE,TODIVCODE,ITEMCLASS)VALUES('"+Cocode+"','"+Deptcode+"','"+Empcode+"','"+ApprovedT1+"','"+ApprovedT2+"','"+Indentdate+"',"+Entryno+",'"+Refno+"','"+Othersp+"','"+Divcode+"','"+Usercode+"','"+Whcode+"','"+Itemgroupcode+"','"+Supplytypecode+"','"+Delcode+"','"+unitcode+"','"+Todivcode+"','"+Itemclass+"')";
out.println(sql);
st.addBatch(sql);
for(int i=0;i<serials.size();i++){
out.println("Inside the Statement");
String query3="test query for u";
out.println(query3);
String queryx="Insert into PTXNINDDTL(APXRATE,ENTRYNO,BRKNO,INDQTY,ITEMCODE,OTHERSPFCS,MUNITCODE,PACKQTY,PACKUOM,REMARKS,DIMSUBGRPCODE,DIMCODE,REQDT)VALUES("+arate.get(i)+","+entryno+","+srname.get(i)+","+iqnty.get(i)+","+itcode.get(i)+",'"+Othersp+"','"+mucode.get(i)+"',"+pqnty.get(i)+",'"+puom1.get(i)+"','"+remarkss.get(i)+"','"+bcs.get(i)+"','"+ccs.get(i)+"','"+rdate.get(i)+"')";
out.println(queryx);
st.addBatch(queryx);
int[] result=st.executeBatch();
connection.commit();
for(int k=0;k<result.length;k++)
out.println("rows updated by "+(k+1)+"insert sta:"+result[k]+"");
catch(BatchUpdateException bue)
out.println("error1;"+bue+"");
catch(SQLException sql)
out.println("error2;"+sql+"");
catch(Exception l)
out.println("error3;"+l+"");
</html>
Now I looking for to retrieve this footer section data available in multiple rows from footer table and present it in jsp page .
I am finding difficulties in how to show this multiple row data for dynamic no of rows .i.e. variable no. of rows.
I have able to show the data in Header portions of page in this ways
here i am adding the part of code which shows the data from header part of table i.e from Header table
<html>
<h2 align="center"><b>Indent Preparation</b></h2>
<div align="left">
<table width="849" border="0" cellspacing="3" cellpadding="3" align="center">
<tr>
<td ><div align="left"><b>Indent No.</b></div></td>
<td ><label>
<input name="indentno" type="text" id="indentno" size="15" value="" /><input type="hidden" name="no" id="no">
</label></td>
<td ><div align="center"><strong>Indent Date</strong></div></td>
<td ><label>
<div align="center">
<input name="dateindent" type="text" id="dateindent"value="<%=date1%>"/><input type="hidden" name="no" id="no">
</div>
</label></td>
<td> </td>
<td><div align="right"><strong>Entry No.</strong></div></td>
<%if(oper!=null && oper.equals("view") && hdrcode!=null && hdrdetails!=null){%>
<td><input type="text" value="<%=hdrcode.get(3)%>" size="10"></td>
<%}else{%>
<td><input type="text" name="entryno" id="entryno" value="<%=entryNo%>"/></td>
<%}%>
<div align="right"></div>
</tr>
<tr>
<td><b>Division</b></td>
<%if(oper!=null && oper.equals("view") && hdrcode!=null && hdrdetails!=null){%>
<td><input type="text" value="<%=hdrdetails.get(9)%>" size="20"</td>
<td><input type="hidden" name="div1" id="div1" value='<%=hdrcode.get(10)%>'></td>
<%}else{%>
<td><input type="text" name="div" id="div" /></td>
<td><input type="hidden" name="div1" id="div1" /> </td>
<%}%>
<td> </td>
<td> </td>
<td><div align="right"><strong>Unit</strong></div></td>
<%if(oper!=null && oper.equals("view") && hdrcode!=null && hdrdetails!=null){%>
<td><input type="text" value="<%=hdrdetails.get(14)%>" size="20"</td>
<td><input type="hidden" name="uni" id="uni" value='<%=hdrcode.get(12)%>'></td>
<%}else{%>
<td><input type="text" name="unit" id="unit" /></td>
<td><input type="hidden" name="uni" id="uni" /> </td>
<%}%>
</tr>
<tr>
</html>
Any suggestion on any above works is highly appreciated.
Thanks and regards
harshalToo much code. It's also not well intented nor formatted. I don't see a question either or it got lost in that heap of unformatted code.
I will only answer the question in the thread's subject:
How to retrieve multiple data from table and represent it in jsp pageTo retrieve, make use of HttpServletRequest#getParameterValues() and/or #getParameter().
To display, make use of JSTL's c:forEach. -
How To Retrieve an Object's Value Defined Using c:set ... Tag?
I have the value of a variable defined in JSP#1 (JSP#1 is not a form) using JSTL tag:
<c:set var="id" value="${articleForm.article}" scope="session"/>Now, I have an object 'id' in the session scope. The object 'id' and all the information, which are defined in JSP#1, are forwarded to JSP#2.
JSP#2 is a form. But, the 'id' is not used in JSP#2.
JSP#2 has a submit button and then, a servlet takes over the control after that button is clicked. All the text fields in JSP#2 together with the object 'id' are forwarded to this servlet.
I have two questions:
1. I should put this object 'id' in a request scope or a session scope? Currently, it is in a session scope.
2. How to retrieve the value of this object 'id' in this servlet? (I do not want to print the value out. I want to retrieve the value and store it in a database.)
int articleID = Integer.parseInt( session.getAttribute( "id" ) ); or, it should be retrieved in another way?I'm not sure you understand the concept of a session object.
Java objects stay on the server. There is no transmission between the web browser and the client.
The scope just sets how long the server "remembers" that variable.
request scope - only lasts one request. Once a web page is returned to the client, the server forgets all request variables.
session scope - lasts for one user - across multiple requests/web pages.
1. I should put this object 'id' in a request scope or a session scope? Currently, it is in a session scope.From your description, you appear to have it right - your object should be in session scope.
2. How to retrieve the value of this object 'id' in this servlet? (I do not want to print the value out. I want to retrieve the value and store it in a database.)If articleForm.article is an String then that looks the right way to access it.
You might have to do it like this:
int articleID = Integer.parseInt( (String)session.getAttribute("id"));
The Integer.parseInt method takes a String as a parameter - while session.getAttribute() returns an Object.
This code will work if the object stored in the session is a String.
The object stored in the session is ${articleForm.article} What type does articletForm.getArticle() return? That is the type you need to cast it to when retrieving it from the session.
Cheers,
evnafets -
How to retrieve data from the HTML form in the JEditorPane?
I could quite easily use JEditorPane to render and display a simple HTML file.
My HTML looks like this:
<html>
<head>
<title> simple form</title>
</head>
<body bgcolor="cccccc">
<center><h1>SURVEY THING</h1>
</center>
<form id="survey">
<p>1.Type something in.</p>
<textarea cols=25 rows=8>
</textarea>
<BR>
<p>2.Pick ONLY one.</p>
<input type="radio" name="thing" value="0" Checked> NO choice <BR>
<input type="radio" name="thing" value="1"> First choice <BR>
<input type="radio" name="thing" value="2"> Second choice
<BR>
<p>3.Pick all you like.</p>
<input type="checkbox" name="stuff" value="A"> A <BR>
<input type="checkbox" name="stuff" value="B"> B <BR>
<input type="checkbox" name="stuff" value="C"> C <BR>
<input type="submit" value="give data">
<input type="reset" value="do clensing">
</form>
</body>
</html>
It gets diplayed fine and I can type in text, select radio buttons (they behave mutualy-exclusive,
as they should) and check checkboxes.
The problem I have is with retrieving the values which were entered into the form.
If I, after editing, try to write the html to the file using HTMLWriter,
it records the changes I made into the textarea, however all the radio and checkbox selections are lost.
Maybe the problem is that when I enter the values I do not use any methods like
insertBeforeStart and so on, but I believe I shouldn't need to use them to populate a form.
Especially I never change the structure of the HTML.
Also, when I try to traverse the Element tree and see the input elements attributes,
I can never see a change in the entered values. However it is probably b/c I am traversing through
the model and the changes are in the view (just a guess.)
Anyway, if anybody could direct me onto the right path: how to retrieve the values typed in the form,
or if it is possible at all in the JEditorPane, I would greatly appreciate.
thanks
maciej
PS. I have seen the answer to a similar question posted some time last year. However, I am trying
to find a soultion which allows forms/surveys to be built by people who have no java and only basic
html knwledge. And Axualize way is probably a little bit too "high-tech."Maybe helpful for u.
import java.awt.*;
import java.awt.event.*;
import java.awt.Container;
import java.util.*;
import javax.swing.*;
import javax.swing.text.*;
import javax.swing.text.html.*;
public class TestHtmlInput extends JFrame {
JEditorPane pane=new JEditorPane();
public TestHtmlInput() {
super();
pane.setEditorKit(new HTMLEditorKit());
pane.setText("<HTML><BODY><FORM>" +
"<p>1.Input your name.</p>" +
"<INPUT TYPE='text' name='firstName'>" +
"<p>2.Input your information.</p>" +
"<TEXTAREA rows='20' name='StationDescriptions' cols='100'>" +
"<p>3.Pick ONLY one.</p>" +
"<input type='radio' name='thing' value='0' Checked> NO choice <BR>" +
"<input type='radio' name='thing' value='1'> First choice <BR>" +
"<input type='radio' name='thing' value='2'> Second Choice <BR>" +
"<p>4.Pick all you like.</p>" +
"<input type='checkbox' name='stuff' value='A'> A <BR>" +
"<input type='checkbox' name='stuff' value='B'> B <BR>" +
"<input type='checkbox' name='stuff' value='C'> C <BR>" +
"<p>5.Choose your nationality.</p>" +
"<select name='natio'>" +
"<option>12</option>" +
"<option selected>13</option>" +
"</select>" +
"</FORM></BODY></HTML>");
this.getContentPane().add(new JScrollPane(pane));
JButton b=new JButton("print firstName text");
b.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("Number of Components in JTextPane: " + pane.getComponentCount());
for (int i = 0; i < pane.getComponentCount(); i++) {
//NOTE FOR BELOW: know its a Container since all Components inside a JTextPane are instances of the inner class
//ComponentView$Invalidator which is a subclass of the Container Class (ComponentView$Invalidator extends Container)
Container c = (Container)pane.getComponent(i);
//the component of this containers will be the Swing equivalents of the HTML Form fields (JButton, JTextField, etc.)
//Get the # of components inside the ComponentView$Invalidator (the above container)
Component swingComponentOfHTMLInputType = c.getComponent(0);
//each ComponentView$Invalidator will only have one component at array base 0
//DISPLAY OF WHAT JAVA CLASS TYPE THE COMPONENT IS
System.out.println(i + ": " + swingComponentOfHTMLInputType.getClass().getName());
//this will show of what type the Component is (JTextField, JRadioButton, etc.)
if (swingComponentOfHTMLInputType instanceof JTextField) {
JTextField tf = (JTextField)swingComponentOfHTMLInputType;
//downcast and we have the reference to the component now!! :)
System.out.println(" Text: " + tf.getText());
tf.setText("JTextField found!");
} else if (swingComponentOfHTMLInputType instanceof JButton) {
} else if (swingComponentOfHTMLInputType instanceof JComboBox) {
JComboBox combo = (JComboBox)swingComponentOfHTMLInputType;
System.out.println(" Selected index: " + combo.getSelectedIndex());
} else if (swingComponentOfHTMLInputType instanceof JRadioButton) {
JRadioButton radio = (JRadioButton)swingComponentOfHTMLInputType;
System.out.println(" Selected: " + new Boolean(radio.isSelected()).toString());
} else if (swingComponentOfHTMLInputType instanceof JCheckBox) {
JCheckBox check = (JCheckBox)swingComponentOfHTMLInputType;
check.setSelected(true);
System.out.println(" Selected: " + new Boolean(check.isSelected()).toString());
} else if (swingComponentOfHTMLInputType instanceof JScrollPane) {
JScrollPane pane = (JScrollPane)swingComponentOfHTMLInputType;
for (int j=0; j<pane.getComponentCount(); j++) {
//JTextArea area = (JTextArea)swingComponentOfHTMLInputType.getComponent(0);
Container c2 = (Container)pane.getComponent(j);
for (int k=0; k<c2.getComponentCount(); k++) {
Component c3 = (Component)c2.getComponent(k);
if (c3 instanceof JTextArea) {
JTextArea area = (JTextArea)c3;
System.out.println(" " + area.getClass().getName());
System.out.println(" Text: " + area.getText());
area.setText("JTextArea found!");
} else {
this.getContentPane().add(b,BorderLayout.SOUTH);
public static void main(String args[]) {
TestHtmlInput app = new TestHtmlInput();
app.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
app.setSize( 400, 900 );
app.setVisible( true );
} -
How to retrieve data from a DB
Hi
I need to retrive data from a DB but I know nothing about DB structure and data type. I've been reading tutorials and writing code and I've all ready except I dont figure out how to know which data type I'm retrieving to use corresponding class to make the job.
I know I must combine getObject with metadata but i couldn't found a sample code.
Could somebody help me ?
thanks in advance
<xl>You can get the metadata of a database with Connection.getMetaData(). Then you can use that DatabaseMetaData objet to search for the datatype of the column. Look at the APIs of DatabaseMetaData to see how you can do that: http://java.sun.com/j2se/1.4.2/docs/api/java/sql/DatabaseMetaData.html
-
HELP! How te retrieve the last row in MYSQL database using Servlet!
Hi ,
I am new servlets. I am trying to retireve the last row id inserted using the servlet.
Could someone show me a working sample code on how to retrieve the last record inserted?
Thanks
MY CODE
import java.awt.*;
import java.awt.event.*;
import java.net.*;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
public class demo_gr extends HttpServlet {
//***** Servlet access to data base
public void doPost (HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException
String url = "jdbc:mysql://sql2.njit.edu/ki3_proj";
String param1 = req.getParameter("param1");
PrintWriter out = resp.getWriter();
resp.setContentType("text/html");
String semail, sfname, slname, rfname, rlname, remail, message;
int cardType;
sfname = req.getParameter("sfname");
slname = req.getParameter("slname");
rfname = req.getParameter("rfname");
rlname = req.getParameter("rlname");
semail = req.getParameter("semail");
remail = req.getParameter("remail");
message = req.getParameter("message");
//cardType = req.getParameter("cardType");
cardType = Integer.parseInt(req.getParameter("cardType"));
out.println(" param1 " + param1 + "\n");
String query = "SELECT * FROM greeting_db "
+ "WHERE id =" + param1 + "";
String query2 ="INSERT INTO greeting_db (sfname, slname ,semail , rfname , rlname , remail , message , cardType ,sentdate ,vieweddate) values('";
query2 = query2 + sfname +"','"+ slname + "','"+ semail + "','"+ rfname + "','"+ rlname + "','"+ remail + "','"+ message + "','"+ cardType + "',NOW(),NOW())";
//out.println(" query2 " + query2 + "\n");
if (semail.equals("") || sfname.equals("") ||
slname.equals("") || rfname.equals("") ||
rlname.equals("") || remail.equals("") ||
message.equals(""))
out.println("<h3> Please Click the back button and fill in <b>all</b> fields</h3>");
out.close();
return;
String title = "Your Card Has Been Sent";
out.println("<BODY>\n" +
"<H1 ALIGN=CENTER>" + title + "</H1>\n" );
out.println("\n" +
"\n" +
" From " + sfname + ", " + slname + "\n <br> To "
+ rfname + ", " + rlname + "\n <br>Receiver Email " + remail + "\n<br> Your Message "
+ message + "\n<br> <br> :");
if (cardType ==1)
out.println("<IMG SRC=/WEB-INF/images/bentley.jpg>");
else if(cardType ==2) {
out.println("<IMG SRC=/WEB-INF/images/Bugatti.jpg>");
else if(cardType ==3) {
out.println(" <IMG SRC=/WEB-INF/images/castle.jpg>");
else if(cardType ==4) {
out.println(" <IMG SRC=/WEB-INF/images/motocross.jpg>");
else if(cardType ==5) {
out.println(" <IMG SRC=/WEB-INF/images/Mustang.jpg>");
else if(cardType ==6) {
out.println("<IMG SRC=/WEB-INF/images/Mustang.jpg>");
out.println("</BODY></HTML>");
try {
Class.forName ("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection
( url, "*****", "******" );
Statement stmt = con.createStatement ();
stmt.execute (query2);
//String query3 = "SELECT LAST_INSERT_ID()";
//ResultSet rs = stmt.executeQuery (query3);
//int questionID = rs.getInt(1);
System.out.println("Total rows:"+questionID);
stmt.close();
con.close();
} // end try
catch (SQLException ex) {
//PrintWriter out = resp.getWriter();
resp.setContentType("text/html");
while (ex != null) {
out.println ("SQL Exception: " + ex.getMessage ());
ex = ex.getNextException ();
} // end while
} // end catch SQLException
catch (java.lang.Exception ex) {
//PrintWriter out = resp.getWriter();
resp.setContentType("text/html");
out.println ("Exception: " + ex.getMessage ());
} // end doGet
private void printResultSet ( HttpServletResponse resp, ResultSet rs )
throws SQLException {
try {
PrintWriter out = resp.getWriter();
out.println("<html>");
out.println("<head><title>jbs jdbc/mysql servlet</title></head>");
out.println("<body>");
out.println("<center><font color=AA0000>");
out.println("<table border='1'>");
int numCols = rs.getMetaData().getColumnCount ();
while ( rs.next() ) {
out.println("<tr>");
for (int i=1; i<=numCols; i++) {
out.print("<td>" + rs.getString(i) + "</td>" );
} // end for
out.println("</tr>");
} // end while
out.println("</table>");
out.println("</font></center>");
out.println("</body>");
out.println("</html>");
out.close();
} // end try
catch ( IOException except) {
} // end catch
} // end returnHTML
} // end jbsJDBCServletI dont know what table names and fields you have but
say you have a table called XYZ which has a primary
key field called keyID.
So in order to get the last row inserted, you could
do something like
Select *
from XYZ
where keyID = (Select MAX(keyID) from XYZ);
Good Luckwhat gubloo said is correct ...But this is all in MS SQL Server I don't know the syntax and key words in MYSQL
This works fine if the emp_id is incremental and of type integer
Query:
select *
from employee e, (select max(emp_id) as emp_id from employee) z
where e.emp_id = z.emp_id
or
select top 1 * from employee order by emp_id descUday -
How to retrieve the Conversation ID in ABAP
Does anyone know how to retrieve a conversation ID in ABAP?
You can retrieve the reference ID from SXMSPMAST but how do you retrieve the conversation ID?
Table names? FM?
ABAP not Java or UDF
All suggestions welcome.
Regards,
NayAs I said in my question, I am not asking for how to retrieve the conversation ID in a UDF. Please read my question....
I am asking, given a specific message ID, how can I retrieve the conversation id for that message ID on the ABAP stack - e.g. with a function module, what table names etc.
thanks, Nay -
How to retrieve updated payload information from completed HumanTask
after initiating the HumanTask , updating the payload object from java client api
payload information set into task object.
taskService.updateTaskOutcome(workflowContext, task, outcome) ;
after this call the HumanTask will be Completed.
Now i tried to get the Payload which was updated in earlier step.
Task task=taskQueryService.getTaskDetailsByNumber(workflowContext, taskNumber);
XMLElement payload =(XMLElement)task.getPayloadAsElement();
in the payload, it only contains payload which was at the time of humanTask initiation .
Can any one help me, how to retrieve the payload information after completing the HumanTask ?
Thanks in AdvanceI think the below code can be used to update the payload in the HumanTask
IWorkflowServiceClient wfSvc=WorkflowServiceClientFactory.getWorkflowServiceClient(WorkflowServiceClientFactory.REMOTE_CLIENT);
//instantiate the TaskQueryService Object
ITaskQueryService taskQuerySvc=wfSvc.getTaskQueryService();
//instantiate the TaskService Object. it has the UpdateOutcome method
ITaskService taskSvc=wfSvc.getTaskService();
final String password="jcooper";
final int taskNumber=123;
try {
//get WorkflowContext
IWorkflowContext context=taskQuerySvc.authenticate("jcooper",password.toCharArray(), "jazn");
Task task=taskQuerySvc.getTaskDetailsByNumber(context, taskNumber);
Element element=task.getPayloadAsElement();
Element payloadNew=element.getOwnerDocument().createElementNS("http://xmlns.oracle.com/bpel/workflow/task", "payload");
JAXBContext jaxbContext=JAXBContext.newInstance("object.path");
Marshaller marshaller=jaxbContext.createMarshaller();
//new Object() is your Object which you want to update in Process payload
marshaller.marshal(new Object(), payloadNew);
task.setPayloadAsElement(payloadNew);
//update task payload
taskSvc.updateTaskOutcome(context, task, "APPROVE");
} catch (WorkflowException e) {
e.printStackTrace();
} catch (JAXBException e) {
e.printStackTrace();
} catch (StaleObjectException e) {
e.printStackTrace();
Edited by: user12267906 on Nov 28, 2009 7:43 AM -
With photoshop ConnectionSDK, How to retrieve app.activeDocument as PSD file?
Dear all,
I'm currently making an automation s/w communicating with PhotoShop via connection sdk.
Even though my primary language is C#, translating Java/iOS sample to C# works fine.
Sending/receiving image file, invoking Javascript snippet work fine as demonstrated in sdk sample.
Also, sending PSD to PhotoShop also works, so that I can send PSD file in my s/w onto PhotoShop.
My question is here, How to retrieve PSD file working in PSD via connection sdk?
Actual goal of my s/w is
1. send predefined PSD onto PhotoShop
2. PhotoShop user does editing with this given psd
3. when editing is done, retrieve PSD from PhotoShop onto my s/w to process further in Asset Management system.
Any advice would be helpful for me, Thanks in advance.Did you purchase Lion or did it come with the computer? If you purchased, look in Mac App Store (MAS) under Purchases tab. You can download again.
If you need to reinstall, you can select to Reinstall OS X while booted from the Recovery Drive.
Boot into the Recovery Drive by holding down Command R when restarting.
If you need to purchase Mac OS X 10.7 Lion, you may order it from this page.
http://store.apple.com/us/product/D6106Z/A/os-x-lion -
How to retrieve public/ private from iKey token using Sun PKCS#11 provider
Dear all,
I'm trying to access one rainbow iKey 2032 token in Java 1.5 (Windows Environment) using Sun PKCS#11 provider. Token is stored with certificate. There is no problem to logging into the token using java.
Provider p = new sun.security.pkcs11.SunPKCS11(configName);
Security.addProvider(p);
KeyStore ks = null;
try{
char[] pin = {'P','A','S','S','W','O','R','D'};
ks = KeyStore.getInstance("pkcs11");
ks.load(null,pin);
catch(Exception e) {}
Now I am wondering how to retrieve a public and private from token, so that I can encrypt and decrypt a plain text file. Could anyone give me a sample program for this?
Your help is very much appreciated!!Hi Fred13
1. I have the same pkcs.cfg and get the following trace. Can you help me understand? Does this imply a bad dkck201.dll? I would really like to get this working for my implementation. tia.
lException in thread "main" java.security.ProviderException: Initialization failed
at sun.security.pkcs11.SunPKCS11.<init>(SunPKCS11.java:175)
at sun.security.pkcs11.SunPKCS11.<init>(SunPKCS11.java:76)
at com.mkp.jce.chap1.ProviderDetail.main(ProviderDetail.java:38)
Caused by: sun.security.pkcs11.wrapper.PKCS11Exception: CKR_TOKEN_NOT_RECOGNIZED
at sun.security.pkcs11.wrapper.PKCS11.C_GetTokenInfo(Native Method)
at sun.security.pkcs11.Token.<init>(Token.java:105)
at sun.security.pkcs11.SunPKCS11.initToken(SunPKCS11.java:555)
at sun.security.pkcs11.SunPKCS11.<init>(SunPKCS11.java:169)
2. (If I can be so indulgent of your time) Can you provide more information on cbp? I have done a search and there is little on it. It appears to be a new authentication framework tied in with sasl unique to 1.5. Any links for self education would be appreciated. -
How to retrieve system Information on client machine Using Applets
How to retrieve video card information on client machine using applets and JNI, please suggest me on this
Thanks
GReddy1. Research platform specific OS API to do whatever you want with video cards
2. Write C/C++ code to wrap the functionality in 1 into something looks closer to what you want to see in java
3. Write a class that models the functionality of 2 with native methods.
4. Write the native methods of 3 such that they call the methods of 2.
Note that steps 1 and 2 have NOTHING to do with jni nor java. So you start by looking somewhere else for the answers to that.
Maybe you are looking for
-
Will Airport Extreme Network with Panasonic Viera TC-P50ST30
Will Airport Extreme Network work properly with Panasonic Viera TC-P50ST30 HDTV?
-
Also, does anyone know if I can boot from the new intel mini's HD using my 12" PowerBook's keyboard and screen? If so, then I would deffinitely reconsider buying a MacBook Pro now and wait for it to have a better optical drive. Thanks for your posts
-
Removing the BC generated JS and CSS files from pages
Hi, We're working on a feature to allow you to generate pages without our styles and JS files. This is what we're planning to build, we need feedback on some automated JS/CSS generation for some pages and modules. We will add one flag per "Page Templ
-
Help. my address book is out of Whack!
I was syncing between two macs and now may adress book has jumbled all the emails and some of my contacts have 40 emails of other contacts including the original one . is ther a way to clean the address book up?
-
What is the best method to write off assets to 0, This means I want to accelerate depreciation so that the asset net value reaches 0. But I <b>do not</b> wat to retire the asset.