www.pudn.com > lucene+mysql+eclipe.rar   To Read all the content


[file head]:
package com.lucene;
import java.util.ArrayList;
import java.util.Date;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
/*
* @CopyRigth(R) 城市通
* @author 申华锋 E-mail:leonshine@qq.com
* @version 创建时间:Mar 9, 2008 12:12:45 AM
* @description
*/
public class Product {
private long productId;

private String title;

private String description;

private String address;

private String userName;

private long userId;

private String tag;

private Date date;

public String getAddress() {
return address;
}

public void setAddress(String address) {
this.address = address;
}

public String getDescription() {
return description;
}

public void setDescription(String description) {
this.description = description;
}

public long getProductId() {
return productId;
}

public void setProductId(long productId) {
this.productId = productId;
... ...

[file tail]:
... ...
tic Product queryProductbyId(long id)throws Exception{
Product photo = new Product();
PreparedStatement pstm = null;
ResultSet rs = null;
String sql = "select product_id,title,address,descr,user_id,user_name,upload_time,tag_name from product where product_id ='"+id+"'";
try {
pstm = DBConnection.getConnection().prepareStatement(sql);
rs = pstm.executeQuery();
while (rs.next()) {

photo.setProductId(rs.getLong("product_id"));
photo.setTitle(rs.getString("title"));
photo.setAddress(rs.getString("address"));
photo.setDescription(rs.getString("descr"));
photo.setUserId(rs.getLong("user_id"));
photo.setUserName(rs.getString("user_name"));
photo.setDate(rs.getTimestamp("upload_time"));
photo.setTag(rs.getString("tag_name"));
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
if (rs != null) {
rs.close();
}
if (pstm != null) {
pstm.close();
}
}
return photo;
}
}