on 08-28-2007 9:41 AM
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
hi vijay
please close this post by updating this to answered
Regards
Chaitanya.A
Message was edited by:
Armin Reichert
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
24 | |
12 | |
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.