String url="jdbc:mysql://localhost:3306/XXdb?rewriteBatchedStatements=true"
// statement executeBatch code :
con.setAutoCommit(false);
Statement stmt = conn.createStatement();
stmt.addBatch("INSERT into student values ('张三','123','18'))");
stmt.addBatch("INSERT into student values ('李四','456','21'))");
stmt.addBatch("INSERT into student values ('王五','789','22'))");
int [] updateCounts=stmt.executeBatch();
con.commit();
pstm.clearBatch();
// PreparedStatement executeBatch code :
conn.setAutoCommit(false);
PreparedStatement ps = conn.prepareStatement("INSERT into student values (?,?,?))";
for (n = 0; n < 100; n++) {
ps.setString(name[n]);
ps.setLong(id[n]);
ps.setInt(salary[n]);
ps.addBatch();
}
int [] = ps.executeBatch();
con.commit();
pstm.clearBatch();
3.3 SQL注入(攻击)
在定义SQL的时候把用户输入的内容作为参数跟SQL拼接的话,当用户输入不合理的数据值的时候有可能导致SQL执行异常。例如:正常的登录SQL : select * from student where stu_name = 'seven' and stu_pwd = '123' 其中seven跟123为用户从界面传入的登录账号,如果用户输入字段带'号则会异常。
如果用户输入 1' or 1='1 时候则拼接的SQL为 select * from student where stu_name = '1' or 1='1' and stu_pwd = '123'此时用户只知道用户名不知道密码则也可以登录成功。
再例如如果用户输入 abc' or 1='1' -- (最后要有个空格)则拼接的SQL为 select * from student where stu_name = 'abc' or 1='1' -- ' and stu_pwd = '123'则用户此时不知道用户名跟密码情况都可以登录成功。
driverClassName=com.mysql.jdbc.Driver
url=jdbc:mysql://127.0.0.1:3306/test1? useUnicode=true&characterEncoding=UTF-8
username=root
password=root
Properties p = new Properties();
InputStream is = new FileInputStream(new File("src/datasource.properties"));
p.load(is);
DataSource ds = DruidDataSourceFactory.createDataSource(p);
5.2 使用DataSource对象
QueryRunner qr = new QueryRunner(ds);
String sql = " select * from student " ;
List list = qr.query(sql, new BeanListHandler(Student.class));
QueryRunner qr = new QueryRunner( );
String sql = " select * from student " ;
List list = qr.query(ds.getConnection(),sql, new BeanListHandler(Student.class));
昨晚和朋友聊天,喝了点咖啡,由于我经常喝茶,很长时间没喝咖啡了,所以失眠了,于是起床读JVM规范,读完后在朋友圈发了一条信息:
JVM Run-Time Data Areas:The Java Virtual Machine defines various run-time data areas that are used during execution of a program. So
Spark SQL supports most commonly used features of HiveQL. However, different HiveQL statements are executed in different manners:
1. DDL statements (e.g. CREATE TABLE, DROP TABLE, etc.)
nginx在运行过程中是否稳定,是否有异常退出过?这里总结几项平时会用到的小技巧。
1. 在error.log中查看是否有signal项,如果有,看看signal是多少。
比如,这是一个异常退出的情况:
$grep signal error.log
2012/12/24 16:39:56 [alert] 13661#0: worker process 13666 exited on s
方法一:常用方法 关闭XML验证
工具栏:windows => preferences => xml => xml files => validation => Indicate when no grammar is specified:选择Ignore即可。
方法二:(个人推荐)
添加 内容如下
<?xml version=
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml&quo
最主要的是使用到了一个jquery的插件jquery.media.js,使用这个插件就很容易实现了。
核心代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.