0

How do I add this Database class which is in another Java project(added as dependency to Dynamic web application) as a Managed Property ?

import java.sql.Connection;
import org.h2.jdbcx.JdbcConnectionPool;
import java.sql.SQLException;
    public class Database
    {
    private JdbcConnectionPool poolMgr;

    public Database(String path, String user, String password, int connectionPoolSize) throws SQLException
        {
            // Creates connection pool
            poolMgr = JdbcConnectionPool.create(path, user, password);
            poolMgr.setMaxConnections(connectionPoolSize);
        }

        public Connection getConnection() throws SQLException
        {
            return poolMgr.getConnection();
        }
    }

package com.project1.bean;
import com.project2.db.Database;
@ManagedBean
@RequestScoped
public class InputBean implements Serializable
{
@ManagedProperty("#{database}")
    private Database database;
 //getters and setters
}
FiendFyre
  • 157
  • 3
  • 17
  • You cannot do that. Managed properties are kept for view layer only (properties which are managed in some way by JSF). I suggest you to go to a `@ManagedBean` which makes service functionality and accesses the controller beans in order to inject them directly. – Aritz Jul 23 '13 at 05:45
  • Thank you for replying, I created a managed bean for database in web application with a no argument constructor. – FiendFyre Jul 23 '13 at 15:47

0 Answers0