Package

Source Code of JdbcExample

/*
*
*
*/

import au.com.bytecode.opencsv.CSVWriter;

import java.io.StringWriter;
import java.sql.ResultSet;
import java.sql.SQLException;

public class JdbcExample
{

  public static void main(String[] args)
  {
    ResultSet rs = null;

    try
    {
      rs = getResultSet();
     
      StringWriter sw = new StringWriter();
     
      CSVWriter writer = new CSVWriter(sw);
      writer.writeAll(rs, false);
      writer.close();
     
      System.out.println(sw);
    }
    catch (Exception ex)
    {
      ex.printStackTrace();
    }
    finally
    {
      if (rs != null)
      {
        try
        {
          rs.close();
        }
        catch (SQLException ignore)
        {
          // ignore
        }
      }
    }

  }

  private static ResultSet getResultSet()
  {
    return new MockResultSet(10);
  }
}
TOP

Related Classes of JdbcExample

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.