If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > add record in SQL

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-06-03, 11:23
jess88 jess88 is offline
Registered User
 
Join Date: Sep 2003
Posts: 12
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.
Reply With Quote
  #2 (permalink)  
Old 10-28-03, 17:12
mkkmg mkkmg is offline
Registered User
 
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.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On