I need help to determine the fix for this error:
C:\Documents and Settings\DHerron\Desktop\ProductApp.java:482: unreported exception java.io.IOException; must be caught or declared to be thrown
FileWriter exportFile = new FileWriter("c:\\DBFile.dat"
;
^
1 error
Tool completed with exit code 1
This is the code section:
public void DbtoText()
{
//Create text file objects.
FileWriter exportFile = new FileWriter("c:\\DBFile.dat"
;
PrintWriter exportFileObject = new PrintWriter(exportFile);
String ProductId_Hold;
String ProductDesc_Hold;
String QtyOnHand_Hold;
String QtyOrd_Hold;
String ExtPrice_Hold;
String UnitPrice_Hold;
ProductId_Hold = "";
ProductDesc_Hold= "";
QtyOnHand_Hold= "";
QtyOrd_Hold= "";
ExtPrice_Hold= "";
UnitPrice_Hold= "";
try
{
rsProduct = cmdProduct.executeQuery(
"Select * from Product;"
;
while (rsProduct.next())
{
ProductId_Hold = rsProduct.getString("ProductID"
;
ProductDesc_Hold = rsProduct.getString("ProductDesc"
;
QtyOnHand_Hold = rsProduct.getString("QtyOnHand"
;
QtyOrd_Hold = rsProduct.getString("QtyOrd"
;
UnitPrice_Hold = rsProduct.getString("UnitPrice"
;
ExtPrice_Hold = rsProduct.getString("ExtPrice"
;
exportFileObject.println("|" + ProductId_Hold + "|" + ProductDesc_Hold + "|" + QtyOnHand_Hold + "|" + QtyOrd_Hold + "|" + UnitPrice_Hold + "|" + ExtPrice_Hold );
}
//Close the file.
exportFileObject.close();
}
catch(SQLException error)
{
lblMessage.setText("Error during Edit. " + "Error: " + error.toString());
}
}
C:\Documents and Settings\DHerron\Desktop\ProductApp.java:482: unreported exception java.io.IOException; must be caught or declared to be thrown
FileWriter exportFile = new FileWriter("c:\\DBFile.dat"
^
1 error
Tool completed with exit code 1
This is the code section:
public void DbtoText()
{
//Create text file objects.
FileWriter exportFile = new FileWriter("c:\\DBFile.dat"
PrintWriter exportFileObject = new PrintWriter(exportFile);
String ProductId_Hold;
String ProductDesc_Hold;
String QtyOnHand_Hold;
String QtyOrd_Hold;
String ExtPrice_Hold;
String UnitPrice_Hold;
ProductId_Hold = "";
ProductDesc_Hold= "";
QtyOnHand_Hold= "";
QtyOrd_Hold= "";
ExtPrice_Hold= "";
UnitPrice_Hold= "";
try
{
rsProduct = cmdProduct.executeQuery(
"Select * from Product;"
while (rsProduct.next())
{
ProductId_Hold = rsProduct.getString("ProductID"
ProductDesc_Hold = rsProduct.getString("ProductDesc"
QtyOnHand_Hold = rsProduct.getString("QtyOnHand"
QtyOrd_Hold = rsProduct.getString("QtyOrd"
UnitPrice_Hold = rsProduct.getString("UnitPrice"
ExtPrice_Hold = rsProduct.getString("ExtPrice"
exportFileObject.println("|" + ProductId_Hold + "|" + ProductDesc_Hold + "|" + QtyOnHand_Hold + "|" + QtyOrd_Hold + "|" + UnitPrice_Hold + "|" + ExtPrice_Hold );
}
//Close the file.
exportFileObject.close();
}
catch(SQLException error)
{
lblMessage.setText("Error during Edit. " + "Error: " + error.toString());
}
}