Mike Alford

Greenhorn
+ Follow
since Mar 02, 2004
Merit badge: grant badges
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Mike Alford

just had a thought .... am doing this in notepad and the classpath might be wrong hence the errors....am gonna download JDeveloper and see if it compiles through that....
20 years ago
no u didnt miss out a bracket....the last line is a comment....however i tried putting in the [code] tag and had more errors
20 years ago
The class that i want to create new instance of is just has getter setter methods in it such as getName() etc.... if thats any help
20 years ago
Its in the same package bank.......
20 years ago
Andres.. thanks for that but it will only be happy with import bank.*; however still doesn't solve problem and I get the same errors...
20 years ago
Andres... Thanks... That clears the 1st error but the other error is still the same... Any other ideas... I was wondering if there is a jar file I'm missing or something?
20 years ago
yeah that could be done.....ermm...... code is ArrayList deitelList = new ArrayList[1..recordset] i think...tho not sure....dont no wot stacktrace is...
20 years ago
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();
20 years ago
Doing database connection fine using bean to get data for a jsp page.
Got a resultset while loop as follows.. but JAVAC won't compile.. objects to NEW instance of class...Don't understand why?
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;
}
20 years ago