cancel
Showing results for 
Search instead for 
Did you mean: 

error while trying to update Java Dictionnary Table

Former Member
0 Kudos

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!!

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi,

con.createStatement().executeUpdate ("insert into IR_TETS(NAME, SURNAME ) values('" + value + "','" + value2+'")");

add a single quote before and after the value and value2 which is shown in bold.

In my previous post its much more readable

Regards

Ayyapparaj

Answers (7)

Answers (7)

Former Member
0 Kudos

It worked!!!

Ayyapparaj, I cannot Thank you enough!!!!!!!

All i can do is give you points for every reply you gave!!!

THANX!!!

Former Member
0 Kudos

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!!!

Former Member
0 Kudos

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

Former Member
0 Kudos

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!!!!

Former Member
0 Kudos

Hi,

Is their any unique contraint on the table for this columns?

Connection con = ds.getConnection();

Try with the following statement.

con.createStatement().executeUpdate ("insert into IR_TETS

(NAME, SURNAME ) values ('a','b')");

Regards

Ayyapparaj

Former Member
0 Kudos

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???

Former Member
0 Kudos

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!!!

Former Member
Former Member
0 Kudos

Hi,

Pl refer this thread for connection

Try to replace the code with

DataSource dataSource = (DataSource)initialContext.lookup("jdbc/POSEIDON");

Regards

Ayyapparaj

Former Member
0 Kudos

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!

Former Member
0 Kudos

wdComponentAPI.getMessageManager().reportException( ex.getMessage() );
Former Member
0 Kudos

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