save data DAO

save data DAO

how to save data in db

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
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
ModuleNotFoundError: No module named 'rds-data-dao'
ModuleNotFoundError: No module named 'rds-data-dao'  Hi, My Python... 'rds-data-dao' How to remove the ModuleNotFoundError: No module named 'rds-data-dao' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'rds-data-dao'
ModuleNotFoundError: No module named 'rds-data-dao'  Hi, My Python... 'rds-data-dao' How to remove the ModuleNotFoundError: No module named 'rds-data-dao' error? Thanks   Hi, In your python
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
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
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
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
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 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
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
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 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
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 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
+"' and password='"+Password+"'"); // Iterating resultset for the data
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
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
How to download web page table data, export the table records in an excel file and save
be displayed and ask me to save the file. on clicking the save button the data should...How to download web page table data, export the table records in an excel file and save  i have a web page(.jsp) which contains the table of 4 to 5
How to read data from txt file and save to database MySql - Java Beginners
How to read data from txt file and save to database MySql  Please help me again ,my problem right know is how to read data from txt file then data save to database from JButton.Please give me a tutorial and source code
DAO Classes
DAO Classes  login page code for Dao classes
How to Validate JRadioButton and How to Save data from JRadioButton to MS Access Database - Java Beginners
How to Validate JRadioButton and How to Save data from JRadioButton to MS Access Database  Hello Sir I want Store Corse Type that contains Two...(3,g); int i=st.executeUpdate(); JOptionPane.showMessageDialog(null,"Data
What is the DAO Layer in any application?
What is the DAO Layer in any application?  Hi, What is the use of the DAO layer in any application and how to develop it. Explain with the example code. Thanks   The DAO layer is also known as data access layer
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
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
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
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
DAO Layer explained
stand for Data Access Object, it is design pattern. The DAO contains a connection... DAO Layer explained       In this section we will explain you the DAO Layer of our
implementing DAO - Struts
. The Data Access Object (DAO) is an important component in business applications... Access Object (DAO) to abstract and encapsulate all access to the data source. The DAO manages the connection with the data source to obtain and store data
DAO,DTO,VO Design patterns
DAO,DTO,VO Design patterns  explain dao,dto,vo design patterns in strut 1.3?   Data Access Object (DAO) pattern is the most popular design... the code that accesses the back-end containing your data. Data Transfer Object (DTO
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">
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">
ModuleNotFoundError: No module named 'dao'
ModuleNotFoundError: No module named 'dao'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'dao' How to remove the ModuleNotFoundError: No module named 'dao' error
ModuleNotFoundError: No module named 'dao'
ModuleNotFoundError: No module named 'dao'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'dao' How to remove the ModuleNotFoundError: No module named 'dao' error
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
spring DAO module turorial
spring DAO module turorial  how to integrate springDAO and spring webMVC
save excel file with save and open dilog box
save excel file with save and open dilog box  following is my jsp code it is working correct.. i want to save excel file throgh jsp bt not by hard...");) user should have freedom to save the file in any location so plz give me
What is Spring Struts Hibernate DAO Layer?
What is Spring Struts Hibernate DAO Layer?  Hi, explain me the difference in between Spring Struts Hibernate DAO Layer? Thanks   Hi... applications. Hibernate is used to write the Data access layer which interacts
Version of spring>spring-dao dependency
List of Version of spring>spring-dao dependency
Version of springframework>spring-dao dependency
List of Version of springframework>spring-dao dependency
Version of co.jufeng>jufeng-dao dependency
List of Version of co.jufeng>jufeng-dao dependency
Version of com.aoindustries>ao-dao dependency
List of Version of com.aoindustries>ao-dao dependency

Ads