KonaKart Community Forum

Installation / Configuration => Programming of KonaKart => Topic started by: mtoon on March 25, 2008, 02:18:35 pm

Title: Accessing the Database
Post by: mtoon on March 25, 2008, 02:18:35 pm
Hello there!
I'm trying to figure out how to access the database directly from the payment module and the JSPs.  In my example, I'd like to make some database calls (external to konakart) when my custom payment module runs as well as retrieve this data on a JSP.  Any thoughts?  Ideally, I'd like to use whatever connection pooling the application is already using.

Thank you!
Title: Re: Accessing the Database
Post by: mtoon on March 27, 2008, 02:31:20 pm
Just a bump on this.  Is there any method hanging off any of the appif classes?
Thanks
Title: Re: Accessing the Database
Post by: trevor on March 27, 2008, 03:09:16 pm
We use Torque (http://db.apache.org/torque/) for the persistence layer, so you should read up on that if you want to use the same mechanism as KonaKart.
Title: Re: Accessing the Database
Post by: mtoon on March 28, 2008, 06:36:22 pm
I just needed a database connection..  I'm posting this in case it's helpful to anyone else...
Here's how I ended up getting the connection.

        Properties properties = new Properties();
        properties.load(new FileInputStream("../webapps/ROOT/WEB-INF/classes/konakart.properties"));
        String Driver = properties.getProperty("torque.dsfactory.oscommerce.connection.driver");
        String ConnectionURL = properties.getProperty("torque.dsfactory.oscommerce.connection.url");
        String UserName = properties.getProperty("torque.dsfactory.oscommerce.connection.user");
        String Password = properties.getProperty("torque.dsfactory.oscommerce.connection.password");

        Class.forName(Driver);
        Connection conn = DriverManager.getConnection(ConnectionURL, UserName, Password);