一、
public class Test {
Integer first=new Integer(10);
Integer second=new Integer(20);
public Integer sum(Integer x,Integer y){
Integer result=x+y;
return result;
}
/**
* @param args
*/
public static void main(String[] args) {
Test test=new Test();
Integer sum=test.sum(test.first,test.second);
System.out.println(sum);
}
}
二、
public class Test{
String word1=\"I \";
String word2=\"Love \";
String word3=\"You \";
public String show(String x,String y,String z){
String say=x+y+z;
return say;
}
public static void main(String[] args){
Test test=new Test();
String sum=test.show(test.word1, test.word2, test.word3);
System.out.println(sum);
}
}
第二天
insert
guo.student(name,age,sex,fav)values('guotingwen','22','male','book');
select* from guo.student;
insert into guo.student(name,age,sex,fav)values('xujun','20','girl','study');
into
insert into guo.student(name,age,sex,fav)values('huanhai','22','boy','play');
select* from guo.student where name='xujun';
select* from guo.student where name like '% xu%';
insert into guo.student(name,age,sex,fav)values('yaoshun','26','boy','game');
insert into guo.student(name,age,sex,fav)values('sunchao','23','boy','footbal');
update guo.student set name=\"xuxiaojun\" where id=2;
insert into guo.student(name,age,sex,fav)values('wangye','25','haha','news');
update guo.student set flag=\"meizuohaode\" where id=2;
delete from guo.student where flag=\"meizuohaode\";
insert
guo.student(name,age,sex,fav)values('guotingwen','22','male','book');
into
select* from guo.student;
insert into guo.student(name,age,sex,fav)values('xujun','20','girl','study');
insert into guo.student(name,age,sex,fav)values('huanhai','22','boy','play');
select* from guo.student where name='xujun';
select* from guo.student where name like '% xu%';
insert into guo.student(name,age,sex,fav)values('yaoshun','26','boy','game');
insert into guo.student(name,age,sex,fav)values('sunchao','23','boy','footbal');
update guo.student set name=\"xuxiaojun\" where id=2;
insert into guo.student(name,age,sex,fav)values('wangye','25','haha','news');
update guo.student set flag=\"meizuohaode\" where id=2;
delete from guo.student where flag=\"meizuohaode\";
insert into
guo.student(name,age,sex,fav,flag)values('chenyue','20','nan','movie','zuohaode');
select * from guo.student where id<5;
select name,count(id) as shu from guo.student group by name;
select name,count(id) as shu from guo.student where name like '%x%';
第三天
package com.yourcompany.struts;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class BaseConnection {
public Connection getConnection() throws InstantiationException,
IllegalAccessException, ClassNotFoundException, SQLException
{
String url=\"jdbc:mysql://localhost:3306/wen\";
String username=\"root\";
String password=\"root\";
Class.forName(\"com.mysql.jdbc.Driver\").newInstance();
Connection conn=null;
conn=(Connection) DriverManager.getConnection(url,username,password);
return conn;
}
}
package com.yourcompany.struts;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
public class LoginAction extends DispatchAction {
public ActionForward login(ActionMapping mapping, ActionForm form,
HttpServletRequest InstantiationException, SQLException {
request, HttpServletResponse response) throws
IllegalAccessException, ClassNotFoundException,
String name=(String)request.getParameter(\"name\");
String password=(String)request.getParameter(\"password\");
BaseConnection con=new BaseConnection();
Connection conn=con.getConnection();
String sql=\"select*from wen.lab where name='\"+name+\"' and
password='\"+password+\"'\" ;
Statement stmt=conn.createStatement();
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()){
return mapping.findForward(\"succ\");
}
return mapping.findForward(\"fail\");
}
}
因篇幅问题不能全部显示,请点此查看更多更全内容