1 package com.lykion; 2 3 import java.sql.Connection; 4 import java.sql.PreparedStatement; 5 import java.sql.ResultSet; 6 import java.sql.SQLException ...
分类:
数据库 时间:
2020-12-05 10:46:05
阅读次数:
6
a、数据库资源是非常昂贵的,用完了应该尽快关闭它。Connection, Statement, ResultSet等JDBC对象都有close方法,调用它就好了。 b、养成在代码中显式关闭掉ResultSet,Statement,Connection的习惯,如果你用的是连接池的话,连接用完后会放回池 ...
分类:
数据库 时间:
2020-11-26 14:29:23
阅读次数:
10
#1. 先导包 pom.xml下 <dependencies> <!-- https://mvnrepository.com/artifact/log4j/log4j --> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artif ...
分类:
其他好文 时间:
2020-11-19 12:48:09
阅读次数:
13
1.加载驱动 Class.forName(driver_class); 2.创建数据库连接 DriverManager.getConnection(url,user,password); 3.创建PreparedStatement PreparedStatement ps=connection.pr ...
分类:
数据库 时间:
2020-11-16 13:44:12
阅读次数:
24
多个字段数据可用Map if(dept!=null && !"".equals(dept)){ List list = this.getDeptNameByDeptCode(dept); if(list!=null && !list.isEmpty()){ Map m=(Map)list.get(0 ...
分类:
数据库 时间:
2020-08-12 15:53:52
阅读次数:
70
import struct,sys from socket import * from contextlib import closing import hashlib,os from functools import partial from prettytable import PrettyTa ...
分类:
数据库 时间:
2020-07-28 00:00:14
阅读次数:
92
一、PreparedStatement接口 1.java.sql.PraparedStatement接口继承并扩展了Statement接口,用于执行动态的SQL语句,即包含参数的SQL语句。 PraparedStatement ps = connection.preparedStatement("s ...
分类:
编程语言 时间:
2020-07-27 09:18:47
阅读次数:
68
读入文件的字符串,以1-n个空格作为分隔拆分读入,全部转换为大写/小写字母(做到不区分大小写)后进行统计。若库里有该词则计数加一,否则添加字段。 package servlet; import java.io.BufferedReader; import java.io.FileNotFoundEx ...
分类:
其他好文 时间:
2020-07-18 22:27:12
阅读次数:
84
public <E> List<E> selectList(Mapper mapper, Connection conn){ PreparedStatement pstm = null; ResultSet rs = null; try{ String queryString = mapper.ge ...
分类:
数据库 时间:
2020-07-17 11:34:51
阅读次数:
97
前言 本文将结合实例demo,阐述30条有关于优化SQL的建议,多数是实际开发中总结出来的,希望对大家有帮助。 1、查询SQL尽量不要使用select *,而是select具体字段。 反例子: select * from employee; 正例子: select id,name from empl ...
分类:
数据库 时间:
2020-07-12 00:47:36
阅读次数:
154