• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Adding a bit new info to the jforum_user table when registerting

 
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I've tried so hard into getting this to work, check this out.

I have a system already filled with username/passwords from a portal, and I want people to be able to register on the forums with a new username/password (The username is a number, like a social security number) but I need to still know who is who, I'm aware there is a authenticator login or something that can help me integrate my current users with the system, the thing is the usernames in the portal are NUMBERS like SSN's and not names or nicknames, therefore, I need to first validate that person is a member of the Portal, if it is, then insert the user into the database + the username from the portal (Which we call cedula)

So, I've made the following changes:

In mysql\db_struct.sql:

Added:

user_cedula varchar(8) NOT NULL default '',
user_passCons varchar(32) NOT NULL default '',

in jforum_users

In User.java entity:
private String cedula;
private String consultaPassword;
...
...
public void setCedula(String cedula){
this.cedula = cedula;
}
public void setconsultaPassword(String consultaPassword){
this.consultaPassword = consultaPassword;
}
public String getCedula(){
return this.cedula;
}
public String getconsultaPassword(){
return this.consultaPassword;
}

In UserModel.java in drivers\generic (I use MySQL):

..

protected void initNewUser(User user, PreparedStatement p) throws Exception
{
p.setString(1, user.getUsername());
p.setString(2, user.getPassword());
p.setString(3, user.getEmail());
p.setTimestamp(4, new Timestamp(System.currentTimeMillis()));
p.setString(5, user.getActivationKey());
p.setString(6, user.getCedula());
p.setString(7, user.getconsultaPassword());
}

In UserAction.java:
String cedula = this.request.getParameter("cedula");
String passConsulta = this.request.getParameter("passConsulta");
....
/* This one checks the user is registered in the portal */
if (!error){
consultaase myConsulta = new consultaase();
try{
passMy = myConsulta.getPassword(cedula);

}
catch (Exception a) {passMy = "";}
if (((passMy.equals(""))) || (!passMy.equals(passConsulta))){
this.context.put("error", I18n.getMessage("UsernamePasswordCannotBeNull"));
error = true;
}
}

.....
u.setCedula(cedula);
u.setconsultaPassword(passConsulta);

And Finally, on generic_queries:

UserModel.addNew = INSERT INTO jforum_users (username, user_password, user_email, user_regdate, user_actkey, user_cedula, user_passCons) VALUES (?, ?, ?, ?, ?, ?, ?)

Ok, everything 'works' fine, I added two textfields in user_new.htm and named them cedula and passConsulta.

Now, when I try to 'register' I get:

No value specified for parameter 6


This is clearly because somehow is not saving, or assigning, or passing the value cedula and passCons to the SQL statement (That exception is a mysql exception).

I'm running Tomcat 5, SDK1.4.02 and mysql 4.

Thanks!
[originally posted on jforum.net by Damian]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, I've been doing some debugging.

Apparently, It is not creating the fields user_cedula and passCons on the Database, I ran the script manually and it did, and then I added the user no problem, it added the info I needed.

I'm making the changes to mysql\mysql_db_struct.sql and I am selecting MySQL on setup, why isn't it creating the database like I stated in the sql?:

Here is the complete section:

--
-- Table structure for table 'jforum_users'
--

DROP TABLE IF EXISTS jforum_users;
CREATE TABLE jforum_users (
user_id mediumint(8) NOT NULL auto_increment,
user_active tinyint(1) default NULL,
username varchar(50) NOT NULL default '',
user_password varchar(32) NOT NULL default '',
user_session_time bigint default 0,
user_session_page smallint(5) NOT NULL default '0',
user_lastvisit datetime default null,
user_regdate datetime default null,
user_level tinyint(4) default NULL,
user_posts mediumint(8) NOT NULL default '0',
user_timezone varchar(5) NOT NULL default '',
user_style tinyint(4) default NULL,
user_lang varchar(255) NOT NULL default '',
user_dateformat varchar(20) NOT NULL default '%d/%M/%Y %H:%i',
user_new_privmsg smallint(5) NOT NULL default '0',
user_unread_privmsg smallint(5) NOT NULL default '0',
user_last_privmsg datetime NULL,
user_emailtime datetime default NULL,
user_viewemail tinyint(1) default '0',
user_attachsig tinyint(1) default '1',
user_cedula varchar(8) NOT NULL default '',
user_passCons varchar(32) NOT NULL default '',
user_allowhtml tinyint(1) default '0',
user_allowbbcode tinyint(1) default '1',
user_allowsmilies tinyint(1) default '1',
user_allowavatar tinyint(1) default '1',
user_allow_pm tinyint(1) default '1',
user_allow_viewonline tinyint(1) default '1',
user_notify tinyint(1) default '1',
user_notify_pm tinyint(1) default '1',
user_popup_pm tinyint(1) default '1',
rank_id smallint(5) default '1',
user_avatar varchar(100) default NULL,
user_avatar_type tinyint(4) NOT NULL default '0',
user_email varchar(255) NOT NULL default '',
user_icq varchar(15) default NULL,
user_website varchar(100) default NULL,
user_from varchar(100) default NULL,
user_sig text,
user_sig_bbcode_uid varchar(10) default NULL,
user_aim varchar(255) default NULL,
user_yim varchar(255) default NULL,
user_msnm varchar(255) default NULL,
user_occ varchar(100) default NULL,
user_interests varchar(255) default NULL,
user_actkey varchar(32) default NULL,
gender char(1) default NULL,
themes_id mediumint(8) default NULL,
deleted tinyint(1) default NULL,
user_viewonline tinyint(1) default '1',
security_hash varchar(32),
user_karma DECIMAL(10,2),
PRIMARY KEY (user_id)
) TYPE=InnoDB;
[originally posted on jforum.net by Anonymous]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The web installer does not read from mysql_db_struct.sql, so that's why you are having problems with it.

Is the web installer a must? otherwise, you can use the manual installation.

Rafael
[originally posted on jforum.net by Rafael Steil]
 
What are your superhero powers? Go ahead and try them on this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic