hi,
I'm trying to insert values from a java page in to a mysql db
the foll is the code

i1=st1.executeUpdate("insert into commissiondtls(CompanyCode,BranchCode,LineNo,PartnerCode,CustomerName,InvoiceNo,InvoiceDate,InvoiceAmount,ReceivedAmount,CommissionPer,CommissionPayable,PaymentRef,PaymentDate,InstrumentNo,InstrumentDate,BankName,BankBranch,CommissionPaid,Narration) values('"+CompanyCode+"','"+BranchCode+"','"+commissionDtlsmaxid+"','"+PartnerCode+"','"+CustomerName[i]+"','"+InvoiceNo[i]+"','"+InvoiceDate[i]+"','"+InvoiceAmount[i]+"','"+ReceivedAmount[i]+"','"+CommissionPer[i]+"','"+CommissionPayable[i]+"','"+Paymentno+"','"+Paymentdate+"','"+chequeOrDdNo+"','"+chequeDate+"','"+bankName+"','"+bankBranch+"','"+Amount+"','"+narration+"')throws SQLException");

this doesnot insert values or shows any exception,. what do u think might be the prob? pls help

public void CommissionDetailsSaveTransaction() 
{
try
{

Connection con=null;
Statement st1=null;

con=ServiceLocator.getService();
st1=con.createStatement();

st1.executeUpdate("iinsert into commissiondtls(CompanyCode,BranchCode,LineNo,PartnerCode,CustomerName,InvoiceNo,InvoiceDate,InvoiceAmount,ReceivedAmount,CommissionPer,CommissionPayable,PaymentRef,PaymentDate,InstrumentNo,InstrumentDate,BankName,BankBranch,CommissionPaid,Narration) values('c111','HO',14,'001','Jannath','80','2010-04-09','213.0','200.0','5.0','300.0','1','20-09-2010','ewwq','20-09-2010','wqeqwe','weqwe','100','qweqwe')");

this is not working either

Don't append "throws SQLException"

i1=st1.executeUpdate("insert into commissiondtls(CompanyCode,BranchCode,LineNo,PartnerCode,CustomerName,InvoiceNo,InvoiceDate,InvoiceAmount,ReceivedAmount,CommissionPer,CommissionPayable,PaymentRef,PaymentDate,InstrumentNo,InstrumentDate,BankName,BankBranch,CommissionPaid,Narration) values('"+CompanyCode+"','"+BranchCode+"','"+commissionDtlsmaxid+"','"+PartnerCode+"','"+CustomerName[i]+"','"+InvoiceNo[i]+"','"+InvoiceDate[i]+"','"+InvoiceAmount[i]+"','"+ReceivedAmount[i]+"','"+CommissionPer[i]+"','"+CommissionPayable[i]+"','"+Paymentno+"','"+Paymentdate+"','"+chequeOrDdNo+"','"+chequeDate+"','"+bankName+"','"+bankBranch+"','"+Amount+"','"+narration+"')");

I would suggest to use - PreparedStatement.

yes i tried preparedstatement also ,..it failed too :sad:

Print the query that you are executing:

String query = ".....";
System.out.println(query);
i1=st1.executeUpdate(query);
System.out.println(i1);

What does it print?
Also try to take the query that was printed and run it to an sql command promt.

thanQ,.. got it

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.