cancel
Showing results for 
Search instead for 
Did you mean: 

saving data in sql database

Former Member
0 Kudos

Ive seen same title subjects but apparently these topics have been deleted. Anyway,

I have a data base named "TestDB", under url www.mysql.com/TestDB. I did in it 2 fields, "ProjectNr", "ProjectName".

Now, I have Webdyn Pro app with two InputFields binded to Contexts "ProjectNr", "ProjectName" and a button "Save"

What code do I need to write in onActionSave() part to make data written into those two fields be saved in sql database after pressing Save button.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

Following is the code, pl aligh that to your requirement

try {

Class.forName("com.sap.dbtech.jdbc.DriverSapDB");

String url="jdbc:sapdb://<HostID>/J2E?sqlmode=ORACLE";

Connection con=DriverManager.getConnection(url,"UserID","password");

String projectID = wdContext.current<Yournode>Element().get<yourAttribute>();

String projectName = wdContext.current<YourNode>Element().get<your Attribute>();

String sql = "insert into Project values (?,?)";

PreparedStatement stmt = con.prepareStatement(sql);

stmt.setString(1, projectID);

stmt.setString(1, projectName);

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

try to make use of JNDI for database connections. That s one of the best practises.

http://java.sun.com/javase/technologies/database/

Regards

Ayyapparaj

Former Member
0 Kudos

thanks for help.

What did you meant by CurrenTElement couse everything I write in there provides an error. Regards

Former Member
0 Kudos

Hi,

String projectID = wdContext.currentTElement().getT1();

String projectName = wdContext.currentTElement().getT1();

Instead of this change to your current node element.

Regards

Ayyapparaj

Former Member
0 Kudos

yeah. and what's T1?

Former Member
0 Kudos

HI,

replace t1 and t2 with the project id and the other attribute i have modified my earliest post so that it is easy for you ....

Regards

Ayyapparaj

Former Member
0 Kudos

I got that just asked because that provides me an error in that place if I wrote there project id, undefined IContextElement is says, most odd that whole thing broke my another action, makes key word void a syntaxt error and thats not "}" issue.