File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Parameter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Parameter" Watch "Parameter" New topic
Author

Parameter

Jennifer Sohl
Ranch Hand

Joined: Feb 28, 2001
Posts: 455
How do I pass the value from a parameter field (:NAME) to a String variable (newvend)? What is the syntax? Is it anything like newvend = :NAME? I can't seem to find any documentation on this. Please help.
A clueless newbie,
Thanks!
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
I think you will need to give us a bit more context. Where does your parameter come from? what does it contain?


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
If the value is coming in as a parameter on a method, you can use the variable name that the method defined in the signature.
public void myMethod(String s){
System.out.println(s);
}
When the method is called with
String name = "Cindy";
myMethod(name);
The input parameter will be printed on the console.
If the parameter is coming in from the command line
>java myApp Cindy
Then in the main method you need to set the variable to the value of arg[0]
String x = arg[0];
System.out.println(x);
will print Cindy to the console.


"JavaRanch, where the deer and the Certified play" - David O'Meara
Jennifer Sohl
Ranch Hand

Joined: Feb 28, 2001
Posts: 455
I have a SELECT statement:
"SELECT dbo.PCVENDX.PCVNO, dbo.PCVENDX.PCVNM, FROM dbo.PCVENDX WHERE ( ( dbo.PCVENDX.PCVNO = :NEXT ) )";
Whatever the user keys into the vendor number field, gets passed to the :NEXT parameter.
Now, I need to pass the value of the :NEXT parameter to a String variable name "newvend".
Could you do something like this:
newvend = getNextVendor.getParameter("NEXT") ??
Sorry, this is hard to explain. Let me know if I've confused you!
BTW, is there somewhere that I could find examples or documentation on syntax when parameter fields(from a SELECT statement) are involved?
Thanks for your time!
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521

TextField vendorNumber = new TextField(10);
String next = vendorNumber.getText();
String sql = "SELECT dbo.PCVENDX.PCVNO, dbo.PCVENDX.PCVNM, FROM dbo.PCVENDX WHERE ( ( dbo.PCVENDX.PCVNO = " + next + " ) )";
Then use the sql variable to make your JDBC call.
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

You can also use PreparedStatemens. Find out more here: http://java.sun.com/j2se/1.3/docs/api/java/sql/PreparedStatement.html
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Parameter