raghavendra raghu

Greenhorn
+ Follow
since Sep 01, 2012
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
2
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by raghavendra raghu

Awesome Mark.

Just few general questions.
Do you suggest IOT as a major career technology?
How are  the careers going to be for a company in digital transformations especially with competetors also getting into cloud?
1 month ago
Thank you Saif asif for your input...
I have changed my Register action class to model driven class and I also included a printing statement but my problem is not solved...Iam getting a null value at my console which means Iam still unable to receive my customer object...same error save or update failed in CustImpl.java...any help regarding this?why is my session not saving?
8 years ago
sorry for too much coding...can anyone help me out?Im dying for the solution?
8 years ago
hello...
Iam trying to create a small register application using struts and hibernate which creates a customer table in mysql DB and stores values in it using hibernate.but iam unable to store values into the table.
Error is:java.lang.IllegalArgumentException: attempt to create saveOrUpdate event with null entity.
.problem is that my session is not getting saved in my custimpl.java.
full stack trace is:
java.lang.IllegalArgumentException: attempt to create saveOrUpdate event with null entity
at org.hibernate.event.SaveOrUpdateEvent.<init>(SaveOrUpdateEvent.java:63)
at org.hibernate.event.SaveOrUpdateEvent.<init>(SaveOrUpdateEvent.java:46)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:551)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:547)
at com.dao.CustomerImpl.addCustomer(CustomerImpl.java:23)
at com.action.Register.execute(Register.java:22)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:453)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:292)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:255)
at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:256)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:265)
at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:211)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:211)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:190)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:90)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:243)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:192)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:511)
at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source).
my programs one by one:
index.html:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Online Banking</title>
</head>
<body bgcolor="grey">
<h1 align="center">Welcome to Online Banking</h1>
<a href="registerpage"><h4>REGISTER</h4></a><br>
</body>
</html>

struts.xml:


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">

<struts>
<constant name="struts.devMode" value="true" />
<constant name="struts.enable.DynamicMethodInvocation" value="false"/>
<constant name="struts.custom.i18n.resources" value="package"/>

<package name="default" extends="struts-default">

<action name="index">
<result>/index.html</result>
</action>
<action name="registerpage">
<result>/pages/register.jsp</result>
</action>
<action name="register"
class="com.action.Register"
method="execute">
<result name="success">/pages/success.jsp</result>
<result name="input">/pages/register.jsp</result>
</action>
</package>
</struts>

web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>OnlineBanking</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
my com.action package:
Customer.java:
package com.action;

import com.dao.CustomerImpl;
import com.opensymphony.xwork2.ActionSupport;

public class Customer extends ActionSupport {

@Override
public String toString() {
return "Customer [fname=" + fname + ", lname=" + lname + ", password="
+ password + ", email=" + email + ", gender=" + gender
+ ", phone=" + phone + "]";
}


String fname,lname,password,email,gender,phone;


public String getFname() {
return fname;
}


public Customer() {
super();
}


public Customer(String fname, String lname, String password, String email,
String gender, String phone) {
super();
this.fname = fname;
this.lname = lname;
this.password = password;
this.email = email;
this.gender = gender;
this.phone = phone;
}


public void setFname(String fname) {
this.fname = fname;
}


public String getLname() {
return lname;
}


public void setLname(String lname) {
this.lname = lname;
}


public String getPassword() {
return password;
}


public void setPassword(String password) {
this.password = password;
}


public String getEmail() {
return email;
}


public void setEmail(String email) {
this.email = email;
}


public String getGender() {
return gender;
}


public void setGender(String gender) {
this.gender = gender;
}


public String getPhone() {
return phone;
}


public void setPhone(String phone) {
this.phone = phone;
}
}

Register.java:

package com.action;

import com.action.Customer;
import com.dao.CustomerDAO;
import com.dao.CustomerImpl;


public class Register {
Customer customer;

public Customer getCustomer() {
return customer;
}

public void setCustomer(Customer customer) {
this.customer = customer;
}
public String execute(){
CustomerDAO ref = new CustomerImpl();
ref.addCustomer(getCustomer());
return "success";
}
}
Customer.hbm.xml:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Mar 1, 2013 10:33:44 AM by Hibernate Tools 3.3.0.GA -->
<hibernate-mapping>
<class name="com.action.Customer" table="CUSTOMER">
<id name="fname" type="java.lang.String">
<column name="FNAME" />
<generator class="assigned" />
</id>
<property name="lname" type="java.lang.String">
<column name="LNAME" />
</property>
<property name="password" type="java.lang.String">
<column name="PASSWORD" />
</property>
<property name="email" type="java.lang.String">
<column name="EMAIL" />
</property>
<property name="gender" type="java.lang.String">
<column name="GENDER" />
</property>
<property name="phone" type="java.lang.String">
<column name="PHONE" />
</property>
</class>
</hibernate-mapping>
my com.dao package:
CustomerDAO.java:

package com.dao;

import com.action.Customer;


public interface CustomerDAO {
void addCustomer(Customer c);

}
CustomerImpl.java:

package com.dao;
import java.io.Serializable;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.Session;

import com.dao.CustomerDAO;
import com.action.Customer;
import com.dao.HibernateUtil;

public class CustomerImpl implements CustomerDAO{
SessionFactory factory;
@Override
public void addCustomer(Customer c) {
try{

factory = HibernateUtil.getSessionfactory();
Session session =factory.openSession();
Transaction t = session.beginTransaction();
session.save(c);//----------------------------->actual problem is here.hibernate doesnt fill my customer details which are entered through register.jsp.instead it returns c as null... session is not getting saved
t.commit();
session.close();
}
catch(Exception e){
e.printStackTrace();
}
}

}

HibernateUtil.java:
package com.dao;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public class HibernateUtil {
private static SessionFactory sessionfactory;
static{
sessionfactory=new Configuration().configure().buildSessionFactory();
}

public static SessionFactory getSessionfactory() {
return sessionfactory;
}
}

My Hibernate.cfg.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.password">root</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/mysql</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<mapping class="com.action.Customer" resource="com/action/Customer.hbm.xml"/>
</session-factory>
</hibernate-configuration>

success.jsp:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags"%>

<!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=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
Welcome
<s:property value="fname" />
</body>
</html>


Iam struggling with this problem since 3 days but every time i check in mysql DB through select command,values are not getting stored ...but Iam getting success page after registration is done!!
8 years ago
hi all
Iam new to struts and hibernate.I want a simple banking application with struts and hibernate..can anyone please provide me the link for the coding part.
any suggestions are gladly welcomed.
8 years ago
hi all,
Im using Oracle linux 6.3..where there is no sort of odbc.ini or sys.odbc.ini to set up our own DSN(neither the default DSN).I want to use my type-1 odbc driver for making a java program to contact with my oracle 11g Express edition instance.Tired of many ways to set up DSN in linux on internet,but all went in wain(Because all of them teach me to edit odbc.ini file,which was not present).
You can recommend using unix odbc package,but why should I have to install it as type1 odbc driver requires no additional software?.please help me to set up my own DSN file.Thank You.
-raghu

Winston Gutkowski wrote:
I think you're missing his point: the fact is that you can write almost any program in one line - just don't put in any carriage returns.

Whether anyone will want to read it or not (including you) is another matter; which is why the "10 lines" business is complete nonsense.

If you write a GOOD program, no matter how many lines it has, it will almost certainly be better than your friend's 10-liner, because you'll be concentrating on doing the job properly, not in showing off how short you can make it.

And the first part of that task is to understand how we write numbers in longhand. And that you should figure out with a pencil and paper, NOT in Java.

Winston

PS: I would say to your friend that you cannot write a good generic program to do this in 10 lines without "cheating" (ie, lumping multiple statements or entire method definitions on one line).




obviously true Winston:Iam not looking for a thin liner program,rather Iam searching for various ways to make it thin and efficient also.I dont mind if it is huge and efficient!any other way you can write this?now I got 3 nice ways to do so!Thanks all for your overwhelming response!
8 years ago

R. Jain wrote:
So that he can retrieve the String value for the corresponding input from the stored String array..
Because, you need only these strings to name all the numbers from 1 to 100 in words.. Just concatenate them to get appropriate number..



yes.I will try writing that in ashwin and henry's way..!
8 years ago

Ashwin Sridhar wrote:

One line to define the look up table as an array of strings. And one line to do the table look up...



If the input is going to be upto 1000, then hard-coding 1000 strings kills the joy of programming.

I might approach in a different way, have three arrays of strings, one containing "one","two"..."ten", next containing "eleven","twelve",..."nineteen", and the last containing "twenty","thirty"...."ninety".

Then we could use "/" and "%" operators and manipulate the code to get the result more efficiently.



Thanks Ashwin...but I think I forot to mention you input is 1---100 and output is the strings part(one,two...).but you are creating strings on 1st hand?
8 years ago

Henry Wong wrote:

Well, if the goal is the number of lines, then you can do it in two lines. One line to define the look up table as an array of strings. And one line to do the table look up... okay, plus a couple more lines to read input and print output.

In my opinion, I think it is best to get it working first. Don't worry about the number of lines. This way, you understand the problem, the details of it, and of course, your solution to it. You can refactor it to the "10 lines" restriction, once you have a working solution.

Henry


Thanks henry for your prompt reply.could you put more effort on explaining the code part..I dont know how to implement look up table indeed!I just put those 10 lines rule to make things much easier...no worries in removing that...if the solution is simpler...!
8 years ago

fred rosenberger wrote:You sound like you are trying to do the CattleDrive assignment 4a: Say.

Even that one is 77 lines...

Focusing on the number of lines is silly. it encourages bad practices. It might make you do things like this:

import packageA.*;import packageB.*;import packageC.*;

or even

for (int x-1;x<=100;x++){doSomething();doSomethingElse();doAThridThing();}



Thanks for your reply fred.Iam actually haunting for various ways of trying different solutions for this.One would suggest that the easiest way to get down to this is:printing 100 statements like if(1) then System.out.println("one"); and so on.but this is a good way of writing bad code.YUCK!I dont want to import packages neither!
8 years ago
I wanna write a simple java program so that if i give the below input,I should get the following output
Input->output
1->one
2->two
3->three
so on till...
100 hundred,If possible I want to extend this to 1000 numbers.
When my friend asked this,I tried in if,switch,ASCII formats,but went in vain....
because the rule is:
code must be as simple as possible within 10 lines or so...!
Anyone got any Idea???
8 years ago

Seetharaman Venkatasamy wrote:Sorry just i posted previous post to mention terminology is important .... because still I struggle with that :)



haha.I think You get me now:)please post your response...people may think that Iam creating spam !!
8 years ago
JSP

raghavendra raghu wrote:

Seetharaman Venkatasamy wrote:[
response to server? I think another request on response?



sorry for my wording.I actually intended to say is there any method or technology to make server execute my 2 requests simultaneously.refer my first post.Thanks.

8 years ago
JSP

Seetharaman Venkatasamy wrote:[
response to server? I think another request on response?



sorry Venkataswamy but I dont understand u.Iam a beginner in web technologies.please elaborate a way in which I can execute my html as well as sendresponse() method and also the code in my else part and sendResponse().could you tell me how another request on response should be done?There is so much fun in learning these things
8 years ago
JSP