• 大小: 672KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-10
  • 语言: Java
  • 标签:

资源简介

本资源为苏年乐老师编写的Java+SQLServer项目开发实践的代码

资源截图

代码片段和文件信息

package flight.assist;

import java.sql.*;
/**
 * 数据库访问辅助类,使用了Singleton软件设计模式
 */
public class DatabaseManager {
  private static DatabaseManager instance;
  private Connection con;
  private ResultSet rs;
  private Statement stmt;

  public static DatabaseManager getInstance() {
    if (instance == null) {
      instance = new DatabaseManager();
    }
    return instance;
  }

  private DatabaseManager() {
    try {
      String url = “jdbc:odbc:flight“;
      Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver“);
      con = DriverManager.getConnection(url);
      stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE
                                 ResultSet.CONCUR_UPDATABLE);
    }
    catch (SQLException sqle) {
      System.out.println(sqle.toString());
    }
    catch (ClassNotFoundException cnfex) {
      cnfex.printStackTrace();
    }
  }

  public ResultSet getResult(String strSQL) {
    try {
      rs = stmt.executeQuery(strSQL);
      return rs;
    }
    catch (SQLException sqle) {
      System.out.println(sqle.toString());
      return null;
    }

  }

  public int updateSql(String strSQL) {
    try {
      int i = stmt.executeUpdate(strSQL);
      con.commit();
      return i;
    }
    catch (SQLException sqle) {
      System.out.println(sqle.toString());
      return -1;
    }
  }

  public void closeConnection() {
    try {
      con.close();
      this.instance=null;
    }
    catch (SQLException sqle) {
      System.out.println(sqle.toString());
    }
  }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       6136  2006-03-08 17:26  FlightManagement\FlightManagement.jpx.local

     文件       2542  2006-02-27 19:28  FlightManagement\FlightManagement.jpx

     文件       3803  2006-03-07 18:46  FlightManagement\src\flight\assist\SeatInfo.java

     文件       1588  2006-03-07 18:06  FlightManagement\src\flight\assist\DatabaseManager.java

     目录          0  2006-02-27 19:10  FlightManagement\src\flight\assist

     文件       1183  2006-03-07 18:46  FlightManagement\src\flight\Main\Main.java

     文件       3774  2006-03-07 18:46  FlightManagement\src\flight\Main\Interface.java

     目录          0  2006-02-27 19:12  FlightManagement\src\flight\Main

     文件       8591  2006-03-07 18:46  FlightManagement\src\flight\manage\DeletePanel.java

     文件       7205  2006-03-07 18:46  FlightManagement\src\flight\manage\InsertPanel.java

     文件       7569  2006-03-07 17:55  FlightManagement\src\flight\manage\UpdatePanel.java

     文件        737  2006-03-07 18:46  FlightManagement\src\flight\manage\Management.java

     文件       3231  2006-03-07 17:54  FlightManagement\src\flight\manage\FlightList.java

     目录          0  2006-02-27 19:12  FlightManagement\src\flight\manage

     文件       7040  2006-03-07 18:46  FlightManagement\src\flight\query\CommonQuery.java

     文件      11469  2006-03-07 18:46  FlightManagement\src\flight\query\ComprehenQuery.java

     文件        504  2006-03-07 18:46  FlightManagement\src\flight\query\Query.java

     文件       2322  2006-03-07 18:19  FlightManagement\src\flight\query\ResultTable.java

     目录          0  2006-02-27 19:12  FlightManagement\src\flight\query

     文件      22267  2006-03-07 18:41  FlightManagement\src\flight\ticketbook\TicketBook.java

     文件      15795  2006-03-07 18:26  FlightManagement\src\flight\ticketbook\Clientframe.java

     文件        846  2006-03-07 17:57  FlightManagement\src\flight\ticketbook\BookInfo.java

     目录          0  2006-02-27 19:12  FlightManagement\src\flight\ticketbook

     文件      17663  2006-03-07 18:45  FlightManagement\src\flight\ticketrefund\TicketRefund.java

     目录          0  2006-02-27 19:12  FlightManagement\src\flight\ticketrefund

     目录          0  2006-02-27 19:09  FlightManagement\src\flight

     目录          0  2006-02-27 19:09  FlightManagement\src

     文件       5595  2006-03-07 18:46  FlightManagement\classes\package cache\flight.Main.dep2

     文件      16574  2006-03-08 16:19  FlightManagement\classes\package cache\flight.manage.dep2

     文件       5231  2006-02-27 20:55  FlightManagement\classes\package cache\flight.tuipiao.dep2

............此处省略259个文件信息

评论

共有 条评论

相关资源