<dependency> <groupId>com.microsoft</groupId> <artifactId>sqljdbc4</artifactId> <version>3.0</version> </dependency>
// 配置 druid 数据库连接池插件 DruidPlugin sqlserverDruidPlugin = new DruidPlugin(PropKit.get("jdbcUrl2"), PropKit.get("user2"), PropKit.get("password2")); sqlserverDruidPlugin.setDriverClass(PropKit.get("jdbcDriver2")); me.add(sqlserverDruidPlugin); // 配置ActiveRecord插件 ActiveRecordPlugin arpSqlserver = new ActiveRecordPlugin("sqlserver",sqlserverDruidPlugin); // 所有映射在 MappingKit 中自动化搞定 arpSqlserver.setShowSql(true); me.add(arpSqlserver); arpSqlserver.setDialect(new SqlServerDialect());
Page<Record> list = Db.use("sqlserver").paginate(1,10,"select *","from utooRoomclear ORDER BY dateTime DESC");
以下是showSql出来的,第二条运行不过去。
Sql: select count(*) from utooRoomclear
Sql: SELECT * FROM ( SELECT row_number() over (order by tempcolumn) temprownumber, * FROM ( SELECT TOP 10 tempcolumn=0, * from utooRoomclear ORDER BY dateTime DESC)vip)mvp where temprownumber>0
https://mvnrepository.com/artifact/com.microsoft.sqlserver/mssql-jdbc
最新的驱动在这里:
https://mvnrepository.com/artifact/com.microsoft.sqlserver/mssql-jdbc
而不是这里(这里的过时了):
https://mvnrepository.com/artifact/com.microsoft.sqlserver/sqljdbc4