db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Norbert Kunstek <norbertkuns...@web.de>
Subject Torque using Tomcat
Date Thu, 22 Jun 2006 13:41:32 GMT
Hello,

I've tried to use Torque within the Servlet but I receive always a ClassNotFound-Exception.
Maybe somebody could solve the Problem:

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.PropertiesConfiguration;
import org.apache.torque.Bank;
import org.apache.torque.Torque;
import org.apache.torque.TorqueException;

//import org.apache.torque.Torque;

//import persistence.Bank;


public class HelloServlet extends HttpServlet
{

public void init() throws ServletException, UnavailableException
{
try
{
ServletContext ct = getServletContext();
PropertiesConfiguration config = new PropertiesConfiguration();

config.load(ct.getResourceAsStream("/WEB-INF/Torque.properties"));


Torque.init(config);
}
catch (ConfigurationException e) {
System.out.println("Configuration: Initialisierung fehlgeschlagen" + e);
}
catch (TorqueException e) {
System.out.println("Init: Initialisierung fehlgeschlagen" + e);
}
}





public void doGet( HttpServletRequest requ, HttpServletResponse resp )
throws ServletException, IOException
{
try
{
Bank sparkasse = new Bank();
sparkasse.setBankId(111);
sparkasse.setName("Apache");
sparkasse.setCity("Torque");

// CREATE
sparkasse.save();

}
catch (Exception e)
{
System.out.println("initializing of Torque failed" + e);
}

resp.setContentType( "text/html" );
PrintWriter out = resp.getWriter();
out.println( "" );
out.println( "Servus," );
out.println( "Torque!" );
out.println( "" );
out.close();
}


}
______________________________________________________________
Verschicken Sie romantische, coole und witzige Bilder per SMS!
Jetzt bei WEB.DE FreeMail: http://f.web.de/?mc=021193


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Mime
View raw message