• 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

How to use Oracle in Struts application?

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hey friends
I am learning struts Framework and using Oracle as backend.But i dont know how to use it.can anyone tell what i have to do for it?What drivers I would be needing? and the datasource configuration?Currently i am using mysql as backend.

regards
 
Ranch Hand
Posts: 111
Mac Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi sarang,

If you are already using MySQL, then you don't need to update much of your code. You need to change some details in struts-config.xml file or web.xml file.

Oracle comes with the drivers you need to use, so don't worry about the drivers. Oracle comes with Type2 OCI driver and Type4 pure Java driver.

Hope this helps.
 
Ranch Hand
Posts: 225
IBM DB2 Eclipse IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by sarang bharambe:
hey friends
I am learning struts Framework and using Oracle as backend.But i dont know how to use it.can anyone tell what i have to do for it?What drivers I would be needing? and the datasource configuration?Currently i am using mysql as backend.

regards


Hi little bit specific

this is how u can use

public class StudentDao
{
Connection con = null;
Statement st = null;
ResultSet rs = null;
DataSource ds = null;
Context ctx = null;
String item = null;
String value = null;
boolean flag = false;
String skill= null;
String jcode = null;
String loc = null;
String pos = null;
String desc = null;
int max = 0;
int min = 0;
//HttpSession workSession = null;
//workSession = req.getSession(true);


public static void display()
{
System.out.println(" i am from dao display");
}

public Collection getSubjects() throws Exception
{
ArrayList list = new ArrayList();
try
{
Properties p = System.getProperties();
p.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
p.put(Context.PROVIDER_URL,"t3://localhost:7001");
ctx = new InitialContext(p);
ds = (DataSource) ctx.lookup("RmsJndi2");
con = ds.getConnection();
st = con.createStatement();
con.setAutoCommit(true);
rs = st.executeQuery("select * from combo");

while(rs.next())
{
item = (String) rs.getString("item");
value = (String) rs.getString("value");
System.out.println(item+" "+value);
list.add(new SubjectBean(value,item));
}// while
} // try
catch(Exception e )
{
System.out.println(" Exception error "+e.getMessage());
}
finally
{
con.close();
st.close();
//rs.close();
}// finally
return list;
}// fn get subjects

}


as usal DAO pattern u can use ...

if u use <datasource> that becomes problem in performance issue slater if u didnt designur code well.....

Lt me know if this help u

 
Ganesh Gowtham
Ranch Hand
Posts: 225
IBM DB2 Eclipse IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi sorry to mentioned i had tested the above code Using weblogic 8.1
 
What are you doing? You are supposed to be reading this tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic