cancel
Showing results for 
Search instead for 
Did you mean: 

webdynpro to oracle db

Former Member
0 Kudos

hi experts,

created one webdynpro application which connect to Oracle database, directly without webservices and ejbs.

my code is as follows:

Connection con = null;

Statement stmt = null;

DataSource ds=null;

ResultSet rs=null;

try

{

InitialContext x = new InitialContext();

ds = (DataSource)x.lookup("jdbc/datadb");

con = ds.getConnection();

stmt = con.createStatement();

rs = stmt.executeQuery("INSERT INTO APPLICANTDTLS1(APPLICANTID,APPFIRSTNAME,APPMIDDLENAME) VALUES ('1234','SSS','YYY') ");

}

catch(Exception e)

{

}

since there was no error , but when i see the database no record was inserted

so how can i find out where i want wrong.

could anyone help me on this issue

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

hi vijay

please close this post by updating this to answered

Regards

Chaitanya.A

Message was edited by:

Armin Reichert

Former Member
0 Kudos

Hi did you got the solution?

if yes close this question

if you have any other solutions please mention so that we can have scope to learn new things

Regards

Chaitanya.A

Former Member
0 Kudos

hi Chaitanya,Rekha,sridhar,

Thank you for reply,

i once again thank you all

problem solved.

if any query i will come back soon.

thank you,

-


vijai

Former Member
0 Kudos

Hi Vijay

got the solution ?

if yes just update this post as answered

if you have any other solution just post it so that we all can learn a new way of doing the thing.

Regards

Chaitanya.A

former_member193726
Active Participant
0 Kudos

Hi Vijay,

Lets try to print messages from Catch block. Might be the connection threw some error.

try

{

InitialContext x = new InitialContext();

ds = (DataSource)x.lookup("jdbc/datadb");

con = ds.getConnection();

stmt = con.createStatement();

rs = stmt.executeQuery("INSERT INTO APPLICANTDTLS1(APPLICANTID,APPFIRSTNAME,APPMIDDLENAME) VALUES ('1234','SSS','YYY') ");

}

catch(Exception e)

{

wdComponentAPI.getMessageManager().reportException("INSIDE CATCH", true);

}

Regards,

Rekha Malavathu

Former Member
0 Kudos

Hi Vijay,

Whart Rekha advised that is correct Put Print Statement in Catch Block.

Add this point also

Use

stmt.<b>executeUpdate</b>("INSERT INTO APPLICANTDTLS1(APPLICANTID,APPFIRSTNAME,APPMIDDLENAME) VALUES ('1234','SSS','YYY') ");

If it successfully record inserted in to Database it will return 1 otherwise not.

Regards

-SS

Former Member
0 Kudos

Hi Vijay

Instead of execute query use PREPARED STATEMENT

PreparedStatement ps=con.prepareStatement("INSERT INTO APPLICANTDTLS1 values(?,?,?)");

ps.setInt(1,APPLICANTID);

ps.setString(2,APPFIRSTNAME);

ps.setString(3,APPMIDDLENAME);

);

ps.executeUpdate();

Regards

Chaitanya.A