代码拉取完成,页面将自动刷新
同步操作将从 drinkjava2/jSqlBox 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
Java persistence tool Java
jSqlBox is a DAO tool based on Apache-commons-DbUtils core.
Chinese中文 | English User Manual | JavaDoc
<dependency>
<groupId>com.github.drinkjava2</groupId>
<artifactId>jsqlbox</artifactId>
<version>5.0.10.jre8</version> <!--Or newest version-->
</dependency>
pom.xml:
<dependency>
<groupId>com.github.drinkjava2</groupId>
<artifactId>jsqlbox</artifactId>
<version>5.0.5.jre8</version> <!-- Java8 -->
</dependency>
<dependency>
<groupId>com.h2database</groupId> <!--H2 database->
<artifactId>h2</artifactId>
<version>1.3.176</version>
</dependency>
And create below java file in Eclipse or Idea:
import javax.sql.DataSource;
import org.h2.jdbcx.JdbcConnectionPool;
import static com.github.drinkjava2.jsqlbox.DB.*;
import com.github.drinkjava2.jdialects.annotation.jdia.UUID25;
import com.github.drinkjava2.jdialects.annotation.jpa.Id;
import com.github.drinkjava2.jsqlbox.ActiveEntity;
import com.github.drinkjava2.jsqlbox.DB;
import com.github.drinkjava2.jsqlbox.DbContext;
public class HelloWorld implements ActiveEntity<HelloWorld> {
@Id
@UUID25
private String id;
private String name;
public String getId() {return id;}
public void setId(String id) {this.id = id;}
public String getName() {return name;}
public HelloWorld setName(String name) {this.name = name;return this;}
public static void main(String[] args) {
DataSource ds = JdbcConnectionPool
.create("jdbc:h2:mem:demo;MODE=MYSQL;TRACE_LEVEL_SYSTEM_OUT=0", "sa", "");
DbContext ctx = new DbContext(ds);
ctx.setAllowShowSQL(true);
DbContext.setGlobalDbContext(ctx);
ctx.quiteExecute(ctx.toDropAndCreateDDL(HelloWorld.class));
ctx.tx(() -> {
HelloWorld h = new HelloWorld().setName("Foo").insert().putField("name", "Hello jSqlBox").update();
System.out.println(DB.qryString("select name from HelloWorld where name like", que("H%"),
" or name=", que("1"), " or name =", que("2")));
h.delete();
});
ctx.executeDDL(ctx.toDropDDL(HelloWorld.class));
}
}
Below is the log output:
SQL: drop table HelloWorld if exists
PAR: []
SQL: create table HelloWorld ( id varchar(250),name varchar(250), primary key (id))
PAR: []
SQL: insert into HelloWorld (name, id) values(?,?)
PAR: [Foo, emeai4bfdsciufuuteb9a7nmo]
SQL: update HelloWorld set name=? where id=?
PAR: [Hello jSqlBox, emeai4bfdsciufuuteb9a7nmo]
SQL: select name from HelloWorld where name like? or name=? or name =?
PAR: [H%, 1, 2]
SQL: delete from HelloWorld where id=?
PAR: [emeai4bfdsciufuuteb9a7nmo]
SQL: drop table HelloWorld if exists
PAR: []
More documents please see wiki.
Welcome post issue or submit PR, to help improve jSqlBox
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。