Thread: Actual Problem

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

    Join Date
    Mar 2003
    Location
    canterbury
    Posts
    6
    Rep Power
    0

    Actual Problem


    What I actually want to do is insert information into my database through my webpage.


    So within my class file I have insert commands e.g

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

    Database2 db = new Database2();

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

    Which allows me to get the required info from my database

    Now i'm trying to allow user to insert information into the database using

    preparedStatement pstmt = db.preparedStatement(
    " INSERT INTO loan (staff_id, frefcode, datereturned) VALUES ( staff_id= ' + frefcode= ' + ts) ");

    But it's given me error messages

    E:\home\public_html>javac StaffidServlet.java
    StaffidServlet.java:46: cannot resolve symbol
    symbol : class preparedStatement
    location: class StaffidServlet
    preparedStatement pstmt = db.preparedStatement(
    ^

    StaffidServlet.java:46: cannot resolve symbol
    symbol : method preparedStatement (java.lang.String)
    location: class Database2
    preparedStatement pstmt = db.preparedStatement(
    ^
    2 errors

    I have also Attached the files below

    Thanks.
    Attached Files
  2. #2
  3. No Profile Picture
    Clueless llama
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Feb 2001
    Location
    Lincoln, NE. USA
    Posts
    2,353
    Rep Power
    117
    The class PreparedStatement is with a capital P. You have a lower case one.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Location
    canterbury
    Posts
    6
    Rep Power
    0
    I have corrected that now, but its still passing error message :

    E:\home\public_html>javac StaffidServlet.java
    StaffidServlet.java:48: unreported exception java.sql.SQLException; must be caught or declared to be thrown
    PreparedStatement pstmt = con.prepareStatement(
    ^
    1 error
  6. #4
  7. No Profile Picture
    Clueless llama
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Feb 2001
    Location
    Lincoln, NE. USA
    Posts
    2,353
    Rep Power
    117
    You need to wrap your database code in a try catch block. I would suggest a jdbc tutorial before you try and do more.

IMN logo majestic logo threadwatch logo seochat tools logo