JSP

C

cliveswan

Hi,

I am trying to create a simple JSP page that views RSS feeds in the
database
AND allows the user to input: URL, description and titel.

CAN anyone look at my code & point out my mistake?????

The user should read any updates in the jsp page.

I am getting lots of errors, can anyone help???
Please!!!!

The JSP page:
package com;
import net.sf.hibernate.*;
import java.io.*;
import java.util.*;
import java.lang.InstantiationException;
import net.sf.hibernate.cfg.*;

public class HibernateFactory
{
public static SessionFactory cSessionFactory;

public HibernateFactory()
{
}

public static void init() throws HibernateException
{
//create instance of configuration
Configuration cf = new Configuration();

//mapped to the instance configuration
cf.addClass(RSS.class);
cf.addClass(Item.class);

//Xml and object mapping
cSessionFactory = cf.buildSessionFactory();
}

public static SessionFactory getSessionFactory()
{
// open a session
return cSessionFactory;
}

public static void main(String args[])
{
try
{
SessionFactory sf = HibernateFactory.getSessionFactory();
Session session = sf.openSession();

Query query = session.createQuery("Select RSS from RSS As RSS");

RSS rss = session.load(RSS.class, new Long(l));
Set items = rss.getItems();

List rssList = query.list();

}
catch(HibernateException he)
{
he.printStackTrace();
}
}


}


+++++++++++++++++++++++++++++

Title.java
package com.persistence;

public class Title
{
private String title;

public String getTitle()
{
return title;
}

public void setTitle(String title)
{
this.title = title;
}

//END
}

+++++++++++++++++++++++++++
HibernateTest.java

package com;

import com.evermind.util.Link;

import java.util.Calendar;
import net.sf.hibernate.*;
import com.persistence.*;
import java.sql.*;
public class HibernateTest
{
public HibernateTest()
{
}

public static void main(String args[]) throws HibernateException {
try
{
HibernateFactory hf = new HibernateFactory();
hf.init();


SessionFactory sf = hf.getSessionFactory();

//private String title;
//private String descp;
//private String link;

Title title = new Title();
title.setTitle(title);

Descp descp = new Descp();
descp.setDescp(descp);

Link link = new Link();
link.setLink (link);


Date d = new Date(Calendar.getInstance().getTimeInMillis());


Session session = sf.openSession();
Transaction trans = session.beginTransaction();
session.save(title);
session.save(descp);
session.save(link);
trans.commit();
}
catch(HibernateException exc)
{
exc.printStackTrace();
}
}
}

+++++++++++++++++++++++++++++
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,229
Latest member
GloryAngul

Latest Threads

Top