Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

java servlet

HI guys: I need urgent help: I am developing online banking system the new customer inter his details into register.html page, I have customers and accounts table in my database, when the new customer register his/her details stored in customers table and the system generate unique customerid and accountid for the customer, but i have exception throw said: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where (customers.'null'=accounts.'null')' at line 1 This my code how do i sort this problem please help:

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
import java.sql.*;
import java.awt.*;
import java.lang.Math;
public class register extends HttpServlet
{
Connection connection;

String name, customerid, address, email, password, accountid,description;
private Connection con = null;
public Statement s = null;
private ResultSet rs = null;
String bigDecimal;
public String URL = "org.gjt.mm.mysql.Driver";
public void init()
{
try
{
Class.forName("org.gjt.mm.mysql.Driver");
Connection con = DriverManager.getConnection
("jdbc:mysql://urlport/user","user","password");
String conStr = "jdbc:mysql://("urlport/user","user","password"&jdbcCompliantTruncation=false";
Statement stmt = con.createStatement();
stmt.executeUpdate( "CREATE TABLE customers (" +
"name text NOT NULL, " +
"customerid int (10) NOT NULL primary key auto_increment, " +
"address text (25) NOT NULL, " +
"email text (20) NOT NULL, " +
"password text (10) NOT NULL," +
"description CHAR (20) NOT NULL," +
")" );
stmt.executeUpdate( "CREATE TABLE accounts (" +
"customerid int (10) NOT NULL, " +
"accountid int (10) NOT NULL primary key auto_increment, " +
"balance text (10) NOT NULL, " +
"overdraft text (10) NOT NULL," +
"description CHAR (20) NOT NULL, " +

")" );
}

catch (Exception e)
{
e.printStackTrace();
}
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
PrintWriter out = response.getWriter();
response.setContentType("text/html");

out.println("<HTML>");
out.println("<BODY>");
String name = request.getParameter("name");
String address = request.getParameter("address");
String email = request.getParameter("email");
String password = request.getParameter("password");
String account_desc = request.getParameter("description");
String balance = request.getParameter("balance");
String overdraft = request.getParameter("overdraft");
try // try to add data to the database
{
Class.forName("org.gjt.mm.mysql.Driver");
Connection con = DriverManager.getConnection
("jdbc:mysql://urlport/user","user","password");

Statement st = con.createStatement();
st.executeUpdate("insert into customers ("+"name,address, email,password,description,customerid)values('"+name+"','"+address+"', '"+email+"', '"+password+"','"+description+"', customerid)");
st.executeUpdate("insert into accounts ("+"customerid,accountid,balance, overdraft, description) values(customerid,accountid, '"+balance+"', '"+overdraft+"','"+description+"')where (customers.'"+customerid+"'=accounts.'"+customerid+"')");

I think my problem is on the red code
Can you help :([/SIZE][/SIZE]
[3701 byte] By [nassar] at [2007-11-11 8:38:10]