Showing posts with label Inserting the content into db and then doing manipulation on the data and moving final set of data in the csv file. Show all posts
Showing posts with label Inserting the content into db and then doing manipulation on the data and moving final set of data in the csv file. Show all posts

Saturday, October 6, 2012


//Connecting to DB2 database while reading properties from file
import java.beans.Statement;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.*;


public class ConnectingDb {


//Establishing connection
Statement statement=null;
//Connection connection = getConnection();
public Connection  getConnection() throws ClassNotFoundException, SQLException
{
Properties prop = new Properties();
try{
prop.load(new FileInputStream("./conf/Db.properties"));
}
catch (Exception e){
}
Class.forName (prop.getProperty("DriverName"));
Connection  connection = DriverManager.getConnection(prop.getProperty("ConnectionURL"),prop.getProperty("Username"),prop.getProperty("Password"));
System. out .println( "From DAO, connection obtained " );
return connection;
//statement = connection.createStatement();
}

}