Groovy data utils. The main issue I needed to address was the reliance on System classloader in @Grab to handle JDBC drivers. This is very inconvenient when using an IDE such as Gade and Ride as it requires you to copy jars to the lib folder and restart the IDE in order for the System classpath to be updated.
However, with some Reflection magic it is possible to do without this. This is what se.alipsa.groovy.datautil.SqlUtil does.
Here is an example:
@Grab('se.alipsa.groovy:data-utils:1.0.6')
@Grab('org.postgresql:postgresql:42.4.0')
import se.alipsa.groovy.datautil.SqlUtil
def idList = new ArrayList()
SqlUtil.withInstance("jdbc:postgresql://localhost:5432/mydb", "dbUser", "dbPasswd", "org.postgresql.Driver") { sql ->
sql.query('SELECT id FROM project') { rs ->
while (rs.next()) {
idList.add(rs.getLong(1))
}
}
}
See test.alipsa.groovy.datautil.SqlUtilTest for more examples!
data-utils is available from maven central
Gradle:
implementation "se.alipsa.groovy:data-utils:1.0.6"
Maven:
<dependency>
<groupId>se.alipsa.groovy</groupId>
<artifactId>data-utils</artifactId>
<version>1.0.6</version>
</dependency>
- Change github repo references from perNyfelt to Alipsa
- Add support for ConnectionInfo as param to Sql factory methods
- upgrade test dependencies and gradle version
- fix bug in determining the DataBaseProvider from a URL
- Add support for handling java.sql.Types and a jdbcType in SqlTypeMapper that returns the Types int corresponding to the Java class
- move Tablesaw stuff to matrix-tablesaw
- add support for getting a db type for a java class
- remove dependency on log4j to slim down the library further and be logging agnostic
- upgrade to jdk17
- add conversions to/from Tablesaw and Matrix
- add wrappers to Gtable for all Table methods returning a Table
- move most of the Normalization code to the Matrix-stats package and adjust accordingly
- upgrade dependencies for groovy, tablesaw, SODS, dom4j
- upgrade transient dependencies with cve issues
- upgrade to groovy 4.0.6
- change groovy dependencies to compileOnly so that consumers of this library can use whatever compatible version of Groovy that they want without conflicts.
- Add TableUtil with support for frequency tables
- Upgrade to Groovy 4.0.4
- Build script fixes
- initial release