shuzo monsoon

Ranch Hand
+ Follow
since Feb 11, 2004
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by shuzo monsoon

Hello all. I can't figure out what is goin wrong with an INSERT SQL query I am using in a JSP page. Here is the code -

But when I attempt to execute this query, I get an SQLException error saying : Syntax error in INSERT INTO statement.
I have also tried using a prepared statement but I get the same error.
Can anyone help?
Thanks!
Thanks Sheriff, I think I'll use prepared statements all the time now!
Hi folks! I'm having a bit of trouble getting a SELECT SQL query to work. I'm not sure what's wrong with it as it should work. I pass a parameter which is the ID of a customer and this ID should then be used to select appopriate fields from the CUSTOMER table for that particular record. Here is the query -

The problem I have is that I usually specify the WHERE part as

But when I do this the query does not execute at all. But the above way, ALL of the records from the table are displayed, despite sending a specific ID.
Can anyone help??
Thanks!
Thanks Blake! That worked. Thanks!
Hello! What I'm trying to do at the moment is have a query which finds the appropriate record of a particulat product in the STOCK table and then decrement that quantity by 1. However, I'm not sure ntirely how to do this, as I know how to change the number by specifying one but I'm not sure how to minus the number. I tried this :

But this doesn't work because the second QuantityInStock is not recognised. Has anyone any ideas?
Thanks!
Hello people! I'm experiencing difficulty in executing an INSERT query from a JSP page. The problem is with the WHERE part of the clause (because it works when I've taken it out) , I've tried two different versions - here they are:

Second variation

What I should say is that the table into which I am inserting already has some values in different fields and basically the rest of the fields in that row need to be filled.
Can anyone help? Thank you!
[ March 18, 2004: Message edited by: shuzo monsoon ]
Thanks again Ko, but now there's an error saying -
"The type of this expression, "int", is not a valid reference type in this context." and it refers to the line -
today.getDate().toString()
Is it because I'm trying to assign the date to a string?
20 years ago
Thanks Ko, but I@m getting an error saying "today" is either a misplaced package name or a non existent entity. Any ideas?
20 years ago
Hello, what I'm trying to do is insert data into a database table. 'normal' info is inserted fine but what I need to do is have the current date inserted with the information also. There is a date field in the table but is there a method that allows the current date to be inserted with the rest of the info?
Thanks!
20 years ago
Thanks so much! It works! Now I just have to deal with only removing one of the items when there is more than that in the ArrayList (i.e. when the quantity is >1) But thanks Basil, if you have any ideas to share about the quantity issue I'd really appreciate it!
20 years ago
Hi Red, well I use the BasketItems class methods getTitle, getArtist etc to display the contents of the arrayList. But your idea sounds vey good, I'm gonna give it a try now. Thanks, I'll let you know how it goes.
20 years ago
Hello! I'm having a problem whereby I have two java classes, one (BasketItem) which sets the values of products (e.g. title, artist, price) these are then added to an arraylist in another class (ShoppingCart). I am using JSP to handle user requests to add products to the cart and also increment quantities. However, I am having trouble allowing users to remove items from their carts. What I have is a link next to the item to be deleted which is sent to a controlling JSP page which handles deleting the selected item from the arraylist. I can't figure out how to select the appropriate entry from the arraylist based on the name of the product, and then delete it. Can nayone help? Thanks.
20 years ago
I did that and it seems like it does expect another curly brace but I can't add one there can I, I mean as the file is created each time the JSP page is compiled - i.e. each time it is run, so does that mean I should add a brace in the JSP page or is there a way around this?
20 years ago
JSP
Hello all, the following code for a JSP page genereates an error which states that the class file for this JSP page has a 'catch wihtout try' a 'try without catch' and needs another '}'. The page basically gets some values sent by the previous page and then either adds these to a class and forwards to the summary page or skips straight to the checkout page.
I can't see what's wrong with the code so I don't know why I've got this error, can anyone help?
<%@page import="java.sql.*, java.util.*, catalogue.*"%>
<jsp:useBean class="catalogue.ShoppingCart" id="cart" scope="session"/>
<%
String submit = request.getParameter("submit");
String product = (String)request.getParameter("product");
String artist = (String)request.getParameter("artist");
float price = Float.parseFloat(request.getParameter("price"));
if(submit.equals("Add")) {
BasketItem cd = new BasketItem();
cd.setTitle(product);
cd.setArtist(artist);
cd.setPrice((float)price);
cd.setQuantity(1);
cart.addItem(cd);
%>
<jsp:forward page="ShoppingCartSummary.jsp"/>
<%
}
else if (submit.equals("Checkout")) {
%>
<jsp:forward page="Checkout.jsp"/>
}
%>
Thanks.
20 years ago
JSP
Hello all, I have written a class called BasketItems, which basically stores the title, artist, price and quantity of an item. Then another class - ShoppingBasket is used to store an instance of the basketItems class in a vector. However, the vector itself is not instantiated until a user adds an item (through a JSP page) to the basket, in which case a process request method should add the product to the vector. I am having some trouble in specifying that if the product is already present, then the quantity should be incremented. Here are the 2 classes -

BASKET ITEMS CLASS
public class BasketItem {
String product = null;
String artist = null;
float price = 0;
int quantity = 0;

public BasketItem(String product_, String artist_, float price_) {
product = product_;
artist = artist_;
price = price_;
quantity = 1;
}
public String getTitle() {
return product;
}
public String getArtist() {
return artist;
}
public float getPrice() {
return price;
}
public int getQuantity() {
return quantity;
}
public void setQuantity(int quantity_) {
quantity = quantity_;
}
public void addToItemQuantity(int q) {
quantity += q;
}
}
SHOPPING BASKET CLASS
package catalogue;
import java.util.*;
import javax.servlet.http.HttpServletRequest;
public class ShoppingBasket extends Object {
private Vector basket = null;
String product = null;
String submit = null;

public ShoppingBasket() {
basket = new Vector();
}
public void setProduct(String product) {
this.product = product;
}
public void setSubmit(String submit) {
this.submit = submit;
}
public Vector getProducts() {
return basket;
}
public void addProduct(String product) {
basket.add(product);
}
public void removeProduct(String product) {
basket.remove(product);
}
public void processRequest(HttpServletRequest req) {
if(submit!=null) {
if(submit.equals("Add")) {

BasketItem item = null;
boolean added = false;
for(int i=0;i<products.size();i++) {
item = (BasketItem)products.get(i);
if(item.getTitle().equals(product)) {
((BasketItem)products.get(i)).addToItemQuantity(1);

added = true;
break;
}
if(!added) {
addProduct(product);
}
}
}
}
else if(submit.equals("remove")) {
removeProduct(product);
}
else {
reset();
}
}
public void reset() {
submit = null;
product = null;
}
}
Teh problem I have is that I have used "products.get(i)" for example which is actually a reference to the vector created on the JSP page.
I hope this isn't too confusing and that someone can try and help!
Thanks.
20 years ago
JSP