Ejemplo n.º 1
0
 public virtual Connection CreateConnection()
 {
     try
     {
         Connection newConnection = dbConf.GetConnection();
         newConnection.SetAutoCommit(false);
         newConnection.SetTransactionIsolation(Connection.TransactionSerializable);
         return(newConnection);
     }
     catch (Exception e)
     {
         throw new RuntimeException(e);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// <inheritDoc/>
        ///
        /// </summary>
        /// <exception cref="System.IO.IOException"/>
        public override RecordWriter <K, V> GetRecordWriter(TaskAttemptContext context)
        {
            DBConfiguration dbConf    = new DBConfiguration(context.GetConfiguration());
            string          tableName = dbConf.GetOutputTableName();

            string[] fieldNames = dbConf.GetOutputFieldNames();
            if (fieldNames == null)
            {
                fieldNames = new string[dbConf.GetOutputFieldCount()];
            }
            try
            {
                Connection        connection = dbConf.GetConnection();
                PreparedStatement statement  = null;
                statement = connection.PrepareStatement(ConstructQuery(tableName, fieldNames));
                return(new DBOutputFormat.DBRecordWriter(this, connection, statement));
            }
            catch (Exception ex)
            {
                throw new IOException(ex.Message);
            }
        }