-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: No data retrieve from mysql
PostPosted: Sat Nov 26, 2016 1:29 pm 
Newbie

Joined: Sat Nov 26, 2016 12:44 pm
Posts: 1
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.jsp

Code:
<%@ 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.xml

Code:
<?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.xml

Code:
<?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.java

Code:
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

Image

Any suggestions?
Thanks so much


Top
 Profile  
 
 Post subject: Re: No data retrieve from mysql
PostPosted: Sat Nov 26, 2016 2:24 pm 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
Turn on the SQL logging to see that you don't execute any statement.

You should also read our User Guide to get a better understanding of how Hibernate works.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.