-->
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.  [ 1 post ] 
Author Message
 Post subject: JDBCExceptionReporter:46 - Invalid argument value: Duplicate
PostPosted: Tue Apr 27, 2004 9:51 am 
Beginner
Beginner

Joined: Wed Mar 24, 2004 8:43 am
Posts: 42
hi
here this is code for new user loggin, when we enter already exists user id , then system dispalyed the erorr page.( Primary key is user id)

but when we add a new user details the system does display following erorr, but data has been inserted to the database.


19:34:45,510 INFO SessionFactoryImpl:118 - building session factory
id is testtest
password is dqwd
19:34:45,525 INFO SessionFactoryObjectFactory:82 - no JNDI name configured
id is testtest
email is wdqwdqwdqwd
users size is []
users list size are0
password is dqwd
email is wdqwdqwdqwd
users size is []
users list size are0
19:34:45,541 WARN JDBCExceptionReporter:38 - SQL Error: 1062, SQLState: S1009
19:34:45,541 ERROR JDBCExceptionReporter:46 - Invalid argument value: Duplicate
entry 'testtest' for key 1
19:34:45,541 WARN JDBCExceptionReporter:38 - SQL Error: 1062, SQLState: S1009
19:34:45,557 ERROR JDBCExceptionReporter:46 - Invalid argument value: Duplicate
entry 'testtest' for key 1
19:34:45,557 ERROR JDBCExceptionReporter:38 - Could not execute JDBC batch update


package test.hibernate.actions;

import java.util.List;
import java.util.Iterator;

import webwork.action.ActionSupport;
import webwork.action.CommandDriven;
import net.sf.hibernate.Session;
import net.sf.hibernate.SessionFactory;
import net.sf.hibernate.cfg.Configuration;
import net.sf.hibernate.HibernateException;
import test.hibernate.util.SessionManager;
import test.hibernate.data.User;


public class NewUserlog extends ActionSupport implements CommandDriven {
private String id;
private String pword;
private String email;
private List users;
String checklogin;

public List getUsers() {
return users;
}

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

public String getPword() {
return pword;
}

public void setPword(String pword) {
this.pword =pword;
}

public String getEmail() {
return email;
}

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


public String doExecute() {
try {


Configuration cfg=new Configuration().addClass(test.hibernate.data.User.class);



SessionFactory sf=cfg.buildSessionFactory();
Session sess=sf.openSession();
users = sess.find("select u from u in class test.hibernate.data.User"
+" where u.id='"+ id +"'");


System.out.println( " id is " + id);
System.out.println( " password is " + pword);
System.out.println( " email is " + email);
System.out.println( " users size is " + users);
System.out.println(" users list size are"+ users.size());

if(users.size() == 0 || users.equals("")){

User event = new User();
event.setId(id);
event.setPassword(pword);
event.setEmail(email);

sess.save(event);
sess.flush();
sess.close();
checklogin="SUCCESS";
return SUCCESS;
}


else if(users!=null || !users.equals("")){
System.out.println(" error in logging");
checklogin="

;
return ERROR;

}

sess.flush();
sess.close();

System.out.println(" check login value is "+ checklogin);
return checklogin;


} catch (HibernateException e) {
e.printStackTrace();
System.out.println(" exception value is "+ e);
return ERROR;
}
}

public String doEnter() {
return INPUT;
}

}


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

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.