Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.Serializable;
- import javax.enterprise.context.SessionScoped;
- // or import javax.faces.bean.SessionScoped;
- import javax.inject.Named;
- /* include SQL Packages */
- import java.sql.Connection;
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import java.util.ArrayList;
- import java.util.List;
- import javax.sql.DataSource;
- import javax.annotation.Resource;
- import javax.faces.context.FacesContext;
- import javax.inject.Inject;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpSession;
- // or import javax.faces.bean.ManagedBean;
- import org.glassfish.osgicdi.OSGiService;
- @Named("DashboardController")
- @SessionScoped
- public class Dashboard implements Serializable {
- private String storedPassword = null;
- private String stringzoro = null;
- private String stringone = null;
- private String stringtwo = null;
- private String SQL_Statement = null;
- private String Password;
- private String User;
- public Dashboard() throws SQLException {
- }
- /* Call the Oracle JDBC Connection driver */
- @Resource(name = "jdbc/Oracle")
- private DataSource ds;
- public String getUser() {
- return User;
- }
- public void setUser(String User) {
- this.User = User;
- }
- public String getPassword() {
- return Password;
- }
- public void setPassword(String Password) {
- this.Password = Password;
- }
- //connect to DB and get customer list
- public List<Dashboard> getDashboardList() throws SQLException {
- if (ds == null) {
- throw new SQLException("Can't get data source");
- }
- //get database connection
- Connection con = ds.getConnection();
- if (con == null) {
- throw new SQLException("Can't get database connection");
- }
- PreparedStatement ps = con.prepareStatement(
- "SELECT * from GLOBALSETTINGS");
- //get customer data from database
- ResultSet result = ps.executeQuery();
- List<Dashboard> list = new ArrayList<Dashboard>();
- while (result.next()) {
- Dashboard cust = new Dashboard();
- cust.setUser(result.getString("SessionTTL"));
- cust.setPassword(result.getString("MAXACTIVEUSERS"));
- //store all data into a List
- list.add(cust);
- }
- return list;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement