The connection code to the database works fine as I have tested that before so I know that that part is working. I changed the way the recordset returns the data in the code fragment which I put in the message.
It seems to be the new instance that doesn;t now compile
javac - verbose deiteldatabean.java
deiteldatabean.java:9:calss DeitelDataBean is public, should be declared in a file named DeitelDataBean.java
public class DeitelDataBean
^
Deiteldatabean.java:68: cannot resolve symbol
symbol: class Deitel
location:class bank.deitelDataBean
Source
package bank;
import java.sql.*;
import java.io.*;
import java.util.*;
import bank.*;
public class DeitelDataBean
{
private PreparedStatement addRecord, getRecords;
private static Connection con = null;
public DeitelDataBean()
{
}
public String ConnectToDB()
{
//connection string variables
String DBDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
String sURL = "jdbc
dbc:HNDDB";
String sUsername = "ALFORD";
String sPassword = "";
try
{
//connect to driver
Class.forName(DBDriver).newInstance();
}
catch( Exception e )
{
return "Failed - test";
//"Failed to Connect to Driver";
}
try
{
// setup connection
con = DriverManager.getConnection ( sURL, sUsername, sPassword);
}
catch (Exception e)
{
return "Failed 2";
// "Failed to Connect";
}
return "Connected okay";
}
public ArrayList getGuestList() throws SQLException
{
ArrayList guestList = new ArrayList();
Statement selectStamt = con.createStatement();
String query = "SELECT LName, LPassword FROM Lecturer";
ResultSet sresult= selectStamt.executeQuery(query);
while ( sresult.next() ) {
Deitel guest = new Deitel();
guest.setName( sresult.getString(1));
guest.setPwd( sresult.getString(2));
guestList.add(guest);
}
return guestList;
}
protected void finalize()
{
try {
getRecords.close();
con.close();
}
catch ( SQLException sqlException ) {
sqlException.printStackTrace();
}
}
}
Deitel guest = new Deitel();