• 大小: 666KB
    文件类型: .gz
    金币: 1
    下载: 0 次
    发布日期: 2021-05-07
  • 语言: Java
  • 标签: 日记本  Java  

资源简介

这个是一个日记本程序,主要目的是用来记录一些技术方面的信息。包括网络上的,还有其他方面获得的信息。这个都存储在数据库中。本程序由Java编写。IDE为Netbeans6.7.1 OS为Ubuntu9.10

资源截图

代码片段和文件信息

/*
 * To change this template choose Tools | Templates
 * and open the template in the editor.
 */

package jemydiary;

import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.util.Calendar;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author jinxinxin
 */
public class ContactSystem {

    public String[] initInfoFromSystem(){
        Connection con=DBAccessFactory.createDBAccess().getConnection();
        String queryStr=“SELECT category FROM category“;
        Vector result=new Vector();
        try {
            Statement stat = con.createStatement();
            ResultSet rs=stat.executeQuery(queryStr);
            while(rs.next()){
                result.add(rs.getString(“category“));
            }
            String resultList[]=new String[result.size()];
            result.toArray(resultList);
            return resultList;
        } catch (SQLException ex) {
            Logger.getLogger(ContactSystem.class.getName()).log(Level.SEVERE null ex);
        }finally{
            try {
                con.close();
            } catch (SQLException ex) {
                Logger.getLogger(ContactSystem.class.getName()).log(Level.SEVERE null ex);
            }
        }
        return null;
    }

    public boolean updateInfoOfSystem(String titleint catIDString content){
        String date=null;
        Calendar c=Calendar.getInstance();
        int year=c.get(Calendar.YEAR);
        int month=c.get(Calendar.MONTH);
        int day=c.get(Calendar.DAY_OF_MONTH);
        int hour=c.get(Calendar.HOUR_OF_DAY);
        int minute=c.get(Calendar.MINUTE);
        int second=c.get(Calendar.SECOND);
        date=year+“-“+month+“-“+day+“ “+hour+“:“+minute+“:“+second;
        Connection con=DBAccessFactory.createDBAccess().getConnection();
        String updateStr=“INSERT INTO notes(titlecontentdatecategory_id) values (‘“+title+“‘‘“+content+“‘‘“+date+“‘“+catID+“)“;
        System.out.println(updateStr);
        try {
            Statement stat = con.createStatement();
            stat.executeUpdate(updateStr);
            return true;
        } catch (SQLException ex) {
            Logger.getLogger(ContactSystem.class.getName()).log(Level.SEVERE null ex);
        }finally{
            try {
                con.close();
            } catch (SQLException ex) {
                Logger.getLogger(ContactSystem.class.getName()).log(Level.SEVERE null ex);
            }
        }
        return false;
    }
    
}

评论

共有 条评论