aspose file tools*
The moose likes JDBC and the fly likes 2 errors i cannot find! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "2 errors i cannot find!" Watch "2 errors i cannot find!" New topic
Author

2 errors i cannot find!

Luke Smtih
Greenhorn

Joined: Jun 01, 2004
Posts: 11
i need some help finding these 2 errors
error one - customer.java:71: cannot resolve symbol
symbol : method displayResultSet (java.sql.ResultSet)
location: class customer
displayResultSet(resultSet);
^

error two - customer.java:93: cannot resolve symbol
symbol : class vector
location: class customer
Vector columnHeads = new vector();
^


THIS IS THE CODE I HAVE MARKED THE LINES WHERE ERRORS ARE

import java.sql.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;

public class customer extends JFrame {
private Connection connection;
private JTable table;

public customer()
{
String url = "jdbc dbc:Info";

try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

connection = DriverManager.getConnection(url);
}
catch (ClassNotFoundException cnfex){
System.err.println(
"Failed to load JDBC/ODBC driver.");
cnfex.printStackTrace();
System.exit(1);
}
catch(SQLException sqlex){
System.err.println("Unable to connect");
sqlex.printStackTrace();
}
getTable();
setSize(450,200);
show();
}
private void getTable()
{
Statement statement;
ResultSet resultSet;

try{
String query = "Select * from custDetails";
//FIRST ERROR HERE SOMEWHERE
statement = connection.createStatement();
resultSet = statement.executeQuery(query);
displayResultSet(resultSet);
statement.close();

}
catch (SQLException sqlex){
sqlex.printStackTrace();
}
}
private void displayresultSet(ResultSet rs)
throws SQLException
{
boolean moreRecords = rs.next();

if(!moreRecords){
JOptionPane.showMessageDialog(this,
"ResultSet contained no records");
setTitle("No records to diaplay");
return;
}

setTitle("Customer Details Table from Customer");
//SECCOND ERROR HERE SOMEWHERE

Vector columnHeads = new vector();
Vector rows = new Vector();

try{
ResultSetMetaData rsmd = rs.getMetaData();

for(int i=1; i<=rsmd.getColumnCount();++i)
columnHeads.addElement(rsmd.getColumnName(1));

do{
rows.addElement(getNextRow(rs, rsmd));

}while (rs.next());

table = new JTable(rows, columnHeads);
JScrollPane scroller = new JScrollPane(table);
getContentPane().add(
scroller, BorderLayout.CENTER);
validate();

}
catch (SQLException sqlex){
sqlex.printStackTrace();

}
}

private Vector getNextRow(ResultSet rs,
ResultSetMetaData rsmd)throws SQLException

{
Vector currentRow = new Vector();

for (int i=1; i<rsmd.getColumnCount();++i)
switch(rsmd.getColumnType(i)){
case Types.VARCHAR:
currentRow.addElement(rs.getString(i));
break;
case Types.INTEGER:
currentRow.addElement(
new Long(rs.getLong(i)));
break;

default:
System.out.println("Type was:"+
rsmd.getColumnTypeName(i));

}
return currentRow;

}

public void shutDown()
{
try{
connection.close();

}
catch (SQLException sqlex){
System.err.println("Unable to disconnect");
sqlex.printStackTrace();

}
}
public static void main(String args[])
{
final customer app = new customer();

app.addWindowListener(
new WindowAdapter(){
public void windowClosing(WindowEvent e)
{
app.shutDown();
System.exit(0);
}
}
);
}
}



thanks in advance!!!
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Java is case sensitive. Look at your code at the lines which the compiler is complaining about and you should see the errors.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Luke Smtih
Greenhorn

Joined: Jun 01, 2004
Posts: 11
hahah thanks i dont believe i didnt notice that...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: 2 errors i cannot find!