Typical coding

November 8th, 2002 by Hen

Ah, a typical evening of coding. I started by looking to fill in some parts for the new DbUtils project I’m trying to get going at Jakarta Commons. It’s an itch I have to scratch at the moment but does mean less time for IO and getting the next release of Lang moving [we had a big bug with setMaximum returning the minimum :)].

So after committing a minimal first DbUtils from my own JdbcW’s two most commonly used methods, I then looked into writing your own jdbc driver [btw, jdbc is trademarked, so no Jakarta Commons JDBC project :( ]. This of course led me to a classic “i should do this” subject of “why don’t I generate it from java.sql.Driver”. Thankfully this time I had my correct-lazy hat on and I did it. Kind of.

Java is all well and good, but perl was my first love. And I got to spend the evening playing with perl, writing regexps [my real love, perl was just an excuse to get at regexp] and crying out in glee [much to my wife’s amusement] when I come up with such wonders as:

s/ ([^( ]*)(([^)]*))[]/[] ()/;

So now I can type: javap java.sql.Driver | wrap.pl | import.pl
[Note: This still has issues. For example, java.util.BitSet shows some bugs]
and get:Obviously not compilable, but a long way there;

import java.sql.Driver;import java.sql.Connection;import java.util.Properties;import java.sql.SQLException;import java.sql.DriverPropertyInfo;

public class DriverWrapper implements Driver {    public Connection connect(String string, Properties properties) throws SQLException {    }

    public boolean acceptsURL(String string) throws SQLException {    }

    public DriverPropertyInfo[] getPropertyInfo(String string, Properties properties) throws SQLException {    }

    public int getMajorVersion() {    }

    public int getMinorVersion() {    }

    public boolean jdbcCompliant() {    }

}

Comments are closed.