Query in java code is returning null values but its working fine on ODBC query tool

279 views Asked by At

With

SELECT field2 FROM table1

in ODBC query tool I get list of required values, but with the same query from java code I get list of "null" values.

SELECT field2 FROM table1 WHERE field2 IS NOT NULL

didn't help.

field2 - VARCHAR(255)

part of code:

Connection conn = DriverManager.getConnection("jdbc:odbc:Test");
Statement statement = connection.createStatement();
ResultSet resultSet = statement.exequteQuery("Select field2 FROM table1");
while (resultSet.next)
   System.out.println(resultSet.getString(1));
1

There are 1 answers

0
XemyL On BEST ANSWER

Hm, my solution of problem:

while (rs.next()) {
            System.out.println(IOUtils.toString(rs.getCharacterStream("field2")));
        }

p.s. IOUtils - class from Apache Commons IO p.s.s. .getBytes() - return me only 255 symbols (there is were more symbols, so i used Reader)