Announcement Announcement Module
Collapse
No announcement yet.
Performance of Spring JdbcTemplate using oracle10g Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Performance of Spring JdbcTemplate using oracle10g

    Hai,

    I am new to spring Framework. I have implemented the application using SpringJdbcTemplate and StrutsMVC.Before I had implemented using normal jdbc Connection. We have any differnce to use Spring JdbcTemplate and Normally using JdbcConnection(In Struts Action file, We using initialcontext class and lookup darasource).


    In pure struts, I have used


    Context initContext = new InitialContext();
    Context envContext = (Context)initContext.lookup("java:/comp/env");
    DataSource ds = (DataSource)envContext.lookup("jdbc/hrms");

    conn = ds.getConnection();

    String sqlquery5="select BLNSTATUS from TBLEK_PHONE where PHONE_ID=?";
    //String sqlquery5="select P.COUNTRY_CODE,P.AREA_CODE,P.EXTENSION,P.PHONE_NO, P.BLNSTATUS,(CASE WHEN PT.PHONE_TYPE_ID = 8 THEN P.IF_OTHER_PHONE_TYPE ELSE PT.PHONE_TYPE_NAME END) AS PHONE_NAME from TBLEK_PHONE P Inner Join TBLEK_PHONE_TYPE PT ON P.PHONE_TYPE_ID = PT.PHONE_TYPE_ID where P.PHONE_ID=?";
    PreparedStatement UserRegisterSt5 = conn.prepareStatement(sqlquery5);
    UserRegisterSt5.setString(1,radiovalue);
    rs=UserRegisterSt5.executeQuery();
    String sts="";

    while(rs.next())
    {
    sts=rs.getString("BLNSTATUS");

    }




    In spring JdbcTemplatem,

    ApplicationContext ctx=new ClassPathXmlApplicationContext("SpringConfig.xml") ;
    dataSource = (DataSource)ctx.getBean("mydataSource");
    JdbcTemplate jt = new JdbcTemplate(dataSource);



    public Collection findAll() throws RemoteException {
    JdbcTemplate jt = new JdbcTemplate(dataSource);
    String sql = "select EMPID,FIRSTNAME,LASTNAME from EMPLOYEE order by FIRSTNAME";
    return jt.query(sql,new EmployeeTOMapper());
    }

    public class EmployeeTOMapper implements RowMapper {
    public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
    Integer empId = new Integer(rs.getInt("EMPID"));
    String FirstName = rs.getString("FIRSTNAME");
    String LastName = rs.getString("LASTNAME");
    Employee empTo = new Employee(empId,FirstName,LastName);
    return empTo;
    }
    }

    What difference between above two, tell me.Used Oracle 10g for both. Because after I implementing SpringJdbcTemplate we have face the new major error sometimes,

    Could not get JDBC Connection; nested exception is java.sql.SQLException: Io exception:
    Connection refused(DESCRIPTION=(TMP=)(VSNNUM=169869568)(ERR=1 2519)(ERROR_STACK=(ERROR=(CODE=12519)(EMFI=4))))

    Caused by: java.sql.SQLException: Io exception: Connection


    Thanks and Regards,
    Venkatesh

  • #2
    Plz check this link, hope this can help u.
    The error produce seems same with u.

    http://forum.springframework.org/sho...d.php?p=133267

    Comment

    Working...
    X