hi all, i hope to get some help from u guys. i want to add record to DB but it doesn't work, the record cant be added to db. i've a java clas like below:
public class CustomerDataBean {
private Connection connection;
private PreparedStatement addRecord, getRecords;
private PreparedStatement sqlFind;
// construct CustomerDataBean object
public CustomerDataBean() throws Exception
{
// load the Cloudscape driver
Class.forName( "COM.cloudscape.core.RmiJdbcDriver" );
// connect to the database
connection = DriverManager.getConnection(
"jdbc:rmi:jdbc:cloudscape:customers");
connection.setAutoCommit(false);
sqlFind = connection.prepareStatement(
"SELECT email, password " +
"FROM custinfor " +
"WHERE email = ? AND password = ? " );
getRecords =
connection.prepareStatement(
"SELECT * FROM custinfor"
);
addRecord = connection.prepareStatement(
"INSERT INTO custinfor (email, firstName, lastName, password, verify, address, phone, creditCard ) " +
"VALUES ( ?, ?, ?, ?, ?, ?, ?, ? )" );
}
public void addCustomer( CustomerBean customer ) throws SQLException
{
addRecord.setString( 1, customer.getEmail() );
addRecord.setString( 2, customer.getFirstName() );
addRecord.setString( 3, customer.getLastName() );
addRecord.setString( 4, customer.getPwd() );
addRecord.setString( 5, customer.getVPwd() );
addRecord.setString( 6, customer.getAdd() );
addRecord.setString( 7, customer.getPhone() );
addRecord.setInt( 8, customer.getCC() );
addRecord.executeUpdate();
}
i called addCustomer method at JSP.
thanks.are you sure that the user name in your connection string that you are using has insert permissions to that table.
I know stupid, but I forget to give execute permissions to sp's all the time.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment