⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 func.java

📁 主要是描述的同学录系统
💻 JAVA
字号:
package com.user;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import com.user.Conn;
import com.user.Vo;

public class Func {
	Conn conn = null;

	Vo vo = null;

	Connection con = null;

	Statement stmt = null;// 一般的操作平台

	PreparedStatement pstmt = null;// 预处理操作平台

	ResultSet rs = null;

	boolean flag = false;

	public Vo getVo() {
		return vo;
	}

	public void setVo(Vo vo) {
		this.vo = vo;
	}
	public String trans(String chi)
	{
		String result = null;
		byte temp[];
		try
		{
			temp = chi.getBytes("iso-8859-1");
			result = new String(temp);
		} catch (java.io.UnsupportedEncodingException e)
		{
			System.out.println(e.toString());
		}
		return result;
	}

	public String trans(Object chi)
	{
		return trans(chi.toString());
	}
	public boolean doregister(Vo vo) {
		String str = "select count(*) from xinxi";
		String sql = "insert into xinxi values(?,?,?,?,?,?,?)";
		int num = 0;
		try {
			conn = new Conn();
			con = conn.getConn();
			stmt = con.createStatement();
			rs = stmt.executeQuery(str);
			if (rs.next()) {
				num = rs.getInt(1);
			}
			rs.close();
			stmt.close();
			String address = vo.getAddress();
			if(address!=""||address!=null)
    		{
    			address=this.trans(address);
    		}
			pstmt = con.prepareStatement(sql);
			pstmt.setInt(1, num + 1);
			pstmt.setString(2, vo.getUsername());
			pstmt.setInt(3, new Integer(vo.getSex()));
			pstmt.setString(4, vo.getPhone());
			pstmt.setString(5, address);
			pstmt.setDate(6, new java.sql.Date(new java.util.Date().getTime()));
			pstmt.setString(7, address);
			pstmt.executeUpdate();
			flag = true;

		} catch (Exception e) {
			System.out.println("注册出现异常");
			e.printStackTrace();
		}
		return flag;
	}

	public boolean doxiugai(String newpassword, String username) {
		String str = "select count(*) from xinxi";
		String sql = "update xinxi set password='" + newpassword
				+ "' where username='" + username + "'";
		System.out.print(sql);
		try {
			conn = new Conn();
			con = conn.getConn();
			stmt = con.createStatement();
			stmt.executeUpdate(sql);
			flag = true;
			stmt.close();
			con.close();
		} catch (Exception e) {
			System.out.println("修改出现异常");
			e.printStackTrace();
		}
		return flag;

	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -