cap0's Profile User Rating: -----

Reputation: 5 Worker
Group:
Members
Active Posts:
32 (0.03 per day)
Joined:
11-December 11
Profile Views:
489
Last Active:
User is offline Jan 10 2013 08:50 AM
Currently:
Offline

Previous Fields

Country:
ZA
OS Preference:
Who Cares
Favorite Browser:
Chrome
Favorite Processor:
Intel
Favorite Gaming Platform:
Playstation
Your Car:
Who Cares
Dream Kudos:
0

Latest Visitors

Icon   cap0 has not set their status

Posts I've Made

  1. In Topic: Using a Database to hold values (inserting, manipulating etc)

    Posted 22 Aug 2012

    thanks for all ur help then.. anyone else able to explain my problem ? :(
  2. In Topic: Using a Database to hold values (inserting, manipulating etc)

    Posted 22 Aug 2012

    doesn't help me bro!! :( maybe in the long run but not now
    i have a deadline for the 2nd september! :\

    and i have a lot of documentation to do.. so if i could just get the programming done :(
  3. In Topic: Using a Database to hold values (inserting, manipulating etc)

    Posted 22 Aug 2012

    this is the DBConnect class - its where the database is connected too and where resultset is created

    import java.sql.*;
    
    public class DBConnect {
    	private Connection con;
    	private Statement stm;
    
    	public void addPatient(String sqlStatement) {
    		try {
    			stm.executeUpdate(sqlStatement);
    			System.out.println("Patient added");
    		} catch (SQLException e) {
    			e.printStackTrace();
    		}
    	}
    
    	/**
    	 * ***** provided ******* constructor which sets up the connection to the
    	 * database
    	 */
    	public DBConnect() {
    		if (setup()) {
    			System.out.println("dbbase connection complete");
    		} else {
    			System.out.println("dbbase connection could not be made");
    		}
    	}
    
    	/**
    	 * ***** provided *******load driver and then make the connection to the
    	 * data source
    	 */
    	public boolean setup() {
    		if (!loadODBC()) { // load driver
    			System.out.println("cannot load the drivers");
    			return false;
    		} else {
    			try {
    				// con = DriverManager.getConnection("jdbc:odbc:data", "" , ""
    				// );
    				con = DriverManager.getConnection(
    						"jdbc:mysql://localhost:3306/pat", "root", "");
    				stm = con.createStatement();
    				return true;
    			} catch (SQLException e) {
    				e.printStackTrace();
    				return false;
    			}
    		}
    	}
    
    	/**
    	 * ***** provided ******* try load the drivers
    	 */
    	public static boolean loadODBC() {
    		try {
    			Class.forName("com.mysql.jdbc.Driver").newInstance();
    			System.out.println("Connected");
    			return true;
    		} catch (Exception e) {
    			e.printStackTrace();
    			return false;
    		}
    	}
    
    	public int NoOfRecords() {
    		String sql = "SELECT COUNT(name) AS num FROM patient";
    
    		try {
    			ResultSet rs = stm.executeQuery(sql);
    			rs.next();
    			int count = rs.getInt("num");
    
    			return count;
    
    		} catch (SQLException e) {
    			System.out.println("Cannot execute statement " + sql);
    			return -1;
    
    		}
    	}
    
    	public ResultSet retrieveAll() {
    		String sql = "SELECT * FROM patient";
    		try {
    			ResultSet rs = stm.executeQuery(sql);
    			return rs;
    
    		} catch (SQLException e) {
    			System.out.println("Cannot execute statement " + sql);
    			return null;
    		}
    	}
    
    }
    
  4. In Topic: Using a Database to hold values (inserting, manipulating etc)

    Posted 22 Aug 2012

    yes i'm connecting to openoffice base (which conencts to mysql) to use the DB as a sort of way to "store" the accounts as a save file

    I'm having trouble figuring out which resultset is not closed or open ?
  5. In Topic: Using a Database to hold values (inserting, manipulating etc)

    Posted 22 Aug 2012

    i've posted the exact error many times..

    java.sql.SQLException: Operation not allowed after ResultSet closed
    	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1074)
    	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:988)
    	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:974)
    	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:919)
    	at com.mysql.jdbc.ResultSetImpl.checkClosed(ResultSetImpl.java:803)
    	at com.mysql.jdbc.ResultSetImpl.next(ResultSetImpl.java:6985)
    	at PatientList.<init>(PatientList.java:21)
    	at Main.<init>(Main.java:35)
    	at Main$1.run(Main.java:66)
    	at java.awt.event.InvocationEvent.dispatch(Unknown Source)
    	at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    	at java.awt.EventQueue.access$000(Unknown Source)
    	at java.awt.EventQueue$3.run(Unknown Source)
    	at java.awt.EventQueue$3.run(Unknown Source)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    	at java.awt.EventQueue.dispatchEvent(Unknown Source)
    	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    	at java.awt.EventDispatchThread.run(Unknown Source)
    
    

My Information

Member Title:
New D.I.C Head
Age:
19 years old
Birthday:
August 5, 1994
Gender:
Location:
South Africa
Full Name:
John Joseph
Years Programming:
1
Programming Languages:
Java

Contact Information

E-mail:
Click here to e-mail me
MSN:
MSN  john.joseph@msn.com

Comments

cap0 has no profile comments yet. Why not say hello?