You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@servicemix.apache.org by servicemix servicemix <se...@gmail.com> on 2007/06/07 14:35:40 UTC

Bug into JDBCStoreFactory

Hi, I think that, there is a bug in JDBStoreFactory: when I open a store
with:
Store store=factory.open("store");

I receive an SQLException : Exception while creating database

I move the connection.commit(); from  JDBStoreFactory line 62 and it work...

There is the source  code of the function:

  public synchronized Store open(String name) throws IOException {
        if (adapter == null) {
            Connection connection = null;
            try {
                connection = getDataSource().getConnection();
                adapter = JDBCAdapterFactory.getAdapter(connection);
                if (statements == null) {
                    statements = new Statements();
                    statements.setStoreTableName(tableName);
                }
                adapter.setStatements(statements);
                if (createDataBase) {
                    adapter.doCreateTables(connection);
                    if(!connection.getAutoCommit())
                        connection.commit();
                }
                 connection.commit();
            } catch (SQLException e) {
                throw (IOException) new IOException("Exception while
creating database").initCause(e);
            } finally {
                if (connection != null) {
                    try {
                        connection.close();
                    } catch (Exception e) {
                    }
                }
            }
        }
        JdbcStore store = stores.get(name);
        if (store == null) {
            store = new JdbcStore(this, name);
            stores.put(name, store);
        }
        return store;
    }


Thanks.

Re: Bug into JDBCStoreFactory

Posted by Guillaume Nodet <gn...@gmail.com>.
Please raise a JIRA and attach your patch, thx !

On 6/7/07, servicemix servicemix <se...@gmail.com> wrote:
>
> Hi, I think that, there is a bug in JDBStoreFactory: when I open a store
> with:
> Store store=factory.open("store");
>
> I receive an SQLException : Exception while creating database
>
> I move the connection.commit(); from  JDBStoreFactory line 62 and it
> work...
>
> There is the source  code of the function:
>
>   public synchronized Store open(String name) throws IOException {
>         if (adapter == null) {
>             Connection connection = null;
>             try {
>                 connection = getDataSource().getConnection();
>                 adapter = JDBCAdapterFactory.getAdapter(connection);
>                 if (statements == null) {
>                     statements = new Statements();
>                     statements.setStoreTableName(tableName);
>                 }
>                 adapter.setStatements(statements);
>                 if (createDataBase) {
>                     adapter.doCreateTables(connection);
>                     if(!connection.getAutoCommit())
>                         connection.commit();
>                 }
>                  connection.commit();
>             } catch (SQLException e) {
>                 throw (IOException) new IOException("Exception while
> creating database").initCause(e);
>             } finally {
>                 if (connection != null) {
>                     try {
>                         connection.close();
>                     } catch (Exception e) {
>                     }
>                 }
>             }
>         }
>         JdbcStore store = stores.get(name);
>         if (store == null) {
>             store = new JdbcStore(this, name);
>             stores.put(name, store);
>         }
>         return store;
>     }
>
>
> Thanks.
>



-- 
Cheers,
Guillaume Nodet
------------------------
Principal Engineer, IONA
Blog: http://gnodet.blogspot.com/