on 05-21-2008 9:41 AM
Hi experts!!
I am trying to implement a WD Java with two views.
The first ones passes the selection parameters for the select statement (to acces the database) in the second one that will show the result of the select statement in table format.
So far i've implemented the first part:
When the user presses the 'Submit' button of the first view the following code is triggered. My question is how can i pass the data to the second view's table??? And in which method of the view??
IWDNode node = wdContext.getChildNode("TEST",0);
ITESTElement test = wdContext.nodeTEST().currentTESTElement();
String name = (String) test.getAttributeValue("NAME");
String surname = (String) test.getAttributeValue("SURNAME");
InitialContext ctx;
try {
ctx = new InitialContext();
DataSource ds = (DataSource)ctx.lookup( "jdbc/SELECT_POOL");
Connection con = ds.getConnection();
String SelectStmt = "select * from IR_TETS where "
+ "where NAME = '" + name + "'" ;
PreparedStatement stmt = con.prepareStatement(SelectStmt);
ResultSet resultSet = stmt.executeQuery();
Please help!!!
Thanx in advance!!!
Hi Ayyapparaj!
I changed :
1) my element in the database table and turned it to integer
2) i re-deployed my dictionnary project
3) my context element in the database is integer
and still i get this message:
The method setAttributeValue is not applicable for the arguments
(String, int)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ayyapparaj,
Once again thank you for your reply!!!!
Regards,
Iria
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can i ask one more thing???
What if i did not have only value to select from the table??
Something like..
Select * from <table> where name between <value1> and <value2> ..
How could we do that in java??
THANX IN ADVANCE!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ayyapparaj,
it works fine!!!
I also tried this one:
element.setAttributeValue("AGE" , resultSet.getObject("AGE"));
and it works too!!!
I am posting it in case any one else needs it.
Thank you for all your help!!!
Best Regards,
Iria
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ayyapparaj!!
Thank you for your reply!!
The code you sent works just fine, but the following line has a problem
element.setAttributeValue("Age", resultSet.getInt("AGE"));
I searched the setAttributeValue method but could not find why it does not work with integers.
I set the AGE to String and it works fine!!
THANX AGAIN!!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
While creating the table what was the datatype of "AGE"?
If its string you have to use the string.
That could be one the issue related with the error in the following line
element.setAttributeValue("Age", resultSet.getInt("AGE"));
Pl have a check at the backend (database) datatype and make use of it.
Regards
Ayyapparaj
Hi,
Create a node which contains two attributes
Ex:
Details Cardianlity 0..n
Name String
Age integer
Following code will help you to populate the context created above using the data fetched from DB
InitialContext ctx;
try {
ctx = new InitialContext();
DataSource ds = (DataSource)ctx.lookup( "jdbc/SELECT_POOL");
Connection con = ds.getConnection();
String SelectStmt = "select NAME,AGE from IR_TETS where "
+ "where NAME = '" + name + "'" ;
PreparedStatement stmt = con.prepareStatement(SelectStmt);
ResultSet resultSet = stmt.executeQuery();
while (resultSet.next())
{
IWDNodeElement element = wdContext.nodeDetails().createElement();
element.setAttributeValue("Name", resultSet.getString("NAME"));
element.setAttributeValue("Age", resultSet.getInt("AGE"));
wdContext.nodeDetails().addElement(element)
}
}catch (Exception e) {
// TODO: handle exception
}
Now bind this node to the table
If their exists records in db you will be able to see them
Regards
Ayyapparaj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
80 | |
24 | |
11 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.