Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2003
    Posts
    12

    Unanswered: add record in SQL

    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.

  2. #2
    Join Date
    Oct 2003
    Location
    Dallas
    Posts
    76

    ....

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •