i have the folowing code in my jsp page:
String[] name = null;
String[] manufacturer = null;
String[] description = null;
String[] category = null;
String[] price = null;
String result = null;
String connectionURL = "jdbc:mysql://localhost:3306/syte";
Connection connection = null; Class.forName("com.mysql.jdbc.Driver").newInstance();
connection = DriverManager.getConnection(connectionURL,"root","");
Statement statement = null;
statement = connection.createStatement();
PreparedStatement pstatement = null;
pstatement = connection.prepareStatement("SELECT name, manufacturer, description, category, price FROM product;");
ResultSet updateQuery;
updateQuery = pstatement.executeQuery();
int i = 0;
updateQuery.beforeFirst();
while(updateQuery!=null && updateQuery.next())
{
name[i] = updateQuery.getString(1);
manufacturer[i] = updateQuery.getString(2);
description[i] = updateQuery.getString(3);
category[i] = updateQuery.getString(4);
price[i] = updateQuery.getString(5);
i++;
updateQuery.next();
}
i get the folowing error on line 19:
Null poiter exception
the database has the folowing structure:
name manufacturer description category product_id price
test test test test 1 999
test1 test1 test1 test1 2 999