//Title: HSA Parents' Corner //Version: //Copyright: Copyright (c) 1998 //Author: Ozgur Balsoy //Company: //Description: Online Parental Access to the School Database package hsa.db; import hsa.util.*; import java.io.PrintWriter; import java.sql.*; import java.util.*; public class students { private static String masterTable = "emf901"; private static String extendedTable = "ema901"; private static String fldID = "id_number", fldPwd = "emf_note1"; private static String spaces = " "; public static dbHashtable queryStudent(String idnumber) throws Exception { return queryStudents("*", "id_number='"+ idnumber +"'", "id_number", "id_number"); } public static dbHashtable queryStudents(String projection, String condition, String orderBy, String groupBy) throws Exception { if (projection == null) projection = "*"; String queryString = "select "+ projection +" from "+ masterTable; if (condition != null && !condition.equals("")) queryString += " where "+ condition; if (orderBy != null && !orderBy.equals("")) queryString += " order by "+ orderBy; if (groupBy != null && !groupBy.equals("")) queryString += " group by "+ groupBy; Log.log("(students) Query string: "+ queryString ); return new dbHashtable( new statement( queryString )); /* statement stmt = new statement(queryString); ResultSet rs = stmt.getResultSet(); ResultSetMetaData rsmd = rs.getMetaData(); int columns = rsmd.getColumnCount(); //out.println("Number of columns: " + columns); out.println(""); int j=0; while( rs.next() ) { out.println(""); for(int i=1; i <= columns; i++) out.println(""); out.println(""); j++; } stmt.close(); out.println("
"+ j + "" + (String)rs.getString(i) + "
"); */ } public static boolean authorized(String user, String pass) //, PrintWriter out) throws Exception { try { Log.log("Checking authorization for user '"+user+"' with password '"+ pass +"'"); String s = "select "+ fldPwd +" from "+ masterTable +" where "+ fldID +"='"+ user + spaces.substring(0,9-user.length()) +"'"; Log.log("Sql statement: '"+ s +"'"); statement stmt = new statement(s); ResultSet rs = stmt.getResultSet(); if( rs.next() ) { String password = rs.getString(1); Log.log("DB password: '"+ password +"'"); if ( password.trim().equals(pass.trim()) ) return true; } else { Log.log("Password check fails."); } } catch(Exception e) { throw e; } return false; } }