File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java Micro Edition and the fly likes how to create a mobile application using struts2 and hibernate on eclipse Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "how to create a mobile application using struts2 and hibernate on eclipse" Watch "how to create a mobile application using struts2 and hibernate on eclipse" New topic
Author

how to create a mobile application using struts2 and hibernate on eclipse

ashish gusain
Greenhorn

Joined: Aug 21, 2013
Posts: 7
hi everyone .. please help i have to create an application usint struts2 hibernate on eclipse .. a simple application with only a button which on clicking shows table from databse (postgresql)
please help me
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42263
    
  64
What do you have so far? If you haven't started, what ideas have you had?

Also, what's the exact connection between a "mobile app" (running on JME, presumably, since this forum is all about JME), and web app technology like Struts?


Ping & DNS - my free Android networking tools app
ashish gusain
Greenhorn

Joined: Aug 21, 2013
Posts: 7
i dont have any idea about j2me or struts .. its a task given by my teacher to complete
i have started with eclipse .. i have installed j2me plugin , i have struts2 and hibernate libraries , and also installed postgresql and wtk from sun on my system
ashish gusain
Greenhorn

Joined: Aug 21, 2013
Posts: 7
please anyone give me the whole source codes step by step
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42263
    
  64
You have to be kidding. This is a task that you should be doing in order to learn. Nobody here will do all the work for you, whilst you take the credit for it. If you don't understand what you're supposed to be doing, ask your teacher - obviously he felt that you have learned everything (or most of) that you need for this assignment.
ashish gusain
Greenhorn

Joined: Aug 21, 2013
Posts: 7
java.lang.Exception: Connection failed with unspecified error.
at org.eclipse.datatools.connectivity.DriverConnectionBase.internalCreateConnection(DriverConnectionBase.java:109)
at org.eclipse.datatools.connectivity.DriverConnectionBase.open(DriverConnectionBase.java:53)
at org.eclipse.datatools.enablement.postgresql.profile.PostgreSQLJDBCConnection.<init>(PostgreSQLJDBCConnection.java:47)
at org.eclipse.datatools.enablement.postgresql.profile.PostgreSQLConnectionFactory.createConnection(PostgreSQLConnectionFactory.java:51)
at org.eclipse.datatools.connectivity.internal.ConnectionFactoryProvider.createConnection(ConnectionFactoryProvider.java:77)
at org.eclipse.datatools.connectivity.internal.ConnectionProfile.createConnection(ConnectionProfile.java:354)
at org.eclipse.datatools.connectivity.ui.PingJob.run(PingJob.java:57)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

can anyone help me resolve this
am unable to connect postgresql to eclipse
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42263
    
  64
Probably not; the singularly unhelpful error mesage gives no hint as to what the problem might be. But it doesn't seem to be about JME (which this forum is all about).
ashish gusain
Greenhorn

Joined: Aug 21, 2013
Posts: 7
hi ulf
i am trying to complete my project but i am having a problem could you please help me

i want to modify these codes below .. these are submitting values to the database but i want to get the table from database and show as output

this is my action class

package ashish.struts2;

import java.util.ArrayList;
import java.util.List;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import ashish.hibernate.Student;
import ashish.hibernate.StudentDAO;

public class AddStudentAction extends ActionSupport
implements ModelDriven<Student>{

Student student = new Student();
List<Student> students = new ArrayList<Student>();
StudentDAO dao = new StudentDAO();
@Override
public Student getModel() {
return student;
}

public String execute()
{
dao.addStudent(student);
return "success";
}

public String listStudents()
{
students = dao.getStudents();
return "success";
}

public Student getStudent() {
return student;
}

public void setStudent(Student student) {
this.student = student;
}

public List<Student> getStudents() {
return students;
}

public void setStudents(List<Student> students) {
this.students = students;
}

}

studentDAO.java on my hibernate package for util

package ashish.hibernate;

import java.util.ArrayList;
import java.util.List;

import org.hibernate.Session;
import org.hibernate.Transaction;

import com.googlecode.s2hibernate.struts2.plugin.\
annotations.SessionTarget;
import com.googlecode.s2hibernate.struts2.plugin.\
annotations.TransactionTarget;

public class StudentDAO {

@SessionTarget
Session session;

@TransactionTarget
Transaction transaction;

@SuppressWarnings("unchecked")
public List<Student> getStudents()
{
List<Student> students = new ArrayList<Student>();
try
{
students = session.createQuery("from Student").list();
}
catch(Exception e)
{
e.printStackTrace();
}
return students;
}

public void addStudent(Student student)
{
session.save(student);
}
}


student.java
my persistance class

package ashish.hibernate;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table(name="student")
public class Student {

@Id
@GeneratedValue
private int id;
@Column(name="last_name")
private String lastName;
@Column(name="first_name")
private String firstName;
private int marks;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public int getMarks() {
return marks;
}
public void setMarks(int marks) {
this.marks = marks;
}
}

student.jsp

<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<html>
<head>
<title>Hello World</title>
<s:head />
</head>
<body>
<s:form action="addStudent">
<s:textfield name="firstName" label="First Name"/>
<s:textfield name="lastName" label="Last Name"/>
<s:textfield name="marks" label="Marks"/>
<s:submit/>
<hr/>
<table>
<tr>
<td>First Name</td>
<td>Last Name</td>
<td>Marks</td>
</tr>
<s:iterator value="students">
<tr>
<td><s:property value="firstName"/></td>
<td><s:property value="lastName"/></td>
<td><s:property value="marks"/></td>
</tr>
</s:iterator>
</table>
</s:form>
</body>
</html>

Ashish Dutt
Ranch Hand

Joined: Apr 12, 2013
Posts: 172

@ashish (OP),
You should be grateful to such erudite yet down to earth people in this forum who are ready to help you only if you show some effort.
In my opinion asking people for source code without doing anything of your own is akin to begging. I'm sorry for being so forthright but it seems in these times of "fast food or take away" people are simply becoming lazier.
i want to modify these codes below .. these are submitting values to the database but i want to get the table from database and show as output

Perhaps you need to rethink again, we are here trying to help you avoid "plagiarism" also known as "Academic Dishonesty"!
If you have written the posted code, then i'm sure you would know where to make the change (which i strongly doubt that you have written......) and if you have not written the code then please for heaven's sake refrain from plagiarism and show some effort for no one is going to do your homework!


Still a beginner at crafting quality coding but have the zeal to learn more. Your help would be appreciated.
My Blog on Learning Analytics
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to create a mobile application using struts2 and hibernate on eclipse