The Source for Java Technology Collaboration
User: Password:



Start New Message Post a Reply

Subject:  How about JDBC Enhancements
Date:  2007-08-15 09:02:06
From:  bgyetko


So far many of the applications we develop require an observable data. Wouldn't it be nice if JDBC 5.0 would offer an observable interface on the connection? This would eliminate much of the code we develop. Here is what the code would look like (maybe on java.sql.Connection):

public interface Connection
{
enum DbEvent{
DbEventInsert,
DbEventUpdate,
DbEventDelete);

// Listen to a particular insert, update and or delete on a particular query
public void addDbListener(
String query,
EventEnum[] eventEnum,
DbListener DbListener );

// Remove the same listener as above to stop receiving updates
public void removeDbListener(
DbListener dbListener );

}

public interface DbListener
{

public void recordsInserted(
ResultSet resultSet );

public void recordsUpdated(
ResultSet oldResultSet,
ResultSet newResultSet );

public void recordsDeleted(
ResultSet recordsDeleted );

}

I think this would be a major improvement to make the JDBC connection a 2 way pipe between the client and database. Not all JDBC drivers would be force to implement it, since you could have JDBC 4.0 (like what is available now) and JDBC 4.0observable which adds the observable capability.



 Feed java.net RSS Feeds