on 05-19-2008 11:36 AM
Hi experts!!
I am trying to insert some data in a table in the Java Dictionnary, from my WD form template view. I use the following code:
The node's name is "TEST" and the table's name "IR_TETS".
It is not working... Any ideas??????
IWDNode node = wdContext.getChildNode("TEST",0);
ITESTElement test = wdContext.nodeTEST().currentTESTElement();
String value = (String) test.getAttributeValue("NAME");
String value2 = (String) test.getAttributeValue("SURNAME");
InitialContext ctx;
try {
ctx = new InitialContext();
DataSource ds = (DataSource) ctx.lookup("java:comp/env/jdbc/POSEIDON");
Connection con = ds.getConnection();
con.createStatement().executeUpdate ("insert into IR_TETS"
+ "(NAME, SURNAME )"
+ "values (value , value2)");
} catch (NamingException e) {
} catch (SQLException e2){
// TODO Auto-generated catch block
e2.printStackTrace();
}
THANX IN ADVANCE!!
Still no solution..
John Adams are the values i gave..
this is the error message..
The SQL statement "INSERT INTO "IR_TETS" ("NAME","SURNAME") VALUES ("JOHN","ADAMS")" contains the semantics error[s]: - 1:43 - the column >>JOHN<< is undefined in the current scope - 1:48 - the column >>ADAMS<< is undefined in the current scope
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It worked!!!
Ayyapparaj, I cannot Thank you enough!!!!!!!
All i can do is give you points for every reply you gave!!!
THANX!!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I had already tried this and it works just fine.
But how about getting the value of the context???
P.S. Ayyapparaj, thanx for yr patience & time!!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Following will work for you
ITESTElement test = wdContext.nodeTEST().currentTESTElement();
String value = (String) test.getAttributeValue("NAME");
String value2 = (String) test.getAttributeValue("SURNAME");
con.createStatement().executeUpdate ("insert into IR_TETS(NAME, SURNAME ) values('" + value + "','" + value2+"')");
Regards
Ayyapparaj
I solved the data source problem by creating a datasources.xml file with an alias and i then used the path jdbc/<alias_name>.
I now get an SQL message so any help would be really appreciated..
The message is this..
The SQL statement "INSERT INTO "IR_TETS" ("NAME","SURNAME") VALUES ("NAME","SURNAME")" contains the semantics error[s]: - 1:46 - column ""NAME"" not unique - 1:53 - column ""SURNAME"" not unique
the values of name & surname are retrieved by the context of the WD
with this code...
IWDNode node = wdContext.getChildNode("TEST",0);
ITESTElement test = wdContext.nodeTEST().currentTESTElement();
String name = (String) test.getAttributeValue("NAME");
String surname = (String) test.getAttributeValue("SURNAME");
ANY IDEAS???
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.
Hi Ayyapparaj!
and thank you again . I tried what you told me but i now get this error message:
Object not found in lookup of jdbc/POSEIDON
Any other ideas???
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You were right! The problem is with the data source.
The error message is
Path to object does not exist at java:comp, the whole lookup name is java:comp/env/jdbc/POSEIDON.
Apart from the visual administrator is there any other place i can find the correct path of the data source???
Thanx once again!!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Maybe this helps a little bit more:
http://help.sap.com/saphelp_nw70/helpdata/EN/5d/dc03f00a484a96aff15f901ad175f2/frameset.htm
First of all, thank you for your reply. I have a question..
Since these are specific Exceptions (Naming & SQL) how can i use the message manager???
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,
Was your dictionary project successfully deployed?
Is their any exception ?
Try to print the exception using message manager so that you dont have to look at the server logs.
Where this code exists in your app?
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 |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.