Hello,
I'm trying to retrieve data from mysql db using Hibernate in Eclipse, everything seems to work correctly but no data are print in the index page. Could you please help me with the code?
here my code:
Index.jspCode:
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="java.util.List"%>
<%@page import="java.util.Date"%>
<%@page import="com.dashboard.model.ListUser" %>
<%@page import="com.dashboard.model.ListAlarms" %>
<%@page import="com.dashboard.model.testUser" %>
<%@page import="com.dashboard.model.Agents" %>
<%@page import="com.dashboard.model.Alarms" %>
<%@page import="com.dashboard.model.User" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Dashboard</title>
</head>
<body>
<h1>Welcome to Dashboard</h1>
<a href="./TimeTracker.html">TimeTracker</a>
<h2>Show Agents: </h2>
<%
ListUser ListUser = new ListUser();
List<Agents> list = ListUser.getListOfAgents();
for (Agents a : list) {
%>
<tr>
<td><%=a.getId()%></td>
<td><%=a.getAgsdt()%></td>
<td><%=a.getHiredt()%></td>
<td><%=a.getWorkdt()%></td>
<td><%=a.getDismissdt()%></td>
<td><%=a.getNickname()%></td>
<td><%=a.getName()%></td>
<td><%=a.getSurname()%></td>
</tr>
<br>
<%}%>
<h2>Show Alarms: </h2>
<%
ListAlarms ListAlarms = new ListAlarms();
List<Alarms> allarmi = ListAlarms.getListOfAlarms();
for (Alarms w : allarmi) {
%>
<tr>
<td><%=w.getId_terna()%></td>
<td><%=w.getValore_picco()%></td>
<td><%=w.isSee()%></td>
</tr>
<br>
<%}%>
<h2>Show Users: </h2>
<%
testUser testUser = new testUser();
List<User> utenti = testUser.getListOfUser();
for (User u : utenti) {
%>
<tr>
<td><%=u.getId()%></td>
<td><%=u.getName()%></td>
<td><%=u.getSurname()%></td>
<td><%=u.getCountry()%></td>
</tr>
<br>
<%}%>
</body>
</html>
Hibernate.cfg.xmlCode:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.3//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:8889/sd</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">root</property>
<property name="hibernate.default_schema">sd</property>
<property name="show_sql">false</property>
<mapping resource="Agents.hbm.xml" />
<mapping resource="Alarms.hbm.xml" />
<mapping resource="user.hbm.xml" />
</session-factory>
</hibernate-configuration>
user.hbm.xmlCode:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.dashboard.model.User" table="users">
<id name="id" column="user_id">
<generator class="assigned" />
</id>
<property name="name" column="firstname" />
<property name="surname" column="lastname" />
<property name="country" column="country" />
</class>
</hibernate-mapping>
User.javaCode:
package com.dashboard.model;
public class User {
private int id;
private String name;
private String surname;
private String country;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSurname() {
return surname;
}
public void setSurname(String surname) {
this.surname = surname;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
}
That's what i see
Any suggestions?
Thanks so much