1、spring得到文件
File configFile = new ClassPathResource("paymentConfig.xml").getFile();
注释:得到的是文件(包含路径)
2、spring 纯jdbc插入数据后获取插入数据的id的方法
//参数 final Map<Integer, Object> insertParams = new HashMap<Integer, Object>(); insertParams.put(1, domain.getName()); insertParams.put(2, domain.getType()); insertParams.put(3, domain.getIsDisplay()); insertParams.put(4, domain.getSortId()); insertParams.put(5, domain.getPid()); insertParams.put(6, domain.getNote()); insertParams.put(7, domain.getStoresId()); //org.springframework.jdbc.support.KeyHolder 用来在插入数据后获取插入数据的id KeyHolder keyHolder = new GeneratedKeyHolder(); jdbcTemplate.update(new PreparedStatementCreator() { @Override public PreparedStatement createPreparedStatement(Connection conn) throws SQLException { String insertSql = "INSERT INTO t_hierarchy (name,type,isDisplay,sortId,pid,note,storesId) VALUES (?, ?, ?, ?, ?, ?, ?)"; PreparedStatement ps = conn.prepareStatement(insertSql, Statement.RETURN_GENERATED_KEYS); //设置参数 Set<Entry<Integer,Object>> entrySet = insertParams.entrySet(); for (Entry<Integer, Object> entry : entrySet) { ps.setObject(entry.getKey(), entry.getValue()); } return ps; } }, keyHolder); //keyHolder.getKey().intValue() 得到插入数据时生成的id(id设置为自动增长) domain.setId(keyHolder.getKey().intValue());
3、spring 管理jdbc后的常用方法
1、查询并迭代
public List findZBB() { this.jdbcTemplate = Factory.getJdbcTemplate(); //得到连接 List zbList = new ArrayList(); //返回页面的list String sql = "select * from onduty where o_date > (sysdate - 1) and o_date < (sysdate + 1) order by DECODE(o_name1,'值班所领导',1,'值班科长',2,'值班民警',3)"; List findList = jdbcTemplate.queryForList(sql); Iterator tt = findList.iterator(); while (tt.hasNext()) { JobBean zbb = new JobBean(); Map jdMap = (Map) tt.next(); zbb.setJobid(jdMap.get("o_id") == null ? "" : jdMap.get("o_id").toString()); // 值班排班id zbb.setJpost(jdMap.get("o_name1") == null ? "" : jdMap.get("o_name1").toString()); // 职位 zbb.setName(jdMap.get("o_name2") == null ? "" : jdMap.get("o_name2").toString()); // 添加值班姓名 zbb.setMobile(jdMap.get("o_name3") == null ? "" : jdMap.get("o_name3").toString()); // 添加值班人固定电话 zbb.setPhone(jdMap.get("o_name4") == null ? "" : jdMap.get("o_name4").toString()); // 添加值班人手机 zbList.add(zbb); } return zbList; }
2、查询唯一返回的值
public String backLsh(){ String sql = "select case" + " when to_number(substr(t.slid, 13, 8)) <" + " to_number(to_char(sysdate, 'yyyymmdd')) then" + " 'HLW-RK-CSDJ-' || to_char(sysdate, 'yyyymmdd') || '0001'" + " when to_number(substr(t.slid, 13, 8)) =" + " to_number(to_char(sysdate, 'yyyymmdd')) then" + " substr(t.slid," + " 1," + " length(t.slid) -" + " length(to_number(substr(t.slid, 21, 4)) + 1)) ||" + " to_char(to_number(substr(t.slid, 21, 4)) + 1)" + " end" + " from (select slbh slid" + " from slbh_list where ywbh = 'HLW-RK-CSDJ') t"; return this.getSession().createSQLQuery(sql).uniqueResult().toString(); }
3、执行更新
public boolean saveRkslbhzdz(String slbh){ String sql = "update slbh_list set slbh='" + slbh + "'where ywbh = 'HLW-RK-CSDJ'"; this.getSession().createSQLQuery(sql).executeUpdate(); return true; }
相关推荐
spring-context-1.2.8.jar, spring-context-1.2.9.jar, spring-context-2.0-m2.jar, spring-context-2.0.1.jar, spring-context-2.0.2.jar, spring-context-2.0.4.jar, spring-context-2.0.6.jar, spring-context-...
spring-aop-1.1.1.jar spring-aop-1.2.6.jar spring-aop-1.2.9.jar spring-aop-2.0.2.jar spring-aop-2.0.6.jar spring-aop-2.0.7.jar spring-aop-2.0.8.jar spring-aop-2.0.jar spring-aop-2.5.1.jar spring-aop-...
开发工具 spring-web-4.3.6.RELEASE开发工具 spring-web-4.3.6.RELEASE开发工具 spring-web-4.3.6.RELEASE开发工具 spring-web-4.3.6.RELEASE开发工具 spring-web-4.3.6.RELEASE开发工具 spring-web-4.3.6.RELEASE...
开发工具 框架JAR spring-framework-4.3.6.RELEASE-dist开发工具 框架JAR spring-framework-4.3.6.RELEASE-dist开发工具 框架JAR spring-framework-4.3.6.RELEASE-dist开发工具 框架JAR spring-framework-4.3.6....
spring-core-4.1.6.RELEASE.jar spring-core-4.3.10.RELEASE.jar spring-core-4.3.12.RELEASE.jar spring-core-4.3.13.RELEASE.jar spring-core-4.3.14.RELEASE.jar spring-core-4.3.16.RELEASE.jar spring-core-4.3...
赠送jar包:springfox-spring-web-2.9.2.jar; 赠送原API文档:springfox-spring-web-2.9.2-javadoc.jar; 赠送源代码:springfox-spring-web-2.9.2-sources.jar; 赠送Maven依赖信息文件:springfox-spring-web-...
spring-ai-core 0.8.1,解决大家使用2023.0.1.0 版本 Spring Cloud Alibaba 依赖,代码依赖下载报错问题, <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-alibaba-dependencies <version>...
在这个问题中,我们遇到了两个关键的jar包:`spring-cglib-repack-3.2.0.jar`和`spring-objenesis-repack-2.1.jar`。这两个jar包对于理解Spring框架的工作原理以及它们在实际应用中的作用至关重要。 首先,`spring-...
开发工具 spring-core-4.3.6.RELEASE开发工具 spring-core-4.3.6.RELEASE开发工具 spring-core-4.3.6.RELEASE开发工具 spring-core-4.3.6.RELEASE开发工具 spring-core-4.3.6.RELEASE开发工具 spring-core-4.3.6....
赠送jar包:spring-plugin-core-2.0.0.RELEASE.jar; 赠送原API文档:spring-plugin-core-2.0.0.RELEASE-javadoc.jar; 赠送源代码:spring-plugin-core-2.0.0.RELEASE-sources.jar; 赠送Maven依赖信息文件:spring...
赠送jar包:spring-jdbc-5.3.15.jar; 赠送原API文档:spring-jdbc-5.3.15-javadoc.jar; 赠送源代码:spring-jdbc-5.3.15-sources.jar; 赠送Maven依赖信息文件:spring-jdbc-5.3.15.pom; 包含翻译后的API文档:...
赠送jar包:spring-data-commons-2.0.6.RELEASE.jar; 赠送原API文档:spring-data-commons-2.0.6.RELEASE-javadoc.jar; 赠送源代码:spring-data-commons-2.0.6.RELEASE-sources.jar; 赠送Maven依赖信息文件:...
赠送jar包:spring-security-crypto-5.5.2.jar; 赠送原API文档:spring-security-crypto-5.5.2-javadoc.jar; 赠送源代码:spring-security-crypto-5.5.2-sources.jar; 赠送Maven依赖信息文件:spring-security-...
赠送jar包:spring-security-core-5.3.9.RELEASE.jar; 赠送原API文档:spring-security-core-5.3.9.RELEASE-javadoc.jar; 赠送源代码:spring-security-core-5.3.9.RELEASE-sources.jar; 赠送Maven依赖信息文件:...
赠送jar包:spring-security-crypto-5.6.1.jar; 赠送原API文档:spring-security-crypto-5.6.1-javadoc.jar; 赠送源代码:spring-security-crypto-5.6.1-sources.jar; 赠送Maven依赖信息文件:spring-security-...
赠送jar包:seata-spring-boot-starter-1.3.0.jar; 赠送原API文档:seata-spring-boot-starter-1.3.0-javadoc.jar; 赠送源代码:seata-spring-boot-starter-1.3.0-sources.jar; 赠送Maven依赖信息文件:seata-...
赠送jar包:spring-session-data-redis-2.0.4.RELEASE.jar; 赠送原API文档:spring-session-data-redis-2.0.4.RELEASE-javadoc.jar; 赠送源代码:spring-session-data-redis-2.0.4.RELEASE-sources.jar; 赠送...
赠送jar包:spring-context-support-1.0.10.jar; 赠送原API文档:spring-context-support-1.0.10-javadoc.jar; 赠送源代码:spring-context-support-1.0.10-sources.jar; 赠送Maven依赖信息文件:spring-context-...
赠送jar包:springfox-spring-webflux-3.0.0.jar; 赠送原API文档:springfox-spring-webflux-3.0.0-javadoc.jar; 赠送源代码:springfox-spring-webflux-3.0.0-sources.jar; 赠送Maven依赖信息文件:springfox-...
赠送jar包:spring-plugin-core-1.2.0.RELEASE.jar; 赠送原API文档:spring-plugin-core-1.2.0.RELEASE-javadoc.jar; 赠送源代码:spring-plugin-core-1.2.0.RELEASE-sources.jar; 包含翻译后的API文档:...