× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Has anyone experienced an odd value in a CLOB field if you set it to an
empty string?

Here's an example program ... if you want to run it, you'll have to adjust
the url obviously.

I'm using JTOpen 3.1 ...

-------------------------------
import java.sql.*;

public class JDBCTester
{

 private static final String URL = "jdbc:as400://IL400SV1/DEVDMGWRK";

 public JDBCTester() {
  // nothing
 }

 public void go() {
  try {
   Class.forName("com.ibm.as400.access.AS400JDBCDriver");

   Connection c = DriverManager.getConnection(URL);

   PreparedStatement p;

   try {
    p = c.prepareStatement("drop table JDBCTEST");
    p.execute();
    p.close();
   } catch (SQLException e) {
    // nothing
   }

   p = c.prepareStatement(
    "create table JDBCTEST (" +
     "FIELD1 CLOB(14680068), " +
     "FIELD2 CLOB(500) " +
    ")"
   );

   p.execute();
   p.close();

   p = c.prepareStatement("insert into JDBCTEST values(?,?)");

   p.setString(1,"");
   p.setString(2,"");
   p.executeUpdate();
   p.setString(1,"abc123");
   p.setString(2,"xyz789");
   p.executeUpdate();
   p.close();

   p = c.prepareStatement("select FIELD1,FIELD2 from JDBCTEST");

   ResultSet r = p.executeQuery();

   int record=0;
   while(r.next()) {
    String field1 = r.getString(1);
    String field2 = r.getString(2);
    System.out.println("Record #" + ++record);
    System.out.println("Field 1 = " + field1);
    System.out.println("Field 2 = " + field2);
    System.out.println("");
   }

   c.commit();

   r.close();
   p.close();
   c.close();
  } catch (Exception e) {
   System.out.println("Caught: " + e);
   e.printStackTrace();
  }
 }


 public static void main(String[] args) {
  JDBCTester j = new JDBCTester();
  j.go();
  System.exit(0);
 }

}
-------------------------------

When I run this program, I get the following results ...

Record #1
Field 1 = com.ibm.as400.access.SQLClobLocator@xxxxxxx
Field 2 =

Record #2
Field 1 = abc123
Field 2 = xyz789

Notice the value in record 1 for field1?

No other database that we've worked with does this.

Any ideas why JT400 would?

Thanks!

david

--
David Gibbs
dgibbs@xxxxxxx
Sr. Software Engineer



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.