some conversion of old database code into JDBC version