bankaccount.java

来自「USB设计的一些源码!适合与USB开发的同学!还是蛮不错的!我用过一些!」· Java 代码 · 共 85 行

JAVA
85
字号

package test;
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","sa","");
				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 + =
减小字号Ctrl + -
显示快捷键?