Query CSV File from Java - Backing Bean

 * Created: 2012.
 * Build Results into Console with CSV
package com.dokoll.solutions.inc.cvs.trials;

 * @author Dököll Solutions, Inc.
 * @version 2012.
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

//Start of Program
public class ReadCSVFileBean
	//Button code
  public static void doGetCSVConsoleData()
	  //Entering try catch
      // load the driver into memory

      // create a connection. The first command line parameter is assumed to
      //  be the directory in which the .csv files are held
      Connection conn = DriverManager.getConnection("jdbc:relique:csv:C:\\temp\\CSV_DATA\\");

      // create a Statement object to execute the query with
      //TO DO: Attempt using Prepared Statement here...
      Statement stmt = conn.createStatement();

      // Select* from UserNewLineOutboundInformation.csv
      ResultSet results = stmt.executeQuery("SELECT * FROM UserNewLineOutboundInformation");

      // dump out the results
      while (results.next())
    	  //TO DO: Write a separate JavaBean to build setters for variables
    	  //that can used in Xpages...
    	String SiteName = results.getString("SiteName");
    	String SiteNumber = results.getString("SiteNumber");
    	//Load to Console
        System.out.println("SiteName " + " SiteNumber");
        System.out.println(SiteName + " " + SiteNumber);

      // clean up
    catch(Exception e)
  }//end of program...
All code submitted to OpenNTF XSnippets, whether submitted as a "Snippet" or in the body of a Comment, is provided under the Apache License Version 2.0. See Terms of Use for full details.
No comments yetLogin first to comment...