import java.io.StringReader;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Statement;


/**
 * 
 * @author chrisw
 */
public class Blah {

  public static void main(String[] args) {
    jdbcTest();
  }
  
  public static void jdbcTest() {
    try {
      Class.forName("com.mysql.jdbc.Driver");
    }
    catch (ClassNotFoundException ex) {
      System.err.println(ex.getMessage());
    }

    try {
      Connection conn = null;
      Statement batch = null;
      PreparedStatement stmt = null;
      try {
        conn = DriverManager.getConnection("jdbc:mysql://localhost/test", "root", "root");

        batch = conn.createStatement();
        batch.addBatch("drop table if exists TEXT_COLUMN");
        batch.addBatch(
            "create table TEXT_COLUMN (" +
            "  path text not null" +
            ") engine=InnoDB");
        batch.executeBatch();
        
        stmt = conn.prepareStatement("insert into TEXT_COLUMN (path) values (?)");
        stmt.setCharacterStream(1, new StringReader(""), 0);
        
        // failure here
        stmt.executeUpdate();
      }
      finally {
        if(stmt != null) stmt.close();
        if(batch != null) batch.close();
        if(conn != null) conn.close();
      }
    }
    catch(SQLException ex) {
      ex.printStackTrace();
    }
  }
}
