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 - WebSevicesneed 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 queryneed 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 db2Need 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 functionsql
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
How can i search and insert within a queryHow 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 needneed 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
searchsearch how to develop
search box and how to retrive data from database..
Please visit the following link:
Search box
query optimizationquery optimization hai ! i
need a code in java for database
query optimization.plz help
query stringquery string
Need some examples of
query strings.send me as soon as possible.
Regards,
R.Santhosh
SEARCHSEARCH 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
elasticsearch search by typeelasticsearch
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 ORMNeed 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
need of codeneed of code howto convert greyscale image to binary image in java
need codingneed 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 queriesNeed 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 SuggistionNeed 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 ProjectNeed 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 projectneed 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 answerneed 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 helpNeed 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 helpNeed 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 JUnitNeed 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 helpNeed 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 jspQuery 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 codeneed 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 codeneed 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 codeneed 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 StringNSMutableArray
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 ExampleHibernate 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 JDBCquery 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 queryphp 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 SearchGoogle 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