-
Bug
-
Resolution: Fixed
-
P4
-
1.3.0
-
beta
-
x86
-
windows_2000
Name: boT120536 Date: 01/15/2001
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build
Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)
When retrieving a null value from an SQL database column of type 'text'
an SQLException is thrown.
Retrieving a null value from a varchar(20) column returns null as expected.
Source:
package untitled15;
/**
* Title:
* Description:
* Copyright: Copyright (c) 2001
* Company:
* @author
* @version 1.0
*/
import java.sql.*;
public class Untitled1
{
public Untitled1()
{
}
public static void main(String[] args)
{
try
{
String url="jdbc:odbc:saffron";
String login = "sa"; // use your login here
String password = ""; // use your password
here
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c = DriverManager.getConnection(url,login,password);
Statement s = c.createStatement();
s.execute("DROP TABLE testtable");
s.execute("CREATE TABLE testtable(testColumn VARCHAR(20) )");
s.execute("INSERT INTO testtable VALUES (NULL)");
s.execute("SELECT * from testtable");
ResultSet rs = s.getResultSet();
rs.next();
String o =(rs.getString(1));
System.out.println(o);
s.execute("DROP TABLE testtable");
s.execute("CREATE TABLE testtable(testColumn text )");
s.execute("INSERT INTO testtable VALUES (NULL)");
s.execute("SELECT * from testtable");
rs = s.getResultSet();
rs.next();
o =(rs.getString(1));
System.out.println(o);
}
catch (Exception e)
{
System.out.println(e.getMessage());
e.printStackTrace();
}
}
}
(Review ID: 115134)
======================================================================