Here you can find the source of isColumnNullable(Connection conn, String table, String column)
public static boolean isColumnNullable(Connection conn, String table, String column) throws SQLException
//package com.java2s; import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; public class Main { /**/*from w ww. ja va2s.co m*/ * Determines whether or not the specified column accepts null values. * * @return true if the column accepts null values, false if it does not (or its nullability is * unknown) */ public static boolean isColumnNullable(Connection conn, String table, String column) throws SQLException { ResultSet rs = getColumnMetaData(conn, table, column); try { return rs.getString("IS_NULLABLE").equals("YES"); } finally { rs.close(); } } /** * Helper function for {@link #getColumnType}, etc. */ protected static ResultSet getColumnMetaData(Connection conn, String table, String column) throws SQLException { ResultSet rs = conn.getMetaData().getColumns("", "", table, column); while (rs.next()) { String tname = rs.getString("TABLE_NAME"); String cname = rs.getString("COLUMN_NAME"); if (tname.equals(table) && cname.equals(column)) { return rs; } } throw new SQLException("Table or Column not defined. [table=" + table + ", col=" + column + "]."); } /** * Closes the supplied JDBC statement and gracefully handles being passed null (by doing * nothing). */ public static void close(Statement stmt) throws SQLException { if (stmt != null) { stmt.close(); } } /** * Closes the supplied JDBC connection and gracefully handles being passed null (by doing * nothing). */ public static void close(Connection conn) throws SQLException { if (conn != null) { conn.close(); } } }