This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes throwing SQLException : GeneralError Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "throwing SQLException : GeneralError" Watch "throwing SQLException : GeneralError" New topic
Author

throwing SQLException : GeneralError

amarnath jha
Greenhorn

Joined: Aug 07, 2006
Posts: 18
my programe is throwing SQLException GeneralError using oracle9i

//this is code

public void insertData(String name,int id,float price,int sales,float total)
{
try
{
//columns = statement.executeUpdate("insert into coffees values ("+name+","+id+","+price1+","+sales1+","+total1+")");
pStatement = connection.prepareStatement("insert into coffees values(?,?,?,?,?)");
pStatement.setString(1,name);
pStatement.setInt(1,id);
pStatement.setDouble(1,price);
pStatement.setInt(1,sales);
pStatement.setDouble(1,total);
pStatement.executeUpdate();
connection.commit();
System.out.println("no of rows inserted "+columns);
}
//catch block and other code
Chetan Natu
Greenhorn

Joined: Dec 03, 2005
Posts: 19
Check your database, normally if you are inserting duplicate primary-key values, you will receive such kind of error...

Can you post the stack trace?


Never Remember the failure
Never Forget the mistake
 
Don't get me started about those stupid light bulbs.
 
subject: throwing SQLException : GeneralError
 
It's not a secret anymore!