Summer eighth week blog

This week, mainly in the primary stage of writing web applications. This time I practice mastery of web development knowledge summer learning. The following is a summary of the experiment after the completion of the project.

Aini Games performance management system Experience

1, the transaction sql statement to query

(1)  Note to open a transaction, the statement is executed, the transaction shall be added after the semicolon " ; "

Eg:  start TRANSACTION;

insert into competitors values('20173533','高波','','101');

insert into competitors values('20173233','李旭春','','101');

COMMIT;

(2)  to list a collection of objects every time you add a new one should be created, can not create an add objects on the outside, and then modify the value stored into it, you think it is saved into multiple objects, when in fact only keep up that last updated object. Examples :

    for(int i=0;i<name.length-1;i++) {

    competitor competitor = new competitor();

    competitor.set(name[i], sex[i], com[i], num[i]);

    List.add(competitor);

    }

 

2, do not want the browser to automatically prompt for input text that can be added in the text of the property set AutoComplete = "OFF"

 

3, timer display jQuery statement

$(function(){

Time = serInterval(“show()”,2500);

 

});

function show(){

Operation code

clearInterval(Time);

}

 

4, multi-table joins operation

Left join SQL statement: select * from student left join score on student.Num = score.Stu_id;

Right join SQL statement: select * from student right join score on student.Num = score.Stu_id;

Fully connected SQL statement: select * from student full join score on student.Num = score.Stu_id;

连接 SQL语句:select * from student inner join score on student.Num=score.Stu_id;

Connection with statements like

select * from student,score where student.ID=course.ID;

5, for reading from the database field with different field items encapsulates example:

// Get the current page of data

public List<competitor> getDataList(int begin, int countPage) throws SQLException {

QueryRunner runner = new QueryRunner(DataSourceUtils.getDataSource());

String sql = "select com.id as number,aca.name as comtestant,com.name,sex   from competitionacademy aca ,competitors com where aca.id = com.academy_id limit ?,?";

return runner.query(sql, new BeanListHandler<competitor>(competitor.class),begin,countPage);

}

 

6, boostrap-Validate reload check

$("#defaultForm").data('bootstrapValidator').destroy();

$('#defaultForm').data('bootstrapValidator', null);

fromValidator();

change check

 

 

7, and external key, foreign key solution added group unrepeatable

Add Foreign Key statement: the ALTER the Table table from the Add ( constraint A foreign key name) [although this is not necessary because it is best to add a foreign key to delete when you need to use]

foreign key ( from Table Field Name ) references a main table (the primary table's primary key)

eg:   alter table product add constraint category_id_fk foreign key (category_id) references category(cid)

 

 

 

Remove the foreign key statement: [] the foreign key name (necessary, add a foreign key to be declared when general to "_fk" at the end, or can not be deleted);

alter table Table drop foreign key foreign key name

eg:    alter table product drop foreign key category_id_fk;

 

Non-key setting content can not be repeated

ALTER TABLE dbname.table ADD UNIQUE (fieldname);

Database named dbname, table name table, field name fieldname.

 

alter table sportcompetitors add unique(sport_id,competitor_id)

 

8, cookie create, add and session Destruction

获取Cookie:Cookie[] cookies = request.getCookies();

Cookie.getName();

Cookie.getValue();

Create a Cookie: new cookie ( "", data);

Set Cookie effective time : cookie.setMaxAge (60 * 60 * 24 * 30) set valid for one month

Set Cookie valid path : cookie.setPath (request.getContextPath ());

添加Cookie:response.addCookie(cookie);

The destruction of the cookie : cookie.setValue ( "");

cookie.setPath(request.getContextPath());

cookie.setMaxAge(-1000);

response.addCookie(cookie);

 

获取session:HttpSession session = request.getSesssion();

销毁session:session.invalidate();

 

9, acquire the full path of a request (since the filter is configured to change the plug can only try to achieve this automatically log)

String retUrl = request.getHeader("Referer");  

Guess you like

Origin www.cnblogs.com/goubb/p/11489325.html