Wednesday, December 15, 2010

SQL where clause with date in Java

Using date in where clause with Java is a bit tricky, this example explains it all

import java.sql.Connection;     

import java.sql.DriverManager;

import java.sql.SQLException;

import java.sql.Statement;

import java.sql.ResultSet;

public class WhereClause {   

    public static void main(String[] args) {

       try {         

            Statement stmt;

            Connection con;


              con = DriverManager.getConnection("jdbc:odbc:DBNAME",null,null);


              ResultSet rs=stmt.executeQuery("Select * from Job_Status where Date ="+"#2010-11-27#");

            while( )


         String str1= rs.getString("Date");






        catch (Exception e) {






No comments:

Post a Comment