How can i use return statement in a method no flaming pls
public class example2
public int add(int i,int j)
int k = i + j;
return k; <<<< -HERE->
public static void main(String[] args)
example2 obj=new example2();
obj.add(2,3);
System.out.println("k"+k);
Iam really really new to java programming so dont flame me
In the above program i was hoping by putting return k it would return vlaue of k to the calling object but it didnt work i had to place sys.out.println in the method and take out the return from the method for it to work
So why dosent it work and where is it returned to the k value.
BlueRibbon wrote:
In the above program i was hoping by putting return k it would return vlaue of k to the calling objectThat's what happens, yes. The VALUE of k is returned, not the NAME k, so you cannot refer to the value by just k. To the caller, the value is obtained by evaluating the expression that calls the function. So you could do
public class example2
public int add(int i, int j)
return i + j;
public static void main(String[] args)
example2 obj = new example2();
System.out.println(obj.add(2, 3));
}
Similar Messages
-
Can we use return statement in procedure?
Can we use return statement in procedure or we can use more than one return statement in procedure?
HamidHelal wrote:
NOReally? Did you at least test it? You can use RETURN in procedure or in anonymous PL/SQL block. The only restriction is you can't specify return value:
SQL> begin
2 dbms_output.put_line('Before return');
3 return;
4 dbms_output.put_line('After return');
5 end;
6 /
Before return
PL/SQL procedure successfully completed.
SQL> create or replace
2 procedure p1
3 is
4 begin
5 dbms_output.put_line('Before return');
6 return;
7 dbms_output.put_line('After return');
8 end;
9 /
Procedure created.
SQL> exec p1;
Before return
PL/SQL procedure successfully completed.
SQL> begin
2 dbms_output.put_line('Before return');
3 return 99;
4 dbms_output.put_line('After return');
5 end;
6 /
return 99;
ERROR at line 3:
ORA-06550: line 3, column 5:
PLS-00372: In a procedure, RETURN statement cannot contain an expression
ORA-06550: line 3, column 5:
PL/SQL: Statement ignored
SQL> create or replace
2 procedure p1
3 is
4 begin
5 dbms_output.put_line('Before return');
6 return 99;
7 dbms_output.put_line('After return');
8 end;
9 /
Warning: Procedure created with compilation errors.
SQL> show err
Errors for PROCEDURE P1:
LINE/COL ERROR
5/9 PL/SQL: Statement ignored
5/9 PLS-00372: In a procedure, RETURN statement cannot contain an
expression
SQL> SY. -
I guess I'll show you what I am trying to do rather and then explain it
public class arraycalc
int[] dog;
public void arraycalc()
dog = new int[2];
public void setSize(int size)
dog[1] = size;
public int getSize()
return dog[1];
This gives me a null pointer exception...
How can I use my array from other methods?You have to make the array static. :)
Although I must admit, this is rather bad usage. What you want to do is use an object constructor to make this class an object type, and then create the array in your main class using this type, and then call the methods from this class to modify your array. Creating the array inside the other method leads to a whole bunch of other stuff that's ... well, bad. :)
Another thing: Because you're creating your array inside this class and you want to call your array from another class, you need to make the array static; to make it static, you must make your methods static. And according to my most ingenious computer science teacher, STATIC METHODS SUCK. :D
So, if you want to stick with your layout, it would look like:
public class arraycalc
static int[] dog;
public static void arraycalc()
dog = new int[2];
public static void setSize(int size)
dog[1] = size;
public static int getSize()
return dog[1];
}But I must warn you, that is absolutely horrible code, and you shouldn't use it. In fact, I don't even know why I posted it.
You should definitely read up on OOP, as this problem would be better solved by creating a new object type. -
HT201359 How can I use PayPal as my payment method?
How can I use PayPal as my payment method for my apple account?
Contact iTunes Customer Service and request assistance
Use this Link > Apple Support iTunes Store Contact -
How can i use "View State" Concept in sharepoint sandbox soltuions??
I need to do video player in sharepoint sandbox solutions..I used following code in form solution the same code i need to use sandbox solution..In this code i am using "viewstate" asp control..i don't know how to use in sandbox solutions..how to use??<html><head></head><body> <object classid="clsid:566DB6E-A56D-10pf-96B8-4488888000" width="425" height="344"><param name="movie" value="player.swf" /> <param name="flashvars" value="file=<%= ServerVideo %>"&"Preview=<%= ServerUrl %>" &autoplay="false" &showPlaylist="false" />
<param name="allowFullScreen" value="true" />
<param name="wmode" value="transparent" />
<param name="autoplay" value="false" />
<param name="allowscriptaccess" value="always" />
<embed src="hdplayer.swf" &
flashvars="file=<%=ServerVideo%>"& Preview="<%= ServerUrl %>"&showPlaylist="false"
style="width:425px;height:344px" allowFullScreen="true" allowScriptAccess="always"
type="application/x-shockwave-flash" wmode="transparent"></embed></object></body></html>Hello,
For those still looking, you should ask on the
SharePoint forums.
Karl
When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer.
My Blog: Unlock PowerShell
My Book: Windows PowerShell 2.0 Bible
My E-mail: -join ('6F6C646B61726C40686F746D61696C2E636F6D'-split'(?<=\G.{2})'|%{if($_){[char][int]"0x$_"}}) -
How can I use the commandLink's setAction method?
I have some jsf code like this:
<af:commandLink text="#{row.name}" action="detail">
and I want to change the commandLink's action dynamic,so I write such code:
CoreCommandLink ccl=new CoreCommandLink();
but I can't write
ccl.setAction("detail");
directly
this method is like this
public final void setAction(MethodBinding action)
Can you give me some example how to use this method?
Thank you very much!User,
If you want the action to be dynamic, create a method in your backing bean that returns the proper navigation case string and bind the action to that. For example, if you have a backing bean called "myBean," write a method in the backing bean like this:
public String myAction()
if (something) return "action1";
if (somethingelse) return "action2";
// etc
}and your commandLink looks like:
<af:commandLink text="#{row.name}" action="#{myBean.myAction}"/>This is a much better way to do what you are trying. The error you are getting, by the way, is you are passing a string paramter to setAction, which expects a MethodBinding as a parameter; however, just use the way described above - much easier.
John -
How can i use multiple row subquery in update statement
Hai All
I using group function in my update statement.. and i need to update more rows so i need to use multiple row
subquery pls tell me how to use multiple row subquery in update statement
For example
while i am using this like this i got an error
update dail_att set outtime in (select max(r2.ptime) from temp_att where empcode=r2.enpno and
barcode=r2.cardn and attend_date=r2.pdate group by enpno,pdate,cardn);
Pls tell me how to use with example
Thanks & regards
Srikkanth.MHai Man
Thanks for ur response Let me clear what i need
First step Fetch the records as text file and stores into table T1
and the next step is i have seperated the text using substring and stores in different columns of a table
There are two shifts 0815 to 1645 and 1200 and 2000
Here I rep IN and O rep OUT
Empno date time inout
001 01-01-10 0815 I
002 01-01-10 0815 I
003 01-01-10 0818 I
001 01-01-10 1100 0
001 01-01-10 1130 I
002 01-01-10 1145 0
002 01-01-10 1215 I
004 01-01-10 1200 I
005 01-01-10 1215 I
004 01-01-10 1315 O
004 01-01-10 1345 I
001 01-01-10 1645 0
002 01-01-10 1715 0
003 01-01-10 1718 0
004 01-01-10 2010 0
005 01-01-10 2015 0
This is my T1 table i have taken data from text file and stored in this table from this table i need to move data to another table T2
T2 contains like this
Empno Intime Intrin Introut Outtime Date
001 0815 1100 1130 1645 01-01-10
002 0815 1145 1215 1715 01-01-10
003 0818 1718 01-01-10
004 1200 1315 1345 2010 01-01-10
005 1215 2015 01-01-10
This what i am trying to do man but i have little bit problems Pls give some solution with good example
And my coding is
declare
emp_code varchar2(25);
in_time varchar2(25);
out_time varchar2(25);
Cursor P1 is
Select REASON,ECODE,READMODE,EMPD,ENPNO,FILL,PDATE,PTIME,INOUT,CARDN,READERN
From temp_att
group by REASON,ECODE,READMODE,EMPD,ENPNO,FILL,PDATE,PTIME,INOUT,CARDN,READERN
ORDER BY enpno,pdate,ptime;
begin
for r2 in p1 loop
declare
bar_code varchar2(25);
begin
select barcode into bar_code from dail_att where empcode=r2.enpno and attend_date=r2.pdate;
For r3 in (select empcode,empname,barcode,intime,intrin,introut,addin,addout,outtime,attend_date from dail_att)loop
if r2.inout ='O' then
update dail_att set outtime =(select max(r2.ptime) from temp_att where empcode=r2.enpno and barcode=r2.cardn and attend_date=r2.pdate group by r2.cardn,r2.enpno,r2.pdate );
end if;
end loop;
exception
when no_data_found then
if r2.inout ='I' then
insert into dail_att(barcode,empcode,intime,attend_date)(select r2.cardn,r2.enpno,min(r2.ptime),r2.pdate from temp_att group by r2.cardn,r2.enpno,r2.pdate );
end if;
end;
end loop;
commit;
end;
Pls tell me what correction i need to do i the update statement i have used a subquery with group function but when i used it will return only one row but my need is to return many rows and i need to use multiple row subquery
and how can i use it in the update statement
Thanks In Advance
Srikkanth.M -
I was using an iPhone 4 while I was living in Japan. How can I use it in the states now that I live here? It is a perfectly good phone and I don't want to use it only as an iPod and camera.
That's one option. The other is to sell it (you can probably get close to what you paid for it) or trade it in and get a new unlocked phone directly from an Apple store. That way you can use it in the US, and also in Japan when you return there.
-
How can i use one SQL statement to solve problem?
How can i use one SQL statement to solve the question below?
For a Table named A, there is a column named F(char type).
Now select all the records where F like '%00' and update their F value to '%01'
Just one SQL statement.Do not use PL/SQL block.
How to do that?
Thanks.What is the data volume for this table?
Do you expect lots of rows to have '%00' as their value?
Following two statements come to mind. Other experts would be able to provide better alternatives:
If you have index on SUBSTR(f, 2):
UPDATE A
SET f = SUBSTR(f,
1,
length(f) - 2) || '01'
WHERE substr(f,
-2) = '00';If most of the rows have pattern '%00':
UPDATE A
SET f = SUBSTR(f,
1,
length(f) - 2) ||
DECODE(SUBSTR(f,
-2),
'00',
'01',
SUBSTR(f,
-2)); -
How do we use if statement in labview?moreover can i use if statement inside for loop?
how do we use if statement in labview?moreover can i use if statement inside for loop?
The if statement in LabVIEW is the Case structure. You can find that on the Structures palette right next to the For Loop. If you're still on the same subject about terminating a for loop early, then what you do is enclose your functions inside the loop with a case statment and make one of the case's empty except for one or more constants that you might have to wire. Hopefully, the attached picture will explain what I mean. Also, as I mentioned in one of your other posts, I think this technique is not as good as using a while loop. The array in the attached example is the same size no matter what and you may have to handle stripping extra or invalid elements.
Attachments:
For_Loop_with_Case.jpg 21 KB -
How can I use comma in the return values of a static list of values
Hi all,
I want to create a select list (static LOV) like the following:
Display Value / Return Value
both are "Y" / 'YY'
one is "Y" / 'YN','NY'
I write the List of values definition is like this:
STATIC:both are "Y"; 'YY',one is "Y";'YN', 'NY'
However, it is explain by htmldb like this:
Display Value / Return Value
both are "Y" / 'YY'
one is "Y" / 'YN'
/ 'NY'
I tried using "\" before the ",", or using single or double quote, but all these do not work:(
How can I use a comma in the return values?
Thanks very much!"Better still, why not process the code of both Y with 2Y and one is Y with 1Y? "
Could you please explain in detail? thanks! I am quite new to htmldb
In fact I have a table which has too columns "a1" and "a2", both the values of these two columns are "Y" or "N". AndI want to choose the records that both a1 and a2 are "Y", or just one of a1, a2 is "Y".
So I write the report sql like this:
"select * from t1 where a1 || a2 in(:MYSELECTLIST) "
Thus, I need to use "," in the LOV, since expression list in IN(,,,) using ",".
Any other way to implement this? -
How Can I use a Variable in Data Controls query. Frank Kindly check...
Hii,
I am using JDeveloper 11g ADF BC.
My Requirement is that I hv a login screen which is taken from [http://blogs.oracle.com/shay/simpleJSFDBlogin.zip].
I hv attached BC in this application. I want to use the login usercode in the next pages after login screen. Next screen contains 3 list items which will be populating based on the user. So I created <af:selectOneChoice> using the BC( Just drag & dropped the column into the page from the data controls). But in the data control i want to use this usercode for passing the condition. Now Data is coming without any condition.
So How can I use the usercode in the Data controls query.
When I tried to display the usercode in the next page it is showing by binding the value. its code is follows
<af:outputText value="#{backing_getUser.uid}"
The program for checking the username & Password is follows.
package login.backing;
import oracle.adf.view.rich.component.rich.RichDocument;
import oracle.adf.view.rich.component.rich.RichForm;
import oracle.adf.view.rich.component.rich.input.RichInputText;
import oracle.adf.view.rich.component.rich.layout.RichPanelFormLayout;
import oracle.adf.view.rich.component.rich.nav.RichCommandButton;
import java.sql.*;
import java.util.List;
import java.util.Map;
import oracle.adf.view.rich.component.rich.output.RichMessage;
import oracle.jdbc.OracleDriver;
public class GetUser {
private RichInputText uid;
private RichInputText pid;
private RichCommandButton commandButton1;
private RichInputText inputText1;
private RichInputText inputText2;
public void setUid(RichInputText inputText1) {
this.uid = inputText1;
public void setPid(RichInputText inputText2) {
this.pid = inputText2;
public RichInputText getUid() {
return uid;
public RichInputText getPid() {
return pid;
public void setCommandButton1(RichCommandButton commandButton1) {
this.commandButton1 = commandButton1;
public RichCommandButton getCommandButton1() {
return commandButton1;
public String login_action() {
// Add event code here...
String user = this.getUid().getValue().toString();
// String pass = inputText2.getValue().toString();
String pid = this.getPid().getValue().toString();
Connection conn;
conn = getConnection();
Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery ("SELECT usercode FROM guser where usercode = '"+user.toUpperCase()+"' and pwd=F_TEST('"+pid.toUpperCase()+"')");
if (rset.next()) {
conn.close();
return "good";
conn.close();
} catch (SQLException e) {
System.out.println(e);
return "bad";
public static Connection getConnection() throws SQLException {
String username = "ACCTS";
String password = "ACCTS";
String thinConn = "jdbc:oracle:thin:@SERVER1:1521:G5PS";
DriverManager.registerDriver(new OracleDriver());
Connection conn =
DriverManager.getConnection(thinConn, username, password);
conn.setAutoCommit(false);
return conn;
public void setInputText1(RichInputText inputText1) {
this.inputText1 = inputText1;
public RichInputText getInputText1() {
return inputText1;
public void setInputText2(RichInputText inputText2) {
this.inputText2 = inputText2;
public RichInputText getInputText2() {
return inputText2;
-----Hi,
I didn't look at the example, but if you want to secure your application then you should use container managed security. Read this .
Anyway, you could add this before return "good"; in your login_action()
FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("username", user);Then, you can access this from anywhere in the application by using #{sessionScope.username}.
Pedja -
How can I use XStream to persist complicated Java Object to XML & backward
Dear Sir:
I met a problem as demo in my code below when i use XTream to persist my Java Object;
How can I use XStream to persist complicated Java Object to XML & backward??
See
[1] main code
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver;
public class PhoneList {
ArrayList<PhoneNumber> phones;
ArrayList<Person> person;
private PhoneList myphonelist ;
private LocationTest location;
private PhoneList(String name) {
phones = new ArrayList<PhoneNumber>();
person = new ArrayList<Person>();
public ArrayList<PhoneNumber> getphones() {
return phones;
public ArrayList<Person> getperson() {
return person;
public void addPhoneNumber(PhoneNumber b1) {
this.phones.add(b1);
public void removePhoneNumber(PhoneNumber b1) {
this.phones.remove(b1);
public void addPerson(Person p1) {
this.person.add(p1);
public void removePerson(Person p1) {
this.person.remove(p1);
public void BuildList(){
location = new LocationTest();
XStream xstream = new XStream();
myphonelist = new PhoneList("PhoneList");
Person joe = new Person("Joe, Wallace");
joe.setPhone(new PhoneNumber(123, "1234-456"));
joe.setFax(new PhoneNumber(123, "9999-999"));
Person geo= new Person("George Nixson");
geo.setPhone(new PhoneNumber(925, "228-9999"));
geo.getPhone().setLocationTest(location);
myphonelist.addPerson(joe);
myphonelist.addPerson(geo);
public PhoneList(){
XStream xstream = new XStream();
BuildList();
saveStringToFile("C:\\temp\\test\\PhoneList.xml",convertToXML(myphonelist));
public void saveStringToFile(String fileName, String saveString) {
BufferedWriter bw = null;
try {
bw = new BufferedWriter(
new FileWriter(fileName));
try {
bw.write(saveString);
finally {
bw.close();
catch (IOException ex) {
ex.printStackTrace();
//return saved;
public String getStringFromFile(String fileName) {
BufferedReader br = null;
StringBuilder sb = new StringBuilder();
try {
br = new BufferedReader(
new FileReader(fileName));
try {
String s;
while ((s = br.readLine()) != null) {
// add linefeed (\n) back since stripped by readline()
sb.append(s + "\n");
finally {
br.close();
catch (Exception ex) {
ex.printStackTrace();
return sb.toString();
public String convertToXML(PhoneList phonelist) {
XStream xstream = new XStream(new DomDriver());
xstream.setMode(xstream.ID_REFERENCES) ;
return xstream.toXML(phonelist);
public static void main(String[] args) {
new PhoneList();
}[2].
import java.io.Serializable;
import javax.swing.JFrame;
public class PhoneNumber implements Serializable{
private String phone;
private String fax;
private int code;
private String number;
private String address;
private String school;
private LocationTest location;
public PhoneNumber(int i, String str) {
setCode(i);
setNumber(str);
address = "4256, Washington DC, USA";
school = "Washington State University";
public Object getPerson() {
return null;
public void setPhone(String phone) {
this.phone = phone;
public String getPhone() {
return phone;
public void setFax(String fax) {
this.fax = fax;
public String getFax() {
return fax;
public void setCode(int code) {
this.code = code;
public int getCode() {
return code;
public void setNumber(String number) {
this.number = number;
public String getNumber() {
return number;
public void setLocationTest(LocationTest bd) {
this.location = bd;
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().add(location);
f.getContentPane().add(location.getControls(), "Last");
f.setSize(400,400);
f.setLocation(200,200);
f.setVisible(true);
public LocationTest getLocationTest() {
return location;
}[3].
package test.temp;
import java.io.Serializable;
public class Person implements Serializable{
private String fullname;
@SuppressWarnings("unused")
private PhoneNumber phone;
@SuppressWarnings("unused")
private PhoneNumber fax;
public Person(){
public Person(String fname){
fullname=fname;
public void setPhone(PhoneNumber phoneNumber) {
phone = phoneNumber;
public void setFax(PhoneNumber phoneNumber) {
fax = phoneNumber;
public PhoneNumber getPhone() {
return phone ;
public PhoneNumber getFax() {
return fax;
public String getName() {
return fullname ;
public void setName(String name) {
this.fullname = name;
public String toString() {
return getName();
}[4]. LocationTest.java
package test.temp;
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import javax.swing.*;
import javax.swing.event.*;
public class LocationTest extends JPanel implements ChangeListener
Ellipse2D.Double ball;
Line2D.Double line;
JSlider translate;
double lastTheta = 0;
public void stateChanged(ChangeEvent e)
JSlider slider = (JSlider)e.getSource();
String name = slider.getName();
int value = slider.getValue();
if(name.equals("rotation"))
tilt(Math.toRadians(value));
else if(name.equals("translate"))
moveBall(value);
repaint();
protected void paintComponent(Graphics g)
super.paintComponent(g);
Graphics2D g2 = (Graphics2D)g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
if(ball == null)
initGeom();
g2.setPaint(Color.green.darker());
g2.draw(line);
g2.setPaint(Color.red);
g2.fill(ball);
private void initGeom()
int w = getWidth();
int h = getHeight();
int DIA = 30;
int padFromEnd = 5;
line = new Line2D.Double(w/4, h*15/16, w*3/4, h*15/16);
double x = line.x2 - padFromEnd - DIA;
double y = line.y2 - DIA;
ball = new Ellipse2D.Double(x, y, DIA, DIA);
// update translate slider values
int max = (int)line.getP1().distance(line.getP2());
translate.setMaximum(max);
translate.setValue(max-padFromEnd);
private void tilt(double theta)
// rotate line from left end
Point2D pivot = line.getP1();
double lineLength = pivot.distance(line.getP2());
Point2D.Double p2 = new Point2D.Double();
p2.x = pivot.getX() + lineLength*Math.cos(theta);
p2.y = pivot.getY() + lineLength*Math.sin(theta);
line.setLine(pivot, p2);
// find angle from pivot to ball center relative to line
// ie, ball center -> pivot -> line end
double cx = ball.getCenterX();
double cy = ball.getCenterY();
double pivotToCenter = pivot.distance(cx, cy);
// angle of ball to horizon
double dy = cy - pivot.getY();
double dx = cx - pivot.getX();
// relative angle phi = ball_to_horizon - last line_to_horizon
double phi = Math.atan2(dy, dx) - lastTheta;
// rotate ball from pivot
double x = pivot.getX() + pivotToCenter*Math.cos(theta+phi);
double y = pivot.getY() + pivotToCenter*Math.sin(theta+phi);
ball.setFrameFromCenter(x, y, x+ball.width/2, y+ball.height/2);
lastTheta = theta; // save theta for next time
private void moveBall(int distance)
Point2D pivot = line.getP1();
// ball touches line at distance from pivot
double contactX = pivot.getX() + distance*Math.cos(lastTheta);
double contactY = pivot.getY() + distance*Math.sin(lastTheta);
// find new center location of ball
// angle lambda = lastTheta - 90 degrees (anti-clockwise)
double lambda = lastTheta - Math.PI/2;
double x = contactX + (ball.width/2)*Math.cos(lambda);
double y = contactY + (ball.height/2)*Math.sin(lambda);
ball.setFrameFromCenter(x, y, x+ball.width/2, y+ball.height/2);
JPanel getControls()
JSlider rotate = getSlider("rotation angle", "rotation", -90, 0, 0, 5, 15);
translate = getSlider("distance from end", "translate", 0, 100, 100,25, 50);
JPanel panel = new JPanel(new GridLayout(0,1));
panel.add(rotate);
panel.add(translate);
return panel;
private JSlider getSlider(String title, String name, int min, int max,
int value, int minorSpace, int majorSpace)
JSlider slider = new JSlider(JSlider.HORIZONTAL, min, max, value);
slider.setBorder(BorderFactory.createTitledBorder(title));
slider.setName(name);
slider.setPaintTicks(true);
slider.setMinorTickSpacing(minorSpace);
slider.setMajorTickSpacing(majorSpace);
slider.setPaintLabels(true);
slider.addChangeListener(this);
return slider;
}OK, My questions are:
[1]. what I generated XML by XSTream is very complicated, especially for object LocationTest, Can we make it as simple as others such as Person object??
[2]. after I run it, LocationTest will popup and a red ball in a panel will dsiplay, after I change red ball's position, I hope to persist it to xml, then when I read it back, I hope to get same picture, ie, red ball stiil in old position, How to do that??
Thanks a lot!!Positive feedback? Then please take this in a positive way: if you want to work on persisting Java objects into XML, then GUI programming is irrelevant to that goal. The 1,000 lines of code you posted there appeared to me to have a whole lot of GUI code in it. You should produce a smaller (much smaller) example of what you want to do. Calling the working code from your GUI program should come later.
-
How can I use Method in the bean
Hi every one
please I made a method in for example employees entity "EmployeesImpl"
the name of method getmax() it return number
how can I use it at the bean
for eaxmple when I want to press button give me the value from this method
sorry Iam still beginner
thanks in advanceThanks sir for your response
my version
oracle jdeveloper reales 1 (11,1,1,4,0)
I use business component
I make method
this metod wrote at enitity "EmployeesImpl"
public Number getMax() throws JboException
PreparedStatement stat=null;
ResultSet rs=null;
try {
String sql="select max(EMPLOYEE_ID)+1 from EMPLOYEES";
stat=getDBTransaction().createPreparedStatement(sql, 1);
rs=stat.executeQuery();
if (rs.next()) {
return new Number (rs.getInt(1));
} catch (Exception e) {
// TODO: Add catch code
//e.printStackTrace();
throw new JboException("error");
} finally {
try {
rs.close();
stat.close();
} catch (Exception e) {
// TODO: Add catch code
//e.printStackTrace();
// oracle.jbo.domain.Number
return new Number (1);
I made a jsf page
and I put button at the page
I want when press the button give me message contain the number which come from previous metod
thanks my dear -
How can I execute a statement before a VO is running
JDEVADF_11.1.1.3.PS2_GENERIC_100408.2356.5660
I use ADF BC
how can I execute a statement before a VO is runningthanks for the answer
i use a logon function before I run a VO
after a certain time will be disconnected
and I have to call the function again
sorry for my English
public String logon(String username, String password){
CallableStatement st = null;
this.username = username;
this.password = password;
try {
st = getDBTransaction().createCallableStatement("begin ep_security.LogOn(?,?); end;",0);
st.setObject(1, username);
st.setObject(2, password);
st.executeUpdate();
this.getDBTransaction().commit();
} catch (SQLException e) {
System.out.println("ERROR "+e.getMessage());
this.addWarning(new JboWarning("Quote retrieved successfully"));
System.out.println("...RETURN ERROR");
return "error";
} finally {
if (st != null) {
try {
// 7. Close the statement
st.close();
} catch (SQLException e) {
e.printStackTrace();
}
Maybe you are looking for
-
How to display a single dot in java?
My teacher ask me to use digital differential analyzer(DDA) routine for rasterizing a line the problem is i can't use the drawLine() method,i only can draw a lot of dot so can somebody tell me how to display a single dot???? thanks in advance
-
I bought an Ipod for my husbands birthday and when I connect it to the computer it shows someone elses name. I don't want to erase my list of music for my Ipod I need help.
-
Problem displaying video from 2 webcams
(Sorry for my bad english) Hi, I'm trying to display a video preview from 2 webcams, the problem is that I'm able to show one at a time but not the two. The java media registry only detects one at a time if the two are plugged, it shows it's locator:
-
I get a lot of squares in different colors in my Firefox for android. This started today How or where can I send a screen shot? ToddeSwe
-
Cannot place file in sidebar of Mac OS X Lion
in Mac OS X Snow Leopard (10.6.x) I was able to place a file on the sidebar and when I clicked on it, it would open. Mac OS X Lion does not allow placing a file ( a .doc file, for example) in the sidebar. I know I need to convert an alias to a certai