毕业设计计算机网络精品课程网站设计(8)

2018-11-23 21:57

计算机网络精品课程网站设计

public class DBO { private Connection conn; private Statement stmt; private DataSource ds; //

public DBO() { } {

打开数据库

public void open()

try {

//Class.forName(\

//conn=DriverManager.getConnection(\Class.forName(\ conn =

DriverManager.getConnection(\\

//

}

stmt=conn.createStatement();

System.out.println(\打开数据库连接\

}

catch (Exception ex)

{

System.err.println(\打开数据库时出错: \}

关闭数据库,将连接返还给连接池 public void close() {

try { // }

catch (SQLException ex) { System.err.println(\返还连接池出错: \

32

connMgr.freeConnection(\

conn.close();

System.out.println (\释放连接\

计算机网络精品课程网站设计

// // // // // //

} { } { } { } {

}

执行查询

public ResultSet executeQuery(String sql) throws SQLException ResultSet rs = null;

rs = stmt.executeQuery(sql);

System.out.println (\执行查询\return rs;

执行增删改

public int executeUpdate(String sql) throws SQLException

int ret = 0;

ret = stmt.executeUpdate(sql); System.out.println (\执行增删改\return ret;

将SQL语句加入到批处理

public void addBatch(String sql) throws SQLException stmt.addBatch(sql);

执行批处理

public int [] executeBatch() throws SQLException boolean isAuto=conn.getAutoCommit();

conn.setAutoCommit(false);

int [] updateCounts = stmt.executeBatch();

conn.commit();

conn.setAutoCommit(isAuto); //conn.setAutoCommit(true);

33

计算机网络精品课程网站设计

// //

return updateCounts;

}

public boolean getAutoCommit() throws SQLException { return conn.getAutoCommit(); }

public void setAutoCommit(boolean auto) throws SQLException { }

public void commit() throws SQLException { }

conn.commit(); this.close();

conn.setAutoCommit(auto);

public void rollBack() throws SQLException { conn.rollback(); }

this.close();

}

音视频上传: package com.util;

import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.sql.ResultSet; import java.sql.SQLException; import java.util.Vector;

import javax.servlet.ServletConfig; import javax.servlet.ServletContext; import javax.servlet.ServletException;

import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import javax.servlet.jsp.JspWriter; import javax.servlet.jsp.PageContext;

public class SmartUpload {

protected byte m_binArray[];

34

计算机网络精品课程网站设计

protected HttpServletRequest m_request;

protected HttpServletResponse m_response; protected ServletContext m_application; private int m_totalBytes; private int m_currentIndex;

private int m_startData; private int m_endData;

private String m_boundary;

private long m_totalMaxFileSize; private long m_maxFileSize; private Vector m_deniedFilesList; private Vector m_allowedFilesList; private boolean m_denyPhysicalPath;

//private boolean m_forcePhysicalPath; private String m_contentDisposition; public static final int SAVE_AUTO = 0; public static final int SAVE_VIRTUAL = 1; public static final int SAVE_PHYSICAL = 2; private SmartFiles m_files;

private SmartRequest m_formRequest;

public SmartUpload() {

m_totalBytes = 0; m_currentIndex = 0; m_startData = 0;

m_endData = 0;

m_boundary = \ m_totalMaxFileSize = 0L; m_maxFileSize = 0L;

m_deniedFilesList = new Vector(); m_allowedFilesList = new Vector(); m_denyPhysicalPath = false;

//m_forcePhysicalPath = false;

m_contentDisposition = \ m_files = new SmartFiles();

m_formRequest = new SmartRequest(); } /**

* @deprecated Method init is deprecated */

public final void init(ServletConfig servletconfig) throws ServletException

35

计算机网络精品课程网站设计

{

m_application = servletconfig.getServletContext(); }

/**

* @deprecated Method service is deprecated */

public void service(HttpServletRequest httpservletrequest,HttpServletResponse httpservletresponse) throws ServletException,IOException {

m_request = httpservletrequest; m_response = httpservletresponse; }

public final void initialize(ServletConfig servletconfig,HttpServletRequest httpservletrequest,HttpServletResponse httpservletresponse) throws ServletException {

m_application = servletconfig.getServletContext(); m_request = httpservletrequest; m_response = httpservletresponse; }

public final void initialize(PageContext pagecontext) throws ServletException {

m_application = pagecontext.getServletContext();

m_request = (HttpServletRequest)pagecontext.getRequest(); m_response = (HttpServletResponse)pagecontext.getResponse(); }

/**

* @deprecated Method initialize is deprecated */

public final void httpsession,HttpServletRequest

initialize(ServletContext servletcontext,HttpSession

httpservletrequest,HttpServletResponse

httpservletresponse,JspWriter jspwriter) throws ServletException {

m_application = servletcontext; m_request = httpservletrequest; m_response = httpservletresponse; }

public void upload() throws ServletException,IOException,SmartUploadException {

int i = 0;

36


毕业设计计算机网络精品课程网站设计(8).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:2019高考化学一轮复习有机化学说课稿

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: