File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes JTA Enabled data source on WAS 3.5 with Oracle. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "JTA Enabled data source on WAS 3.5 with Oracle." Watch "JTA Enabled data source on WAS 3.5 with Oracle." New topic

JTA Enabled data source on WAS 3.5 with Oracle.

Prince Manchanda
Ranch Hand

Joined: Jun 25, 2001
Posts: 52
I am using WAS 3.5. I have a datasource created on it which is JTA enabled. My problem is that when i insert records into a table, the changes are not reflected in the database. But when i issue select from my code, it shows the new records.
Do i need to do something extra to commit the changes to the database. My database is Oracle 8.1.5.
My JSP code is given below:
<%@ page import="javax.sql.DataSource,java.sql.*,java.rmi.RemoteException,java.util.*,javax.rmi.*, javax.naming.*" %;
Context initContext=null;
out.println("First 11");
Properties properties = new Properties();
initContext = new InitialContext(properties);
}//End of try
catch(NamingException ne)
out.println("Exception inside "+ne.toString());
}//End of catch()
DataSource ds = (DataSource)
initContext.lookup ("jdbc/skDataSource");
Connection cn = ds.getConnection("lms","lms");
Statement smt= cn.createStatement();
int i=smt.executeUpdate("insert into test1 values('khare','1')");
out.println("succese i= "+i);
ResultSet rs= smt.executeQuery("select * from test1");
out.println("name ="+rs.getString(1));
out.println("conn Close");
catch(Exception e)
out.println("Exception inside"+e);
} <html> </html>

Thanks and Regards
P Manchanda
Adam Hardy
Ranch Hand

Joined: Oct 09, 2001
Posts: 567
Your insert statement should auto-commit if you haven't told it otherwise.
However I haven't used JTA - perhaps somebody else who has done can help.

It's not clear what you mean - does the inserted record never ever turn up again?
Your last catch block looks a bit weird too. It should be e.toString() or e.getMessage()

I have seen things you people would not believe, attack ships on fire off the shoulder of Orion, c-beams sparkling in the dark near the Tennhauser Gate. All these moments will be lost in time, like tears in the rain.
I agree. Here's the link:
subject: JTA Enabled data source on WAS 3.5 with Oracle.
It's not a secret anymore!