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

📄 getcustomermain.java

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

/**
 * @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 GetCustomerMain {
	private static final String DBCLASS = "COM.ibm.db2.jdbc.app.DB2Driver";
	private static final String URL = "jdbc:db2:EJBBANK";

	public GetCustomerMain() {	
		try {
			Class.forName(DBCLASS);
		} catch (Throwable ex) {}
	}

	private Connection getConnection() throws SQLException {
		Connection con = DriverManager.getConnection(URL);
		return con;
	}
	
	public static void main(String[] args) throws SQLException {
		String customerID = "104";
		if (args != null && args.length > 0) customerID = args[0];
		
		GetCustomerMain custTest = new GetCustomerMain();
		
		// connect to database
		Connection con = custTest.getConnection();

		// prepare statement that calls stored procedure
		CallableStatement cs = con.prepareCall("{call ITSO.GetCustomer(?)} ");
		cs.setString(1, customerID);

		// execute
		ResultSet rs = cs.executeQuery();

		while (rs.next()) {
			// get the data from the row
			System.out.println("CUSTOMER ID: " + rs.getString("customerid"));
			System.out.println("TITLE:       " + rs.getString("title"));
			System.out.println("FIRST NAME:  " + rs.getString("firstname"));
			System.out.println("LAST NAME:   " + rs.getString("lastname"));
			System.out.println("USERNAME:    " + rs.getString("userid"));
			System.out.println("PASSWORD:    " +rs.getString("password"));
		}
	}	
}

⌨️ 快捷键说明

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