• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JTA Enabled data source on WAS 3.5 with Oracle.

 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
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;
try{
out.println("First 11");
Properties properties = new Properties();
properties.put(Context.PROVIDER_URL,"iiop://localhost:900");
properties.put(Context.INITIAL_CONTEXT_FACTORY,"com.ibm.ejs.ns.jndi.CNInitialContextFactory");
initContext = new InitialContext(properties);
out.println("2");
}//End of try
catch(NamingException ne)
{
out.println("Exception inside "+ne.toString());
}//End of catch()
try{
out.println("3");
DataSource ds = (DataSource)
initContext.lookup ("jdbc/skDataSource");
out.println("4");
Connection cn = ds.getConnection("lms","lms");
out.println("5");
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");
while(rs.next())
out.println("name ="+rs.getString(1));
if(smt!=null)
smt.close();
out.println("Close");
if(cn!=null)
cn.close();
out.println("conn Close");
}
catch(Exception e)
{
out.println("Exception inside"+e);
} <html> </html>
 
Ranch Hand
Posts: 567
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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()
Adam
 
Uh oh, we're definitely being carded. Here, show him this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic