[Building Sakai] jdbc spring slowly
yolima u
yolimita.uribe at gmail.com
Wed May 27 16:05:39 PDT 2009
thank you, i'm working now with the class that you told me and it works
excelent,
idon't have to wait 3 minutes jajajaja, thanks
Aaron Zeckoski wrote:
>
> Normally spring jdbc will do a commit for each update/insert/delete
> that you run using the jdbctemplate. If you are doing a lot of these
> without a transactional wrapper then it can be a little bit expensive
> (though not typically the amount of time you are talking about).
>
> I recommend you try using the spring JdbcDaoSupport class and take a
> look at the example code here:
> http://bugs.sakaiproject.org/confluence/display/BOOT/Spring+JDBC+Info
>
> It may help to clean up all the empty try/finally blocks in your code
> for readability when pasting it here. You also might want to send
> along your spring configuration file along with your code.
> Hope this helps
> :-)
> -AZ
>
>
> On Wed, May 27, 2009 at 1:54 AM, yolima u <yolimita.uribe at gmail.com>
> wrote:
>>
>> 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.
>>
>> _______________________________________________
>> sakai-dev mailing list
>> sakai-dev at collab.sakaiproject.org
>> http://collab.sakaiproject.org/mailman/listinfo/sakai-dev
>>
>> TO UNSUBSCRIBE: send email to
>> sakai-dev-unsubscribe at collab.sakaiproject.org with a subject of
>> "unsubscribe"
>>
>
>
>
> --
> Aaron Zeckoski (aaronz at vt.edu)
> Senior Research Engineer - CARET - Cambridge University
> [http://bugs.sakaiproject.org/confluence/display/~aaronz/]
> Sakai Fellow - [http://aaronz-sakai.blogspot.com/]
> _______________________________________________
> sakai-dev mailing list
> sakai-dev at collab.sakaiproject.org
> http://collab.sakaiproject.org/mailman/listinfo/sakai-dev
>
> TO UNSUBSCRIBE: send email to
> sakai-dev-unsubscribe at collab.sakaiproject.org with a subject of
> "unsubscribe"
>
--
View this message in context: http://www.nabble.com/jdbc-spring-slowly-tp23734131p23752443.html
Sent from the Sakai - Development mailing list archive at Nabble.com.
More information about the sakai-dev
mailing list