Your insert statement is incorrect, and should look like that:
Statement stmt = con.createStatement();
stmt.executeUpdate("insert OfficeSupply values "+
"("+this.LItem+","+this.Lquan+","+this.Lprice+",0)");
You should have also seen some kind of SQL Exception on the server running
this
JSP.
Regards,
Oren
Manna Inc.
www.mannainc.com
-----Original Message-----
From: A mailing list about Java Server Pages specification and reference
[mailto:[EMAIL PROTECTED]]On Behalf Of Ting Abbey
Sent: Wednesday, July 05, 2000 4:09 PM
To: [EMAIL PROTECTED]
Subject: insert data
Dear JSP guru(s),
I am new to JSP. I have a problem and need your help. Thanks in advance!
I try to get input from user and insert the data into Sybase db.
I received no error but no user data is inserted into the db.
Please help!
Below are the codes for both the JSP & the bean:
-----------JSP-------------------------------------------------------
<html>
<%@ page import = "dbPlay.UserInsertDataBean"%>
<jsp:useBean id="insertData" scope="session"
class="dbPlay.UserInsertDataBean"/>
<jsp:setProperty name="insertData" property="*" />
<body>
<form method=get>
Item <input type =text name=item><p>
Quantity <input type = text name=quan><p>
Unit Price <input type = text name=price><p>
<input type=submit value="submit">
</form>
<% insertData.setItem(request.getParameter("item"));
insertData.setQuan(request.getParameter("quan"));
insertData.setPrice(request.getParameter("price"));
insertData.doInsert();
%>
<%-- insertData.doInsert(); --%>
</body>
</html>
-------------------bean----------------------------------------
package dbPlay;
import java.sql.*;
import java.util.*;
import com.sybase.jdbcx.SybDriver;
public class UserInsertDataBean{
String LItem;
String Lquan;
String Lprice;
public UserInsertDataBean() {super();}
public void setItem(String item){
this.LItem = item;}
public void setQuan(String quan){
this.Lquan = quan;}
public void setPrice(String price){
this.Lprice = price;}
public void doInsert()throws
ClassNotFoundException, InstantiationException,
IllegalAccessException{
try{
SybDriver sybDriver = (SybDriver)
Class.forName("com.sybase.jdbc2.jdbc.SybDriver").newInstance();
Properties SysProps = new Properties();
SysProps.put("user","dbuser");
SysProps.put("password","");
String url = "jdbc:sybase:Tds:165.122.250.28:5000/stm";
Connection con = DriverManager.getConnection(url,SysProps);
Statement stmt = con.createStatement();
stmt.executeUpdate("insert OfficeSupply values "+
"(this.LItem,this.Lquan,this.Lprice,0)");
con.close();}
catch (SQLException e){
e.getMessage();}
}
}
-----------------------------end--------------------------------------------
------
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets