Hi, right, I have created the following code below, I am trying to convert it into a Bean by creating a manifest file and generating a jar file, however, it just does not seem to work, not allowing me to use it once the jar file is loaded through BeanBuilder, so i fear the error may lie in this code somewhere,
any help would be greatly appreciated,
Thanks for your time.
Code:import java.io.*; import java.util.*; import java.sql.*; public class MatchResults implements Serializable { private int resOppScore=0; private int resClubScore=0; public static void main (String args[]) { MatchResults matchRes = new MatchResults(); } public MatchResults() { System.out.println("tester"); } public void insertNew(String opponents,String homeOrAway,int clubScore, int oppScore) { Connection link = null; Statement statement = null; Scanner input = new Scanner(System.in); boolean matchFound; matchFound=getData(opponents,homeOrAway); if (!matchFound) { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); link = DriverManager.getConnection("jdbc:odbc:ClubData","",""); } catch(ClassNotFoundException e) { System.out.println("* Unable to load driver! *"); System.exit(1); } catch(SQLException e) { System.out.println("* Cannot connect to database! *"); System.exit(1); } try { statement = link.createStatement(); String insert = "INSERT INTO Results VALUES ('"+ opponents + "','" + homeOrAway + "'," + clubScore + "," + oppScore + ")"; int result = statement.executeUpdate(insert); if (result==0) System.out.println("\t\tInsertion Failed!"); else System.out.println("\t\tRecords Inserted"); } catch(SQLException e) { System.out.println("* Cannot execute query! *"); e.printStackTrace(); System.exit(1); } finally { try { link.close(); } catch(SQLException e) { System.out.println("* Unable to disconnect! *"); e.printStackTrace(); } } } else System.out.println("\n\t\t* Match Already Exists - Insertion Cancelled *"); } public boolean getData(String opponents, String homeOrAway) { Connection link = null; Statement statement = null; ResultSet results = null; boolean matchFound = false; try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); link = DriverManager.getConnection("jdbc:odbc:ClubData","",""); } catch(ClassNotFoundException e) { System.out.println("* Unable to load driver! *"); System.exit(1); } catch(SQLException e) { System.out.println("* Cannot connect to database! *"); System.exit(1); } try { statement = link.createStatement(); results = statement.executeQuery( "SELECT * FROM Results " + "WHERE opponents = '"+ opponents +"' " + "AND homeOrAway= '" + homeOrAway + "'"); } catch(SQLException e) { System.out.println("* Cannot execute query! *"); e.printStackTrace(); System.exit(1); } try { while (results.next()) { System.out.println("\n\t\t- Match Information -\n"); int opponentScore = results.getInt(4); int clubScore = results.getInt(3); System.out.print("\t\tScore - "); System.out.println("Us:" + clubScore + " " + results.getString(1) + ":" + opponentScore + "\n"); if(clubScore>opponentScore) System.out.println("\t\tHome Win\n"); else if(clubScore==opponentScore) System.out.println("\t\t- Draw -\n"); else System.out.println("\t\t- Away Win -\n"); matchFound=true; resOppScore = opponentScore; resClubScore = clubScore; } } catch(SQLException e) { System.out.println("* Error retrieving data! *"); e.printStackTrace(); System.exit(1); } finally { try { link.close(); } catch(SQLException e) { System.out.println("* Unable to disconnect! *"); e.printStackTrace(); } } return matchFound; } public int getClubScore(String opponents, String homeOrAway) { getData(opponents,homeOrAway); return resClubScore; } public int getOppScore(String opponents, String homeOrAway) { getData(opponents,homeOrAway); return resOppScore; } public void setNewMatch(String opponents, String homeOrAway, int clubScore, int oppScore) { insertNew(opponents,homeOrAway,clubScore,oppScore); } }


LinkBack URL
About LinkBacks
Reply With Quote