Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
Product.java
Package: lucene+mysql+eclipe.rar [view]
Upload User: zhihansy
Upload Date: 2014-12-04
Package Size: 7241k
Code Size: 4k
Category:
Search Engine
Development Platform:
Java
- 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;
- }
- public String getTag() {
- return tag;
- }
- public void setTag(String tag) {
- this.tag = tag;
- }
- public String getTitle() {
- return title;
- }
- public void setTitle(String title) {
- this.title = title;
- }
- public long getUserId() {
- return userId;
- }
- public void setUserId(long userId) {
- this.userId = userId;
- }
- public String getUserName() {
- return userName;
- }
- public void setUserName(String userName) {
- this.userName = userName;
- }
- public String ToString(){
- return "这是个照片的实体";
- }
- public Date getDate() {
- return date;
- }
- public void setDate(Date date) {
- this.date = date;
- }
- //查询数据库,返回Product对象数组
- public static Product[] loadProducts() throws Exception {
- ArrayList<Product> list = new ArrayList<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";
- try {
- pstm = DBConnection.getConnection().prepareStatement(sql);
- rs = pstm.executeQuery();
- while (rs.next()) {
- Product photo = new Product();
- photo.setProductId(rs.getLong(1));
- photo.setTitle(rs.getString(2));
- photo.setAddress(rs.getString(3));
- photo.setDescription(rs.getString(4));
- photo.setUserId(rs.getLong(5));
- photo.setUserName(rs.getString(6));
- photo.setDate(rs.getTimestamp(7));
- photo.setTag(rs.getString(8));
- list.add(photo);
- }
- } catch (SQLException e) {
- e.printStackTrace();
- } finally {
- if (rs != null) {
- rs.close();
- }
- if (pstm != null) {
- pstm.close();
- }
- }
- return (Product[]) list.toArray(new Product[list.size()]);
- }
- //根据传入id获取一个Product
- public static 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;
- }
- }