Hi i want to connect oracle with struts action class. Can i do this without DataSource? My Code Like This, this code always throws exception after ClassforName line. So "Sonuc" parameter value is being 0.
package KULLANICI;
import org.apache.struts.action.*;
import javax.servlet.http.*;
import java.io.*;
import java.sql.*;
import oracle.jdbc.driver.*;
public class GirisAction extends Action{
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,HttpServletResponse response) throws Exception{ GirisForm gForm = (GirisForm) form; String KulAd = gForm.getKulAd();
String Sifre = gForm.getSifre();
Connection Conn; Statement stmt;
ResultSet rs;
int Sonuc=0; try
{
Class.forName("Oracle.jdbc.driver.OracleDriver");
Conn = DriverManager.getConnection("jdbc:oracle:thin:localhost:1528:ORCL","System","vol83kan");
stmt = Conn.createStatement(); rs = stmt.executeQuery("Select COUNT(*) as number from KULLANICI where KUL_AD = 'vunal' and SIFRE = 'vol83kan'"); rs.next(); Sonuc = rs.getInt("number");
rs.close();
}
catch(Exception ex)
{
System.out.println(ex.getMessage() + Sonuc);
}
if(Sonuc != 0)
{ return mapping.findForward("Success");
}
else
{ return mapping.findForward("Failed");
} }