Java tutorial
/** * Copyright (c) 2001-2012 "Redbasin Networks, INC" [http://redbasin.org] * * This file is part of Redbasin OpenDocShare community project. * * Redbasin OpenDocShare is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package dao; import java.sql.Connection; import java.sql.PreparedStatement; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import util.RegexStrUtil; /** * This class implements PersonalinfoAddQuery * Used by <code>Personalinfo</code> bean * @author Smitha Gudur (smitha@redbasin.com) * @version $Revision: 1.1 $ */ class PersonalinfoAddQuery extends BaseCommonQuery { protected final Log logger = LogFactory.getLog(getClass()); public void run(Connection conn, String[] params) throws BaseDaoException { /* public void run(Connection conn, String dob, String title, String ihave, String iwant, String industry, String company, String pwebsite, String cwebsite, String blogsite, String education, String city, String state, String country, String desc, String interests, String zipcode, int gender, String nickname, String designation, String bcity, String bstate, String bcountry, String bzipcode, String hphone, String cphone, String bphone, String yim, String aim, String msn, String icq, String loginid, String pLabel, String dLabel) throws BaseDaoException { */ /**** use UTC_TIMESTAMP after upgrading mysql **/ // default date PreparedStatement query = null; String dob = params[0]; String title = params[1]; String ihave = params[2]; String iwant = params[3]; String industry = params[4]; String company = params[5]; String pwebsite = params[6]; String cwebsite = params[7]; String blogsite = params[8]; String education = params[9]; String city = params[10]; String state = params[11]; String country = params[12]; String desc = params[13]; String interests = params[14]; String zipcode = params[15]; String gender = params[16]; String nickname = params[17]; String designation = params[18]; String bcity = params[19]; String bstate = params[20]; String bcountry = params[21]; String bzipcode = params[22]; String hphone = params[23]; String cphone = params[24]; String bphone = params[25]; String yim = params[26]; String aim = params[27]; String msn = params[28]; String icq = params[29]; //String loginid = params[30]; String pLabel = params[30]; String dLabel = params[31]; String street = params[32]; String bstreet = params[33]; String zone = params[34]; if (RegexStrUtil.isNull(dob)) { dob = "1970-01-01"; } byte[] mydesc = { ' ' }; if (!RegexStrUtil.isNull(desc)) { mydesc = desc.getBytes(); } String stmt = "insert into usertab values (" + "LAST_INSERT_ID()" + ", CURRENT_TIMESTAMP(), " + 0 + ", '" + dob + "', '" + title + "','" + ihave + "', '" + iwant + "', '" + industry + "', '" + company + "', '" + pwebsite + "', '" + cwebsite + "', '" + blogsite + "', '" + education + "', '" + street + "', '" + city + "', '" + state + "', '" + country + "',?, '" + interests + "', '" + zipcode + "', '" + designation + "', '" + gender + "', '" + nickname + "', '" + bstreet + "', '" + bcity + "', '" + bstate + "', '" + bcountry + "', '" + bzipcode + "', '" + hphone + "', '" + cphone + "', '" + bphone + "', '" + yim + "', '" + aim + "','" + msn + "', '" + icq + "', '" + pLabel + "', '" + dLabel + "', '" + zone + "')"; try { query = conn.prepareStatement(stmt); query.setBytes(1, mydesc); query.executeUpdate(); } catch (Exception e) { logger.warn("Error occured while executing PersonalinfoAddQuery," + stmt, e); throw new BaseDaoException("Error occured PersonalinfoAddQuery" + stmt, e); } } }