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

📄 customerlisting.java

📁 噶额外噶外骨骼感广泛高热感 就 啊啊
💻 JAVA
字号:
package itso.gui;
import java.sql.*;
import java.util.Vector;

/**
 * @author UELI
 *
 * To change this generated comment edit the template variable "typecomment":
 * Window>Preferences>Java>Templates.
 * To enable and disable the creation of type comments go to
 * Window>Preferences>Java>Code Generation.
 */
public class CustomerListing {
	static String dbtab = "CUSTOMER";
	
	public Vector getAllByLastName() {
		Vector result = new Vector();
		//System.out.println("Customer Listing for " + dbtab);

		Connection con = null;
		con = connect();

		Statement stmt = null;
		ResultSet rs = null;
		String select = "SELECT * FROM ITSO." + dbtab;
		try {
			stmt = con.createStatement();
			rs = stmt.executeQuery(select);
			while (rs.next()) {
				//String firstName = rs.getString("firstName");
				//String lastName = rs.getString("lastName");
				//String userID = rs.getString("userID");
				//System.out.println(firstName + " " + lastName + " " + userID);
				result.addElement(rs.getString("lastName"));
			}
			//System.out.println("End of Listing");

		} catch (Exception e) {
			System.err.println("Exception: " + e.getMessage());
		} finally {
			try {
				if (rs   != null) rs.close();
				if (stmt != null) stmt.close();
				if (con  != null) con.close();
			} catch (SQLException e) {}
		}
		return result;
	}

	public String getFirstNameByKey(String key) {
		String result = new String();

		Connection con = null;
		con = connect();

		Statement stmt = null;
		ResultSet rs = null;
		String select =
			"SELECT * FROM ITSO." + dbtab + " WHERE lastName = '" + key + "'";
		try {
			stmt = con.createStatement();
			rs = stmt.executeQuery(select);
			while (rs.next()) {
				result = rs.getString("firstName");
			}
		} catch (Exception e) {
			System.err.println("Exception: " + e.getMessage());
		} finally {
			try {
				if (rs   != null) rs.close();
				if (stmt != null) stmt.close();
				if (con  != null) con.close();
			} catch (SQLException e) {}
		}
		return result;
	}
	
	protected static Connection connect() {
		Connection con = null;
		try {
			Class.forName("COM.ibm.db2.jdbc.app.DB2Driver");
			con = DriverManager.getConnection("jdbc:db2:EJBBANK");
		} catch (Exception e) {
			System.err.println("Exception: " + e.getMessage());
		}
		return con;
	}
}

⌨️ 快捷键说明

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