need search query

need search query

View Answers

March 19, 2009 at 12:32 AM

Hi Friend,

Please try the following code. It will be helpful in solving your problem.


/* For Working code use these sql queries

create database komal;

use komal;

create table stu(name varchar(10), dob date);

insert into stu values('komal','1984,10,27');

*/

import java.sql.*;

public class NewClass {

public static void main(String args[]) {

int date = 27;
int month = 10;
int year = 1984;

Connection con = null;
String url = "jdbc:mysql://localhost:3306/";;
String db = "komal";
String driver = "com.mysql.jdbc.Driver";
String user = "root";
String pass = "root";

Date dob = new Date(1);

try {
Class.forName(driver);
con = DriverManager.getConnection(url + db, user, pass);

String sql = "select * from stu where name ='komal'";
Statement st = con.createStatement();
ResultSet rs = st.executeQuery(sql);

while (rs.next()) {
dob = rs.getDate("dob");
}
} catch (Exception e) {
e.printStackTrace();
}
System.out.println(dob);

if (dob.compareTo(new Date(year - 1900, month - 1, date)) == 0) {
System.out.println("search sussesfull...");
} else {
System.out.println("Record not found");
}
}
}

Thanks









Related Tutorials/Questions & Answers:
need search query - WebSevices
need search query  I have a field in database as DOB. But I want to search recrods as per "fromage" to "toage". I dont know how to compare the ages...) { System.out.println("search sussesfull..."); } else
need query
need query  hi sir , i am beginner to sql.i need a query so that it can be helpful to my project. i have four tables each containing different fruits with different amounts. i need a query in such a way that when i say some
Advertisements
Need a query to run in db2
Need a query to run in db2  hi all, I need a query to run in DB2...; Table 2- ACCOUNTS Fields-LEDGERCODE,ACCOUNTNUMBER,BALANCE FROM THE ABOVE I NEED A QUERY TO RETRIEVE ONLY THE ACCOUNTYPE=AFFILIATE FOR ACCOUNTNUMBERS FROM TABLE
sql query search function
sql query search function  i have a textbox on a form , i like a search a data in the form, when i give whatever name and id or etc..its will search and show the same form , so help me using jsp
search query - SQL
. i have to search? how to do query for this? any one can help me...search query  hi anyone can help me? i have four textfield...) 4)Age From and Age to ((drop down list box) i have to search the result
Need query for rollup based on month and category
Need query for rollup based on month and category   Hi, Here is my question.. I have a table as below. trans_date,cateory,amount 1-1-11,1,10 2-1-11,2,20 3-2-11,3,15 23-2-11,4,12 13-5-11,4,19 Need a query to get result like
Case-insensitive search using Hibernate Query Language(HQL).
Case-insensitive search using Hibernate Query Language(HQL).  What is Case-insensitive search using Hibernate Query Language
How can i search and insert within a query
How can i search and insert within a query  if it is possible that for eg: Retrieve seat numbers sql tables bases of some conditions eg batch semester and degree if i search batch 2008 , semester first and degree bscs then search
urgent need for jsp code with mysql query for uploading and downloading file - JSP-Servlet
urgent need for jsp code with mysql query for uploading and downloading file  can anyone tell me how to upload and download a doc file using jsp with mysql as the back end... and kindly help me to create the table too
need
need  i need a jsp coding based project plz help me
Search
Search   Hi, I have a project in which I am trying to enter "Marathi" (Indian local language) data in JSP using JSTL and trying to search data... and tries to search then It shows no data from database
search
search  how to develop search box and how to retrive data from database..   Please visit the following link: Search box
query optimization
query optimization  hai ! i need a code in java for database query optimization.plz help
query string
query string  Need some examples of query strings.send me as soon as possible. Regards, R.Santhosh
SEARCH
SEARCH  how can we do search in jsp...? option for search criteria like name and DOB...   Please visit the following links: http://www.roseindia.net/jsp/user-search.shtml http://www.roseindia.net/servlets/search.shtml
sql query - JDBC
sql query  I need a SQL query to add data into database
elasticsearch search by type
elasticsearch search by type  Hi, How to perform search by type in elasticsearch? Thanks   HI, Use following query: GET /_search..." } } } Above query will search all the data with the type "doc". Thanks
Need of ORM
Need of ORM  Why do you need ORM tools like hibernate
multiple keyword search - SQL
can n't guess which textfield they give and search. i need query... and city and click search button or user may type in country and genderand click search button or user may type in country and age and click search button
how to show search results in the same panel of jframe to where search field and button is present..
application i need to show search results in the same panel of jframe to where...how to show search results in the same panel of jframe to where search field and button is present..  Hello Sir, Sir i do have one more query
need of code
need of code  howto convert greyscale image to binary image in java
need coding
need coding  sir i need code for simple bank application in jsp please send it   sir i need the coding for simple bank application in jsp.   Please visit the following link: Jsp Bank Application
Need help with nested queries
Need help with nested queries  Hello, Table1 has "id", "votes" columns. Table2 has "id", "Name" column. I need to retrieve Name and its... me with a query? Thanks in advance
Need Suggistion
Need Suggistion  how to call a callable statement in our jSp page using Struts environment
urgent need
urgent need   Input a line. Count the number of words that start with a capital letter
Need Project
Need Project  How to develop School management project by using Struts Framework? Please give me suggestion and sample examples for my project
need to Program
need to Program   Can any one help me on below How to insert more then one records in EXCEL Sheet using JSP
need
need
need project
need project  hi im new on this site so dnt knw actual procedure . but i need a project on banking system in java with sql database. which should... is good plz add it i need project till Saturday i.e 10th march 2012 plzzzz
need answer
need answer  Given a phone number, as a string, generate the lettercombinations that are possible based on the telephone keypad's number/letter relationship (ie, 1 is related to no letters, 2 is related to 'a' 'b' 'c', 3
Need help
Need help  Hello... I need some help I have a method which contains 1 string value and i wnat when this method get called den that string value should b assigned as array name.. for example.. i have a method name() which
Need help
Need help  Hello... I need some help I have a method which contains 1 string value and i wnat when this method get called den that string value should b assigned as array name.. for example.. i have a method name() which
sql query
numbers of sids.i want to delete the sid based on the mid.for that i need sql query plz help to me
sql query
numbers of sids.i want to delete the sid based on the mid.for that i need sql query plz help to me
sql query
numbers of sids.i want to delete the sid based on the mid.for that i need sql query plz help to me
Need of JUnit
Need of JUnit  Hi sir, What makes JUnit better than other testing tools for Java Unit testing?   Hi friend.. It is better to know.... There's no need to manually comb through a report of test results.ADS_TO_REPLACE_2 4
Need help
Need help  Dear sir, I have a problem. How to write JSP coding, if a user select a value from drop down list for example department, the another drop down list should show the list of name in the department that chosen before
Query in jsp
Query in jsp  I have one textbox in jsp. when i will write any letter in that textbox i want all values which are starting from that letter in option from database. same as we are getting in google search textbox. Thank
NEED A PROG
NEED A PROG   whats the program to add,delete, display elements of an object using collecions. without using linked list   Hi Friend, Try the following code: import java.util.*; class CollectionExample { public
need code
need code  Create Vehicle having following attributes: Vehicle No., Model, Manufacturer and Color. Create truck which has the following additional attributes:loading capacity( 100 tons?).Add a behavior to change the color
need code
need code  Create Vehicle having following attributes: Vehicle No., Model, Manufacturer and Color. Create truck which has the following additional attributes:loading capacity( 100 tons?).Add a behavior to change the color
need code
need code  Create Vehicle having following attributes: Vehicle No., Model, Manufacturer and Color. Create truck which has the following additional attributes:loading capacity( 100 tons?).Add a behavior to change the color
Need help with this!
Need help with this!  Can anyone please help me with this? It's suppose to write to a file student information: student name, student Id, test scores... to effectivly end the loop with out the need to break it. for(i=(0); i <
NSMutableArray Search String
NSMutableArray Search String  Hi all, In my iPhone SDK application.. i wanted to search from the table data. My question is ..do i need to innsert the table data into search array? thanks
Hibernate Criteria Query Example
Hibernate Criteria Query Example In this Example, We will discuss about hibernate criteria query, The interface org.hibernate.Criteria is used to create the criterion for the search. In this example we create a criteria instance
query in JDBC
query in JDBC  What are the steps required to execute a query in JDBC
SQL QUERY
Gopal oracle C Now i need to write a query "which
php show last query
php show last query  How to show the last updated record from the database in PHP? Is there any query that i need to write in the php script
Google Search
Google Search  I have a textbox and submit button in my JSP page. On giving word in the textbox and click submit it should redirct to google search... code I need. Anyone can help me with explanation

Ads