Package com.google.mu.safesql
package com.google.mu.safesql
Injection-safe SQL template (requires mug-safesql artifact)
A SQL template library with:
- Industry-strength library-enforced SQL injection safety - you cannot shoot yourself in the foot.
- Powerful dynamic SQL capability - compose subqueries flexibly (and safe from SQL injection, again).
- Compile-time semantic check - never worry about passing template parameters wrong.
- Real, actual SQL that you can copy/paste - no DSL; no XML; no StringBuilder.
SafeSql sql = SafeSql.of("select id, name, age from Users where id = {id}", userId); for (User user : sql.query(dataSource, User.class)) { // ... }
Package Specification
The code is developed and tested under Java 8.0.-
ClassDescriptionAn injection-safe dynamic SQL, constructed using compile-time enforced templates.SqlFunction<F,
T> For lambdas that can throwSQLException
.Annotation to facilitate mapping from a result set row to a pojo through theSafeSql.query(java.sql.Connection, Class)
method and friends.Functional interface to apply settings onto a JDBCStatement
.A simple unchecked wrapper ofSQLException
.