• 手机版

    扫码体验手机版

  • 微信公众号

    扫码关注公众号

国内首家协议开发

软芯音视解码保护平台

在线
客服

发布
需求

在线
聊天

天盟
APP

天盟APP下载

关注
微信

微信扫一扫访问
顶部

postgresql一览展示了数据库里的数据,怎么删除呢,代码在下面

Title.java

package cn.ac.radi.example;
import java.sql.Date;
public class Title {
     private int id;   
     private Date createTime;
     private int rainfall;   
    public int getId() {
       return id;
    }
    public void setId(int id) {
        this.id = id;
    }
    public int getRainfall() {
       return rainfall;
   }
    public void setRainfall(int rainfall) {
        this.rainfall = rainfall;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public Title(int id,Date createTime,int rainfall) {
        super();
        this.id = id;
        this.createTime = createTime;
        this.rainfall = rainfall;
      
    }
}
------------------------------------------------------------------------------------------------------------------------------------
TitleDAO.java
package cn.ac.radi.example;
import cn.ac.radi.example.Title;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;
public class TitleDAO {
    public List readFirstTitle(){
        //调用list接口下的ArrayList类,再此需要使用泛型,因为当数据存入集合中,类型默认转换为object类型所以加入泛型,就不用后续进行强制转换了
   
    List list =new ArrayList();
        Connection con=null;
        PreparedStatement psmt=null;
        ResultSet rs=null;
        
        try {
            Class.forName("org.postgresql.Driver");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }     
        try {
            con=DriverManager.getConnection("jdbc:postgresql://localhost:5432/myDB","postgres","postgres");
            String sql="select * from rainfall2013";
            psmt=con.prepareStatement(sql);
            rs=psmt.executeQuery();
            while(rs.next())
            {
                int id=rs.getInt("id");
                Date createTime=rs.getDate("date");
                int rainfall=rs.getInt("降雨量");   
                //通过创建Title实体类的对象,把行数据依次存入,之后再把行数据逐次的方法list集合中
                Title tl=new Title(id, createTime,rainfall);
                list.add(tl);
            }
            
        } catch (SQLException e) {
            e.printStackTrace();
        }finally
        {
            try {
                if(rs!=null)
                {
                    rs.close();
                }
                if(psmt!=null)
                {
                    psmt.close();
                }
                if(con!=null)
                {
                    con.close();
                }
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
        return list;
    }
   
}
------------------------------------------------------------------------------------------------------------------------------
titleList.jsp











Test-newsTitle


  
idDate降雨量(mm)操作
删除



------------------------------------------------------------------------------------------------------------------------------------

免责声明:本内容仅代表回答会员见解不代表天盟观点,请谨慎对待。

版权声明:作者保留权利,不代表天盟立场。

使用道具 举报

发新帖

发布任务需求已有1031168位用户正在使用天盟网服务

发布分类: *
任务预算: *
需求内容: *
手机号码: *
任务商家报价为
  • 预算价 :
  • 成交价 :
  • 完工期 :
  • 质保期 :

* 最终任务项目以服务商报价、双方协商为准!