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