SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Mar 2011
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    error in java statement to insert data into sql server 2005

    error : not an sql expression statement
    gettin error in sql query to insert data in sql server 2005 using java

    Code Java:
    import java.sql.*;
     
    public class TaskBO 
    {
      public TaskBO()
      {
      }
     public boolean createtask(Taskdata taskdata) 
      {
        try 
        {
          Connection conn = DatabaseManager.getConnection();
          Statement stmt = conn.createStatement();
          String query = "insert into dbo.guru VALUES('"+taskdata.getTaskid() +"','" + taskdata.getTaskname() +"','"+taskdata.getDateOfBirth();"')";
          boolean result = stmt.execute(query);
          stmt.close();
     
        } catch (Exception ex) 
        {
          ex.printStackTrace();
        }
     
        return true;
      }
      }
    Last edited by Mittineague; Mar 22, 2011 at 20:44. Reason: reformatting bbcode tags

  2. #2
    SitePoint Wizard silver trophy rushiku's Avatar
    Join Date
    Dec 2003
    Location
    A van down by the river
    Posts
    2,056
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    When you print out the statement to see if it looks correct, does it?

  3. #3
    SitePoint Evangelist
    Join Date
    Jun 2004
    Location
    ny
    Posts
    560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    your problem is your insert statement...extra "; or +" getDateOfBirth();


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •