[Building Sakai] jdbc spring slowly

yolima u yolimita.uribe at gmail.com
Tue May 26 17:54:15 PDT 2009


hi all,
 i'm developing  a tool in sakai using  jdbc spring for the connection to
the data base
i'm working with a bean where i create all the functions for the data base:

public class MetGwBean {

	private DataSource dataSource;

	public void setDataSource(DataSource dataSource) {
		this.dataSource = dataSource;
	}
	
	
	
	public void Insertar(String sql,Object[] obj)throws SQLException{
	
		   
	   JdbcTemplate sel = new JdbcTemplate(dataSource);
	   
	   try {		   
		   sel.update(sql, obj);
		   // do things with your connection (select, insert, delete, etc.)
	   } finally {
	      
	   }
	}
	
	public List SelectObjetos(String sql,Object[] obj)throws SQLException{
		   
		JdbcTemplate sel = new JdbcTemplate(dataSource);
		try{
			return sel.queryForList(sql, obj, String.class);
			}finally{
				
			}
	}
	
	public List Selectsolo(String sql)throws SQLException{
			   
		JdbcTemplate sel = new JdbcTemplate(dataSource);
		try{
			return sel.queryForList(sql,String.class);
			}finally{
			
			}
	}
	
	public void Borrar(String sql,Object[] obj)throws SQLException{
		 
		   
		   JdbcTemplate sel = new JdbcTemplate(dataSource);
		   
		   try {			   
			   sel.update(sql, obj);
			   // do things with your connection (select, insert, delete, etc.)
		   } finally {
		   
		   }
		
	}
	
	public void Actualizar(String sql,Object[] obj)throws SQLException{
		  
		   
		   JdbcTemplate sel = new JdbcTemplate(dataSource);
		   
		   try {			   
			   sel.update(sql, obj);
			   // do things with your connection (select, insert, delete, etc.)
		   } finally {
		      
		   }
		
	}
	
	public String Selectid(String sql,Object[] obj)throws SQLException{
			   
		JdbcTemplate sel = new JdbcTemplate(dataSource);
		try{
			return (String)sel.queryForObject(sql, obj, String.class);
			}
		finally{
				
			}
	}
	
	public int Selectint(String sql,Object[] obj)throws SQLException{
			   
		JdbcTemplate sel = new JdbcTemplate(dataSource);
		try{
			return sel.queryForInt(sql, obj);
			}
		finally{
				
			}
	}		
}



later i call this functions in a jsp page, for example:



if (request.getParameter("guardar")!=null)
	{
		if (request.getParameter("textarea")!=null)
		{
			objgen.setProyecto(bean2.getCurrentSiteId());//id del proyecto
			String
idobgen=bean.Selectid(objgen.SqlObjId(),objgen.ObjetoBuscar(objgen));//buscar
el id del obj general
			objesp.setObjgeneral(Integer.parseInt(idobgen));//id de obj general en
obj esp
			objesp.setdescObjetivo(request.getParameter("textarea"));
			objesp.setAutor(bean2.getCurrentUserId());
			objesp.setestado("en definicion");
			objesp.setprioridad(0);
			bean.Insertar(objesp.SqlInsertar(),objesp.ObjetoInsertar(objesp));	
			response.sendRedirect("objetivos_esp.jsp");
			return;
		}		
	}

the problem is that the tool is fast for to do the select, but the tool
takes so much time for to do the inserts, like 3 to 4 minutes.

and in some jsp pages i need show data of the data base that i just insert
to the DB, but how the tool does this so slowly, the jsp page can't show
this data.

why does the tool do the insert to slowly?
what can i do for do this more fast?

-- 
View this message in context: http://www.nabble.com/jdbc-spring-slowly-tp23734131p23734131.html
Sent from the Sakai - Development mailing list archive at Nabble.com.



More information about the sakai-dev mailing list