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

📄 bankaccount.java

📁 J2EE关于JSP,SERVERLET的多个实用例子
💻 JAVA
字号:
import java.io.*;
import java.sql.*;

public class BankAccount 
{
	private String sAccountID=" ";
	private String sPin=" ";
	private boolean AccountValidate;		
	Connection connect = null;
	Statement state = null;
	ResultSet result = null;

	
        public void setsAccountID(String sAccountID)
		{
   			System.out.println("Inside setter method"+sAccountID);
			this.sAccountID=sAccountID;
		}
   
	public void setsPin(String sPin)
		{
			this.sPin=sPin;
		}

	public String getsAccountID()
		{
   		return this.sAccountID;
		}

	public String getsPin()
		{
          		return sPin;
		}


	public BankAccount() throws ClassNotFoundException
		{
			Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
		}
	


		
		public boolean AccountValidate()
		{
				boolean  validate=false;
				String sPinNo="";
			try{

				sAccountID=getsAccountID();
				sPin=getsPin();		
				System.out.println("Inside VALIDATE method"+sAccountID);
				connect=DriverManager.getConnection("jdbc:odbc:MyDataSource","faculty","");
				String strQuery = "Select cPin_no from Login where cAccount_id='"+sAccountID+"'" ;
				System.out.println("Query: "+strQuery);
				state = connect.createStatement();
				ResultSet result = state.executeQuery(strQuery);
				while(result.next())
				{
					
					sPinNo = result.getString(1);
					System.out.println("Inside Result method"+sPinNo+sPin);
				
				}
				sPinNo=sPinNo.trim();
				sPin=sPin.trim();
				if(sPinNo.equals(sPin))
					{
						validate = true;
					}
				
			}
			catch(Exception e)
			{
				System.out.println("SQL Exception is caught.");	
			}

			return validate;
		}
}


⌨️ 快捷键说明

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