Java中date与Jsp中date交互

文章作者 100test 发表时间 2011:03:17 21:07:10
来源 100Test.Com百考试题网


  Judge.java:

  package com.goodhope.regist.

  import java.sql.Connection.

  import java.sql.DriverManager.

  import java.sql.ResultSet.

  import java.sql.SQLException.

  import java.sql.Statement.

  #ff0000>import java.util.Date.

  public class Judge {

  Statement stmt.

  ResultSet rs.

  public void init() {

  try {

  Class.forName("org.postgresql.Driver").

  String url = "jdbc:postgresql://localhost:5432/postgres".

  Connection con = DriverManager.getConnection(url, "postgres",

  "pair36").

  stmt = con.createStatement().

  } catch (Exception e) {

  e.printStackTrace().

  }

  }

  public boolean IfExit(String username) {

  Boolean a = false.

  init().

  String sql = "0select name from cas where name=" username "".

  try {

  rs = stmt.executeQuery(sql).

  } catch (SQLException e) {

  e.printStackTrace().

  }

  try {

  a = rs.next().

  } catch (SQLException e) {

  e.printStackTrace().

  }

  return a.

  }

  public void InsetIntoTable(String name, String pwd, Date birthday) {

  init().

  String sql = "insert into cas (name,password,birthday) values ("

   name "," pwd ",to_date(" birthday

   ",yyyy-mm-dd))".

  try {

  stmt.execute(sql).

  } catch (SQLException e) {

  e.printStackTrace().

  }

  }

  }

  Regist.java

  package com.goodhope.regist.

  #ff0000>import java.sql.Date.

  import com.opensymphony.xwork2.ActionSupport.

  public class Regist extends ActionSupport {

  private static final long serialVersionUID = -5254042367980236169L.

  private String username.

  private String password.

  private Date birthday.

  public String getUsername() {

  return username.

  }

  public void setUsername(String username) {

  this.username = username.

  }

  public String getPassword() {

  return password.

  }

  public void setPassword(String password) {

  this.password = password.

  }

  public Date getBirthday() {

  return birthday.

  }

  public void setBirthday(Date birthday) {

  this.birthday = birthday.

  }


相关文章


JavaMap遍历速度最优解
servlet中session的使用
ArrayList遍历的4种方法
JAVA实现AES加密
Java中date与Jsp中date交互
2011年计算机二级考试JAVA备考冲刺攻略
您的JAVA代码安全吗?
实战角度比较EJB2和EJB3的架构异同
JBossDeveloperStudio简介
澳大利亚华人论坛
考好网
日本华人论坛
华人移民留学论坛
英国华人论坛