3:50 pm - Wednesday February 19, 1755

Statement ISNULL() Example program in java Jdbc mysql database

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044

Create Statement  for  the  table EMP:


Mysql>Create table EMP (name varchar(12),id int(5),salary int(10));

INSERT INTO EMP(name,id,salary) VALUES("Karthik",3,5000 );

INSERT INTO EMP(name,id,salary) VALUES("Tamil",4,2500 );

JAVA CODE  for ISNULL :

package myjava1;

import java.sql.*;

public class Null {

	/**
	 * @param args
	 */

	// TODO Auto-generated method stub
	public static void main(String[] args) throws Exception {

		Class.forName("com.mysql.jdbc.Driver").newInstance();
		Connection conn = DriverManager.getConnection(
				"jdbc:mysql://localhost:3306/Arun", "root", "root");
		Statement st = conn.createStatement();

		st = conn.createStatement();
		ResultSet rs = st
				.executeQuery("SELECT name,id FROM EMP      WHERE salary IS NULL");

		while (rs.next()) {
			String name = rs.getString(1);
			System.out.println(name);

		}

		rs.close();
		st.close();
		conn.close();

	}

}

Output:

Filed in: Z-A All Java Codes

Comments are closed.