Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Pls Help

  1. #1
    Junior Member
    Join Date
    Jul 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy Pls Help



    Hey Im new to java.I'm doing a project from java.since i'm new to java i have some problem with java db data retriving.Please guys help me

    I have date field in my javadb.I have to retrive data from the table via date field.
            Date date = jCalendar1.getDate();
            session = HibernateUtil.getSessionFactory().getCurrentSession();
            session.beginTransaction();
            List result = session.createQuery("from Presentation.Appoinment where location=\'"+date+"\'").list();
     
            for(Object a:result){
                Appoinment app=(Appoinment)result;
                JOptionPane.showMessageDialog(this, app.getLocation());
              }
     
            session.getTransaction().commit();
            HibernateUtil.getSessionFactory().close();

    but code won't work.Please help me on this guys
    Last edited by copeg; July 18th, 2010 at 03:05 PM. Reason: Please use the code tags


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    21,105
    Thanks
    52
    Thanked 2,285 Times in 2,256 Posts

    Default Re: Pls Help

    code won't work
    Can you explain what does happen and why/how you want to change it?

  3. #3
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,337
    Thanks
    182
    Thanked 830 Times in 773 Posts
    Blog Entries
    5

    Default Re: Pls Help

    Errors, expected behavior, and resulting behavior always help others diagnose problems. How is your date represented in the database? Would it be the same as calling date.toString() (current implementation), or should you format the date somehow so it matches the representation in the database?

  4. #4
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Location
    Warrington, United Kingdom
    Posts
    1,274
    My Mood
    Happy
    Thanks
    70
    Thanked 156 Times in 152 Posts

    Default Re: Pls Help

    For being new to Java maybe you should consider something other than Hibernate. I'm not too familiar with Hibernate myself but is really a valid way of writing a query, if it is, it sure isn't best practice.

    // Json