need search query

Ads

 
 

Share on Google+Share on Google+

kathiresan
need search query
1 Answer(s)      8 years ago
Posted in : WebSevices
Ads
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

Ads









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
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
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
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
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
need
need  i need a jsp coding based project plz help me
search
search  how to develop search box and how to retrive data from database..   Please visit the following link: Search box
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
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
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
sql query - JDBC
sql query  I need a SQL query to add data into database
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
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 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
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
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
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
Search index
Search index  how to write code for advanced search button
query in JDBC
query in JDBC  What are the steps required to execute a query in JDBC
Hibernate Criteria restrictions Query Example
Hibernate Criteria restrictions 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
SQL QUERY
Gopal oracle C Now i need to write a query "which
Query conversion
Query conversion  can please convert the following mysql query to hibernate query select * from table1 where field1 not in (select field_1 from table3
Array search
Array search  Need a program which performs a searching operation on a one dimensional array called NUM, which is an N-element array stored in a file... for the search operation. he value with one or more of the array items. Search begins

Ads

 
Advertisement null

Ads