#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Location
    canterbury
    Posts
    6
    Rep Power
    0

    Question Insert into Database


    Help pls !

    Having problems inserting into database

    When complied passing error

    E:\home\public_html>javac StaffidServlet.java
    StaffidServlet.java:54: cannot resolve symbol
    symbol : method insert (java.lang.String,java.lang.String,java.lang.String)
    location: class Database2
    db.insert(table, colNames, colValues);
    ^
    1 error

    Code:

    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.*;
    import java.util.Date;
    import java.sql.*;
    import java.sql.Timestamp;
    import java.lang.System.*;

    public class StaffidServlet extends HttpServlet {

    public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {

    PrintWriter out;

    response.setContentType("text/html");

    out = response.getWriter();

    out.println("<html><body>");

    /* This string parameters will capture information that is received from webpage and pass it through
    the array */


    String [] staffinfo = request.getParameterValues("staff_id");
    String firstStaffinfo = staffinfo [0];

    Database2 db = new Database2();

    String [] staffresults = db.selectWhere("*", "staffmembers", "staff_id= '"+ firstStaffinfo +"'");


    String [] fileinfo = request.getParameterValues("frefcode");
    String firstFileinfo = fileinfo [0];

    String [] fileresults = db.selectWhere("*", "file", "frefcode= '"+ firstFileinfo +"'");

    long currentTime = System.currentTimeMillis();
    Timestamp ts = new Timestamp (currentTime);

    /* Insert into database*/



    String table= "Loan";
    String colNames= "(staff_id, frefcode, dateBorrowed)";
    String colValues= "('" + firstStaffinfo +"'," + firstFileinfo + "," +ts.toString() +")";


    db.insert(table, colNames, colValues);
    out.println(ts);
    out.println("<br>");

    Thanks.
  2. #2
  3. kill 9, $$;
    Devshed Supreme Being (6500+ posts)

    Join Date
    Sep 2001
    Location
    Shanghai, An tSín
    Posts
    6,897
    Rep Power
    3886

    Re: Insert into Database


    Originally posted by as57
    Help pls !

    Having problems inserting into database

    When complied passing error

    E:\home\public_html>javac StaffidServlet.java
    StaffidServlet.java:54: cannot resolve symbol
    symbol : method insert (java.lang.String,java.lang.String,java.lang.String)
    location: class Database2
    db.insert(table, colNames, colValues);
    ^
    1 error
    That's a standard Java error message. It means that your Database2 class doesn't have a method insert() that takes three strings as arguments. Have a look at your Database2 class.

    ~ishnid
    PS - this should really be in the Java forum.

IMN logo majestic logo threadwatch logo seochat tools logo