Package | Description |
---|---|
org.ujorm.tools.sql |
Class and Description |
---|
SqlBuilder
PrepareStatement builder support
How to use a SELECT
SqlBuilder sql = new SqlBuilder() .select("t.id", "t.name") .from("testTable t") .where() .andCondition("t.name", "=", "Test") .andCondition("t.created", ">=", someDate); for (ResultSet rs : sql.executeSelect(dbConnection)) { int id = rs.getInt(1); String name = rs.getString(2); } How to use a INSERTSqlBuilder sql = new SqlBuilder() .insert("testTable") .write("(") .columnInsert("id", 10) .columnInsert("name", "Test") .columnInsert("date", someDate) .super.write(")"); sql.executeUpdate(dbConnection); How to use a UPDATESqlBuilder sql = new SqlBuilder() .update("testTable") .columnUpdate("name", "Test") .columnUpdate("date", SOME_DATE) .where() .andCondition("id", "IN", 10, 20, 30) .andCondition("created BETWEEN ? |
Copyright 2019-2022, Pavel Ponec