J
Jody
Hey, i'm having issues with the following code:
package dbase;
import java.util.Vector;
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
public class Register extends DataBase
{
public Register()
{
}
public Vector getBookLoansColumnHeadings()
{
Vector headings = new Vector();
this.setConnection();
try
{
Statement st = conn.createStatement();
String sql = "Select * from library where BorrowerID < 1";
// get the meta data from the ResultSet
ResultSet rs = st.executeQuery(sql);
ResultSetMetaData rsmd = rs.getMetaData();
for (int x= 1 ; x <= rsmd.getColumnCount(); x++)
{
headings.addElement(rsmd.getColumnName(x));
}
rs.close();
st.close();
this.closeConnection();
}
catch (Exception ex)
{
System.out.println(ex.getMessage());
}
return headings;
}
public Vector getBookLoansData()
{
Vector BookLoansData = new Vector();
this.setConnection();
try
{
Statement st = conn.createStatement();
String sql = "Select * from library"; // get all the records
ResultSet rs = st.executeQuery(sql);
ResultSetMetaData rsmd = rs.getMetaData();
while (rs.next()) // loop through all the records
{
Vector myrow = new Vector(); // create a vector for each row
// Note: indexed from 1 to N not 0 to N-1
for (int x= 1 ; x <= rsmd.getColumnCount(); x++)
{
myrow.addElement(rs.getString(x));
}
// add vector to overall vector
BookLoansData.addElement(myrow);
}
rs.close();
st.close();
this.closeConnection();
}
catch(Exception ex)
{
System.out.println(ex.getMessage());
}
return BookLoansData;
}
}
The errors i get are as follows:
cannot resolve symbol
symbol : class DataBase
location: class dbase.Register
public class Register extends DataBase
^
cannot resolve symbol
symbol : method setConnection ()
location: class dbase.Register
this.setConnection();
^
cannot resolve symbol
symbol : variable conn
location: class dbase.Register
Statement st = conn.createStatement();
^
cannot resolve symbol
symbol : method closeConnection ()
location: class dbase.Register
this.closeConnection();
^
cannot resolve symbol
symbol : method setConnection ()
location: class dbase.Register
this.setConnection();
^
cannot resolve symbol
symbol : variable conn
location: class dbase.Register
Statement st = conn.createStatement();
^
cannot resolve symbol
symbol : method closeConnection ()
location: class dbase.Register
this.closeConnection();
^
Has this got something to do with packages, or is it something really
obvious?
package dbase;
import java.util.Vector;
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
public class Register extends DataBase
{
public Register()
{
}
public Vector getBookLoansColumnHeadings()
{
Vector headings = new Vector();
this.setConnection();
try
{
Statement st = conn.createStatement();
String sql = "Select * from library where BorrowerID < 1";
// get the meta data from the ResultSet
ResultSet rs = st.executeQuery(sql);
ResultSetMetaData rsmd = rs.getMetaData();
for (int x= 1 ; x <= rsmd.getColumnCount(); x++)
{
headings.addElement(rsmd.getColumnName(x));
}
rs.close();
st.close();
this.closeConnection();
}
catch (Exception ex)
{
System.out.println(ex.getMessage());
}
return headings;
}
public Vector getBookLoansData()
{
Vector BookLoansData = new Vector();
this.setConnection();
try
{
Statement st = conn.createStatement();
String sql = "Select * from library"; // get all the records
ResultSet rs = st.executeQuery(sql);
ResultSetMetaData rsmd = rs.getMetaData();
while (rs.next()) // loop through all the records
{
Vector myrow = new Vector(); // create a vector for each row
// Note: indexed from 1 to N not 0 to N-1
for (int x= 1 ; x <= rsmd.getColumnCount(); x++)
{
myrow.addElement(rs.getString(x));
}
// add vector to overall vector
BookLoansData.addElement(myrow);
}
rs.close();
st.close();
this.closeConnection();
}
catch(Exception ex)
{
System.out.println(ex.getMessage());
}
return BookLoansData;
}
}
The errors i get are as follows:
cannot resolve symbol
symbol : class DataBase
location: class dbase.Register
public class Register extends DataBase
^
cannot resolve symbol
symbol : method setConnection ()
location: class dbase.Register
this.setConnection();
^
cannot resolve symbol
symbol : variable conn
location: class dbase.Register
Statement st = conn.createStatement();
^
cannot resolve symbol
symbol : method closeConnection ()
location: class dbase.Register
this.closeConnection();
^
cannot resolve symbol
symbol : method setConnection ()
location: class dbase.Register
this.setConnection();
^
cannot resolve symbol
symbol : variable conn
location: class dbase.Register
Statement st = conn.createStatement();
^
cannot resolve symbol
symbol : method closeConnection ()
location: class dbase.Register
this.closeConnection();
^
Has this got something to do with packages, or is it something really
obvious?