|
From: <Jon...@o2...> - 2004-07-08 17:48:00
|
What do you think about a generic addition? Like
public interface ConnectionCallback
{
Object doWithConnection(Connection conn)
throws
SQLException,
DataAccessException;
}
and accordingly in JdbcTemplate
public Object execute(final ConnectionCallback action)
{
...
}
That would allow me to print/analyze/verify database metadata without
caring for opening and closing the connection. And I could use my handmade
rowset stuff. Of course, having explicit rowset support would be great!
Regards,
Jonas
Thomas Risberg <tho...@tr...>
Gesendet von: spr...@li...
08.07.2004 17:37
Bitte antworten an springframework-developer
An: spr...@li...
Kopie:
Thema: Re: [Springframework-developer] Rowsets and JdbcDaoSupport
Jonas,
There is currently no support for RowSets. We have some code in the
sandbox that allows you to retrieve a cached rowset, but nothing for
updating. We might add this at some point since it would be fairly
simple to add - probably a new method update(RowSet rset) on
JdbcTemplate. This might go in the 1.2 release since 1.1 is pretty much
set with the 1.1 RC1 due out this weekend. What is the demand for this
support?
Thomas
Jon...@o2... wrote:
>Dear spring developers,
>
>as my question was unanswered at the forum, I'm re-posting it here. Still
>at the beginning of spring usage, thus very excited about its
capabilities
>and the code quality I saw so far :-)
>
>How to flush rowsets to the database without manually doing the
connection
>closing, transaction stuff etc., but using these nice callbacks instead?
>
>neither getJdbcTemplate().execute(..) nor getJdbcTemplate().update(..)
>will work, as they assume me to create a java.sql.Statement resp. write
>handcoded SQL update string...?
>
>The same applies to pure metdata handling, when I just want to read infos
>from Connection without having statements and the like.
>
>To make it clear, this is how my code looks like, which I want to
re-write
>using callbacks:
>
><code>
>
>public final class RowsetDAO
> extends JdbcDaoSupport
>{
>
>...
>
>/**
> * Saves the given disconnected rowset to the database.
> *
> * @param rowSet rowset to save
> * @throws DataAccessException runtime exception on database error
> * @throws NullPointerException if given rowset is null
> */
>public synchronized void saveMutableRowSet(CachedRowSet rowSet)
> throws
> NullPointerException,
> DataAccessException
>{
> Connection conn;
>
> if (rowSet==null)
> {
> throw new NullPointerException("Given mutable rowset to save must not
>be null!");
> }
>
> conn = getConnection();
>
> try
> {
> LOG.debug("Saving rowset into table : " + rowSet.getTableName() );
> long startTime = System.currentTimeMillis();
>
> rowSet.setUrl( conn.getMetaData().getURL() );
> rowSet.setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);
> rowSet.acceptChanges(conn);
> conn.commit();
>
> long endTime = System.currentTimeMillis();
> LOG.debug("Executed SQL in : " + (endTime - startTime) + " ms");
> }
> catch (SQLException e)
> {
> LOG.error(e);
> try
> {
> conn.rollback();
> }
> catch (SQLException e1)
> {
> LOG.error("Could not rollback changes", e1);
> }
> throw getJdbcTemplate().getExceptionTranslator().translate(
> e.toString(),
> "saving mutable rowset",
> e
> );
> }
> finally
> {
> try
> {
> conn.close();
> }
> catch (SQLException e1)
> {
> LOG.error("Could not close connection", e1);
> }
> }
>}
>
>...
></code>
>
>Jonas
>
>
>
>-------------------------------------------------------
>This SF.Net email sponsored by Black Hat Briefings & Training.
>Attend Black Hat Briefings & Training, Las Vegas July 24-29 -
>digital self defense, top technical experts, no vendor pitches,
>unmatched networking opportunities. Visit www.blackhat.com
>_______________________________________________
>Springframework-developer mailing list
>Spr...@li...
>https://lists.sourceforge.net/lists/listinfo/springframework-developer
>
>
>
>
>
-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 -
digital self defense, top technical experts, no vendor pitches,
unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
Springframework-developer mailing list
Spr...@li...
https://lists.sourceforge.net/lists/listinfo/springframework-developer
Jonas,
There is currently no support for RowSets. We have some code in the
sandbox that allows you to retrieve a cached rowset, but nothing for
updating. We might add this at some point since it would be fairly
simple to add - probably a new method update(RowSet rset) on
JdbcTemplate. This might go in the 1.2 release since 1.1 is pretty much
set with the 1.1 RC1 due out this weekend. What is the demand for this
support?
Thomas
|