datatable java实现_如何用Java实现.NET中DataTable功能

因为我本来就是搞net的,突然来了两个项目就是要用java以及oracle,便从各种方向上寻求net的影子,便有了今天这些工具类。不知道好不好,bug测试了一下了,性能上也只有经过项目来验证吧。其中一部分涉及到双数据库操作,所以也提了一种解决方案,写的不好,大家看看吧!

我们先看效果,再说说怎么弄!

我们来试试如何用,我也写了一个测试数据。

f603aec66abc446c0fddd78a553cdff0.png

fff7768fbc7afa127bcbe353af302229.png

然后我们在Junit中测试:

@Test

publicvoidjoinTable() {

JingZongDB jzdb=newJingZongDB();

DataTable dt1=jzdb.getDataTable("select * from newsType");

DataTable dt2=jzdb.getDataTable("select * from news");

DataTable dt=DataTable.joinTable(dt1, dt2, "id","typeid");

wl("新闻类型表:"+dt1.getRow().size());

DataTable.outTable(dt1);

wl("新闻表:"+dt2.getRow().size());

DataTable.outTable(dt2);

wl("合并后:"+dt.getRow().size());

DataTable.outTable(dt);

}

privatevoidwl(String s) {

System.out.println(s);

}

最后结果为:

新闻类型表:4

id:1typeName:学生工作

id:2typeName:通知公告

id:3typeName:招生简章

id:4typeName:教务信息

新闻表:16

id:1typeid:1newsName:学生工作1

id:2typeid:1newsName:学生工作2

id:3typeid:1newsName:学生工作3

id:4typeid:1newsName:学生工作4

id:5typeid:2newsName:通知公告1

id:6typeid:2newsName:通知公告2

id:7typeid:2newsName:通知公告3

id:8typeid:2newsName:通知公告4

id:9typeid:3newsName:招生简章1

id:10typeid:3newsName:招生简章2

id:11typeid:3newsName:招生简章3

id:12typeid:3newsName:招生简章4

id:13typeid:4newsName:教务信息1

id:14typeid:4newsName:教务信息2

id:15typeid:4newsName:教务信息3

id:16typeid:4newsName:教务信息4

合并后:16

id:1typeName:学生工作 id:1typeid:1newsName:学生工作1

id:1typeName:学生工作 id:2typeid:1newsName:学生工作2

id:1typeName:学生工作 id:3typeid:1newsName:学生工作3

id:1typeName:学生工作 id:4typeid:1newsName:学生工作4

id:2typeName:通知公告 id:5typeid:2newsName:通知公告1

id:2typeName:通知公告 id:6typeid:2newsName:通知公告2

id:2typeName:通知公告 id:7typeid:2newsName:通知公告3

id:2typeName:通知公告 id:8typeid:2newsName:通知公告4

id:3typeName:招生简章 id:9typeid:3newsName:招生简章1

id:3typeName:招生简章 id:10typeid:3newsName:招生简章2

id:3typeName:招生简章 id:11typeid:3newsName:招生简章3

id:3typeName:招生简章 id:12typeid:3newsName:招生简章4

id:4typeName:教务信息 id:13typeid:4newsName:教务信息1

id:4typeName:教务信息 id:14typeid:4newsName:教务信息2

id:4typeName:教务信息 id:15typeid:4newsName:教务信息3

id:4typeName:教务信息 id:16typeid:4newsName:教务信息4

现在说如何实现

1)实现.net数据库参数化。

packagecdu.yas.xykps.util;

importjava.sql.Blob;

importjava.sql.Date;

/**

* @功能描述 sql参数,sql执行时传递的参数用此类封装

* @可能的错误

* @作者 王磊

* @修改说明

* @修改人

*/

publicclassSqlParameter {

publicSqlParameter(String type, String value) {

this.type = type;

th

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值