Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JDBC save data DAO
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Mumbai
save data DAO
1 Answer(s)      a year and 6 months ago
Posted in : JDBC


how to save data in db


Advertisement
View Answers

May 22, 2013 at 11:21 AM


package com.tcs.ignite.dao;

import com.tcs.ignite.bean.User;
import com.tcs.ignite.connection.Connectiondetails;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author ignite234
 */
public class UserDAO {

    private Connectiondetails connectionDetails;

    public UserDAO() {
        connectionDetails = new Connectiondetails();
    }

    public boolean saveDetails(User user) {
        connectionDetails.openConnection();
        String query2 = "select * from user where Email_id like '%" + user.getEmail() + "%'";
        try {
            ResultSet resultSet = connectionDetails.statement.executeQuery(query2);
            if(resultSet.next()) {
                return false;
            }
        } catch (SQLException ex) {
            Logger.getLogger(UserDAO.class.getName()).log(Level.SEVERE, null, ex);
        }
        String query = "insert into user (Name,Email_id,Password,Gender,Hobby,City) values('" + user.getName() + "','" + user.getEmail() + "','" + user.getPassword() + "','" + user.getGender() + "','" + user.getHobby() + "','"+user.getCity()+"');";
        try {
            int result = connectionDetails.statement.executeUpdate(query);
            if (result == 0) {
                return false;
            }
        } catch (SQLException ex) {
            Logger.getLogger(UserDAO.class.getName()).log(Level.SEVERE, null, ex);
            return false;
        } finally {
            connectionDetails.closeConnection();
        }
        return true;
    }


Related Tutorials/Questions & Answers:
save data DAO
save data DAO  how to save data in db   package com.tcs.ignite.dao; import com.tcs.ignite.bean.User; import com.tcs.ignite.connection.Connectiondetails; import java.sql.ResultSet; import java.sql.SQLException; import
save data in excel
save data in excel  hello sir, i'm new to this field i want to know can i save data in excel by html forms input,means if any one fill up form online then it is save offline in excel how can i do it can you give me solution sir
Advertisements
save data in excel
save data in excel  hello sir, i'm new to this field i want to know can i save data in excel by html forms input,means if any one fill up form online then it is save offline in excel how can i do it can you give me solution sir
Creating Data Access Object (DAO) Design Pattern
Creating Data Access Object (DAO) Design Pattern Data Access Object... to separating the object persistence and data access logic. All the basic data access code contains in  DAO and it provides a simple interface to access the data
dao
+"' and password='"+Password+"'"); // Iterating resultset for the data
How to save data - Swing AWT
How to save data  Hi, I have a problem about how to save data ,but first before data save to dababase, data must view in jLisit or Jtable... save data from jList and Jtable(in jList or jTable data will be many).Thank's
How to display data in jsp from dao using java beans?
How to display data in jsp from dao using java beans?  Hi I need to display data in jsp pulling from dao using java beans, Please can anyone give me the sample application with above topics. Any help would be highly appreciated
How to save database data into excelsheet using hibernate
How to save database data into excelsheet using hibernate  How to save database data into excelsheet using hibernate
Data Access object (DAO) Design Pattern
. The DAO design pattern completely  hides the data access implementation... and some DAO classes to implement those interfaces.   The Data Access object...; } .style3 { background-color: #FFFFCC; } Data Access Object Pattern Data Access
To save table format data in pdf/excel in jsp
To save table format data in pdf/excel in jsp  Hello, I am doing web... table. So my question is ,I want so save this html format data in pdf/excel format... can save html table data in pdf/excel format.Your inputs are valuable to me
How can we save a data list in jsf?
How can we save a data list in jsf?  I have a code in jsf that fires a query in Data Base each time it is called, i have added a validation check... it is called again. I tried using save State but it did not help as other functions got
Save the input data until user get changed
Save the input data until user get changed  I would like to know how to store the give input data and perform the calculations even after re-opening... and save this amount until he changes it again. Thank You
Save the input data until user get changed
Save the input data until user get changed  I would like to know how to store the give input data and perform the calculations even after re-opening... and save this amount until he changes it again. Thank You
Save the input data until user get changed
Save the input data until user get changed  I would like to know how to store the give input data and perform the calculations even after re-opening... and save this amount until he changes it again. Thank You
save switch data into database - Java Beginners
save switch data into database  switch(menu) { case 1://add a student System.out.print("Enter student ID: "); int ID = scan.nextInt(); System.out.print("Enter your name: "); String name = scan.next(); break
DAO - JDBC
DAO  what is dao ? and how to use it?  Hi Friend, The DAO is a pattern that provides a technique for separating object persistence and data access logic from any particular persistence mechanism or API. Thanks
SQLGrammarException while trying to save data in db
SQLGrammarException while trying to save data in db  //hibernate cfg file// <?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN
DAO Classes
DAO Classes  login page code for Dao classes
DAO Example
DAO Example  Dear Friends Could any one please give me any example of DAO application in struts? Thanks & Regards Rajesh
DAO in Struts
DAO in Struts  Can Roseindia provide a simple tutorial for implementation of DAO with struts 1.2? I a link already exits plz do tell me. Thank you
How to save data to excel with a 2.1 work sheet format without changing it?
How to save data to excel with a 2.1 work sheet format without changing it?  hi , i have done a program that allows user to inout data through jtable and save it to excel file then read it again .. the problem is , when data
How to save form data to a csv file using jquery or ajax
How to save form data to a csv file using jquery or ajax  Please let...) {// code for IE7+, Firefox, Chrome, Opera, Safari data=new XMLHttpRequest(); } else {// code for IE6, IE5 data=new ActiveXObject
doubt on DAO's
doubt on DAO's  hai frnds.... can anyoneexplain about how... our own plugin????? and please help me. how to use dao s while integrating struts with hibernate..??? actually what is the purpose of dao's ????? please help
doubt on DAO's
doubt on DAO's  hai frnds.... can anyoneexplain about how... our own plugin????? and please help me. how to use dao s while integrating struts with hibernate..??? actually what is the purpose of dao's ????? please help
how to save html form data into .csv file using only jsp.
how to save html form data into .csv file using only jsp.  Dear all, I am developing a website only using jsp and html. i need to save the form data...:\\File.xls"); wb.write(fileOut); fileOut.close(); out.println("Data is saved
dao pack
dao pack  package com.tsi.dao; import java.sql.*; import com.tsi.constants.*; public class DaoPack { public static Connection conn = null; public static Connection createConnection() { try
dao pack
dao pack  package com.tsi.dao; import java.sql.*; import com.tsi.constants.*; public class DaoPack { public static Connection conn = null; public static Connection createConnection() { try
CRUD DAO
CRUD DAO  how to create dao for create,read,update and delete?   /* *ConnectionManager * * *Version:1.0 * *Date:25-Nov-2011 * */ package com.student.dao; import java.sql.*; import org.apache.log4j.Logger
DAO DTO design pattern
DAO DTO design pattern  Hi,using dao and dto i want to perform insert,update and delete operation.and the data should navigate from 1 frame 2...;/br> <input type="submit" name="Submit" value="Save">
DAO DTO design pattern
DAO DTO design pattern  Hi,using dao and dto i want to perform insert,update and delete operation.and the data should navigate from 1 frame 2...;/br> <input type="submit" name="Submit" value="Save">
DAO DTO design pattern
DAO DTO design pattern  Hi,using dao and dto i want to perform insert,update and delete operation.and the data should navigate from 1 frame 2...;/br> <input type="submit" name="Submit" value="Save">
Advertisements
 

 

 

DMCA.com