Re: Database and java.sql.SQLException Questions
- From: "zhah99 via JavaKB.com" <u19084@uwe>
- Date: Thu, 27 Apr 2006 04:43:21 GMT
Well Integer was definitly one of my problems, I have the CreateDatabase
running now. I am working on the SalesClient. I am getting a
NullPointerException in the addNewSalesman method below. I think it might
have to do with the way I am inserting the data into the database, is this
correct? Am I do something wrong with the quotes?
[code]
......
public void addNewSalesman()
{
double sales = calculateNewSales(product.getSelectedIndex(), Integer.
parseInt(amtprodsold.getText()));
if (getNewSalesman(salesmanname.getText()) != null)
{
JOptionPane.showMessageDialog(this, salesmanname.getText() + " is an
existing Salesman. To update an existing Salesman," +
"\n" + "please go to Sales Data Entry - Update Current Salesman.",
"Existing Salesman", JOptionPane.INFORMATION_MESSAGE);
}
else
{
try
{
if(saleslevel.getSelectedItem().equals("Entry"))
{
level = .05;
}
else if(saleslevel.getSelectedItem().equals("Junior"))
{
level = .10;
}
else if(saleslevel.getSelectedItem().equals("Senior"))
{
level = .15;
}
String insertsalesman2 = "INSERT INTO Salesman VALUES(" + salesmanname +
"," + "''" + level + ")";
String insertsales2 = "INSERT INTO Sales VALUES(" + sales + ")";
stmt.executeUpdate(insertsalesman2);
stmt.executeUpdate(insertsales2);
System.out.println("Inside addNewSalesman Method!!");
}
catch(Exception ee)
{
ee.printStackTrace();
}
}
salesmanname.setText("");
saleslevel.setSelectedIndex(0);
product.setSelectedIndex(0);
amtprodsold.setText("");
salesmanname.requestFocus();
}
......
[/code]
--
Message posted via http://www.javakb.com
.
- Follow-Ups:
- Re: Database and java.sql.SQLException Questions
- From: Bjorn Abelli
- Re: Database and java.sql.SQLException Questions
- References:
- Database and java.sql.SQLException Questions
- From: zhah99 via JavaKB.com
- Re: Database and java.sql.SQLException Questions
- From: Jon Martin Solaas
- Re: Database and java.sql.SQLException Questions
- From: zhah99 via JavaKB.com
- Re: Database and java.sql.SQLException Questions
- From: Bjorn Abelli
- Database and java.sql.SQLException Questions
- Prev by Date: Re: UnsatisfiedLinkError
- Next by Date: Re: UnsatisfiedLinkError
- Previous by thread: Re: Database and java.sql.SQLException Questions
- Next by thread: Re: Database and java.sql.SQLException Questions
- Index(es):